From: Masatake YAMATO Date: Mon, 6 Jan 2025 08:34:19 +0000 (+0900) Subject: tests: (lsns::filter) skip if /proc/self/uid_map is not writable X-Git-Tag: v2.42-start~103^2~2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=237f31e883445e6db91332612a102fc0aa19420d;p=thirdparty%2Futil-linux.git tests: (lsns::filter) skip if /proc/self/uid_map is not writable On some platforms, lsns::filter test failed with the following message: +test_mkfds: failed to write to /proc/self/uid_map: -1: Operation not permitted This change is to skip the test case on such platforms. Signed-off-by: Masatake YAMATO --- diff --git a/tests/helpers/test_mkfds.c b/tests/helpers/test_mkfds.c index dfb60ae8e..702f8328a 100644 --- a/tests/helpers/test_mkfds.c +++ b/tests/helpers/test_mkfds.c @@ -3091,7 +3091,7 @@ static void map_root_user(uid_t uid, uid_t gid) "failed to open /proc/self/uid_map"); r = write (mapfd, buf, n); if (r < 0) - err(EXIT_FAILURE, + err((errno == EPERM? EXIT_EPERM: EXIT_FAILURE), "failed to write to /proc/self/uid_map"); if (r != n) errx(EXIT_FAILURE, diff --git a/tests/ts/lsfd/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash index 1b2a0ac04..8bbe31ab1 100644 --- a/tests/ts/lsfd/lsfd-functions.bash +++ b/tests/ts/lsfd/lsfd-functions.bash @@ -149,3 +149,23 @@ function lsfd_check_vsock ts_failed "failed to use a AF_VSOCK socket: $msg [$err]";; esac } + +function lsfd_check_userns +{ + ts_check_test_command "$TS_HELPER_MKFDS" + + local msg + local err + + msg=$("$TS_HELPER_MKFDS" -c userns 3 2>&1) + err=$? + + case $err in + 0) + return;; + "$EPERM") + ts_skip "maybe /proc/self/uid_map it not writable";; + *) + ts_failed "failed to use a AF_VSOCK socket: $msg [$err]";; + esac +} diff --git a/tests/ts/lsns/filter b/tests/ts/lsns/filter index a6274b031..88029680c 100755 --- a/tests/ts/lsns/filter +++ b/tests/ts/lsns/filter @@ -31,6 +31,8 @@ ts_check_test_command "$TS_HELPER_MKFDS" # unshare(2) used in userns factory of test_mkfds reports "Invalid argument". ts_skip_qemu_user +lsfd_check_userns + ts_cd "$TS_OUTDIR" PID= FD=4