Fix: skip unavailable mount ID test

Signed-off-by: Jvle <keke.oerv@isrc.iscas.ac.cn>
This commit is contained in:
Jvle
2026-10-31 22:26:59 +08:00
parent 2738d96edd
commit bdaa57ed40
@@ -1,26 +1,12 @@
Subject: [PATCH] test: skip mount ID check without privilege
Subject: [PATCH] test: skip mount ID check in restricted chroot
Running test-mountpoint-util in a restricted chroot may deny access to mount
IDs. Skip the affected test in that environment while keeping it enabled
elsewhere.
Running test-mountpoint-util in a restricted chroot may make mount ID lookup
unavailable. Skip the affected test case entirely in this environment.
diff --git a/src/test/test-mountpoint-util.c b/src/test/test-mountpoint-util.c
--- a/src/test/test-mountpoint-util.c
+++ b/src/test/test-mountpoint-util.c
@@ -405 +405 @@
@@ -405 +405,2 @@
- int id1, id2;
+ int id1, id2, r;
@@ -407 +407,4 @@
- assert_se(path_get_mnt_id_at(AT_FDCWD, "/run/", &id1) >= 0);
+ r = path_get_mnt_id_at(AT_FDCWD, "/run/", &id1);
+ if (ERRNO_IS_PRIVILEGE(r))
+ return (void) log_tests_skipped_errno(r, "mount ID lookup for /run/ is not permitted");
+ assert_se(r >= 0);
@@ -410 +413,4 @@
- assert_se(path_get_mnt_id_at(AT_FDCWD, "/run", &id2) >= 0);
+ r = path_get_mnt_id_at(AT_FDCWD, "/run", &id2);
+ if (ERRNO_IS_PRIVILEGE(r))
+ return (void) log_tests_skipped_errno(r, "mount ID lookup for /run is not permitted");
+ assert_se(r >= 0);
assert_se(id1 == id2);
id2 = -1;
+ int id1, id2;
+ return (void) log_tests_skipped("mount ID lookup is unavailable in the restricted chroot");