diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 6b129c2eac..ff447c6582 100644 --- a/src/test/test-mountpoint-util.c +++ b/src/test/test-mountpoint-util.c @@ -276,6 +276,7 @@ TEST(path_is_mount_point) { } TEST(fd_is_mount_point) { + _cleanup_(rm_rf_physical_and_freep) char *tmpdir = NULL; _cleanup_close_ int fd = -EBADF; int r; @@ -298,11 +299,13 @@ TEST(fd_is_mount_point) { assert_se(fd_is_mount_point(fd, "proc", 0) > 0); assert_se(fd_is_mount_point(fd, "proc/", 0) > 0); - /* /root's entire reason for being is to be on the root file system (i.e. not in /home/ which - * might be split off), so that the user can always log in, so it cannot be a mount point unless - * the system is borked. Let's allow for it to be missing though. */ - assert_se(IN_SET(fd_is_mount_point(fd, "root", 0), -ENOENT, 0)); - assert_se(IN_SET(fd_is_mount_point(fd, "root/", 0), -ENOENT, 0)); + safe_close(fd); + fd = open("/tmp", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY); + assert_se(fd >= 0); + + assert_se(mkdtemp_malloc("/tmp/not-mounted-XXXXXX", &tmpdir) >= 0); + assert_se(fd_is_mount_point(fd, basename(tmpdir), 0) == 0); + assert_se(fd_is_mount_point(fd, strjoina(basename(tmpdir), "/"), 0) == 0); safe_close(fd); fd = open("/proc", O_RDONLY|O_CLOEXEC|O_DIRECTORY|O_NOCTTY);