From: Franck Bui Date: Thu, 10 Aug 2023 12:13:45 +0000 (+0200) Subject: test-mountpoint-util: /root might be mounted X-Git-Tag: v255-rc1~752 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=487ae08b85048f86e72e86d6c601d4c558b6cb8a;p=thirdparty%2Fsystemd.git test-mountpoint-util: /root might be mounted On openSUSE with BTRFS, /root has to be mounted as dedicated subvolume to avoid restoring it when a rollback of the system happens. --- diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c index 6b129c2eac8..ff447c65821 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);