summaryrefslogtreecommitdiffstats
path: root/src/test/test-stat-util.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/test-stat-util.c')
-rw-r--r--src/test/test-stat-util.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/test/test-stat-util.c b/src/test/test-stat-util.c
index 5aca207..8d7fd5b 100644
--- a/src/test/test-stat-util.c
+++ b/src/test/test-stat-util.c
@@ -180,6 +180,25 @@ TEST(dir_is_empty) {
assert_se(dir_is_empty_at(AT_FDCWD, empty_dir, /* ignore_hidden_or_backup= */ false) > 0);
}
+TEST(fd_verify_linked) {
+ _cleanup_(rm_rf_physical_and_freep) char *t = NULL;
+ _cleanup_close_ int tfd = -EBADF, fd = -EBADF;
+ _cleanup_free_ char *p = NULL;
+
+ tfd = mkdtemp_open(NULL, O_PATH, &t);
+ assert_se(tfd >= 0);
+
+ assert_se(p = path_join(t, "hoge"));
+ assert_se(touch(p) >= 0);
+
+ fd = open(p, O_CLOEXEC | O_PATH);
+ assert_se(fd >= 0);
+
+ assert_se(fd_verify_linked(fd) >= 0);
+ assert_se(unlinkat(tfd, "hoge", 0) >= 0);
+ assert_se(fd_verify_linked(fd) == -EIDRM);
+}
+
static int intro(void) {
log_show_color(true);
return EXIT_SUCCESS;