From: Nick Rosbrook Date: Fri, 21 Nov 2025 17:49:37 +0000 (-0500) Subject: test: skip test-reread-partition-table if missing privileges X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7d23e27e4c96d47187986a6b21cb2710485b71db;p=thirdparty%2Fsystemd.git test: skip test-reread-partition-table if missing privileges Right now, this test runs inside unprivileged chroots, despite the running_in_chroot() check. This is because running_in_chroot() fails with -EACCES, which is ignored. Hence, check for privileges before calling running_in_chroot(), otherwise call is inconclusive. Note, the test will fail later on if running without privileges anyways. --- diff --git a/src/test/test-reread-partition-table.c b/src/test/test-reread-partition-table.c index cff31f41a1e..769d2a8d2f9 100644 --- a/src/test/test-reread-partition-table.c +++ b/src/test/test-reread-partition-table.c @@ -4,6 +4,7 @@ #include #include "blockdev-util.h" +#include "capability-util.h" #include "fd-util.h" #include "loop-util.h" #include "memfd-util.h" @@ -45,6 +46,8 @@ TEST(rereadpt) { if (detect_container() > 0) return (void) log_tests_skipped("test not available in container"); + if (geteuid() != 0 || have_effective_cap(CAP_SYS_ADMIN) <= 0) + return (void) log_tests_skipped("test requires privileges"); if (running_in_chroot() > 0) return (void) log_tests_skipped("test not available in chroot()");