From: "Ricardo B. Marlière" <rbm@suse.com>
To: Shuah Khan <shuah@kernel.org>, Christian Brauner <brauner@kernel.org>
Cc: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org,
"Ricardo B. Marliere" <rbm@suse.com>
Subject: [PATCH 3/3] selftests/namespaces: Skip efault tests when listns() is not available
Date: Tue, 07 Apr 2026 11:35:47 -0300 [thread overview]
Message-ID: <20260407-selftests-namespaces_fixes-v1-3-59109909d88b@suse.com> (raw)
In-Reply-To: <20260407-selftests-namespaces_fixes-v1-0-59109909d88b@suse.com>
When listns() is not implemented the iterator child detects ENOSYS and
exits cleanly with status PIDFD_SKIP before the parent has a chance to
signal it. The parent sends SIGKILL (which is a harmless no-op at that
point) and then calls waitpid(), obtaining a normal-exit status. The
subsequent ASSERT_TRUE(WIFSIGNALED(status)) therefore fails, causing the
three EFAULT-focused tests to report FAIL rather than SKIP on kernels that
do not yet carry listns() support.
After collecting the iterator's exit status, check whether it exited with
PIDFD_SKIP and issue a SKIP verdict in that case, consistent with the
behaviour of every other listns test that already handles ENOSYS correctly.
Signed-off-by: Ricardo B. Marlière <rbm@suse.com>
---
.../testing/selftests/namespaces/listns_efault_test.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/tools/testing/selftests/namespaces/listns_efault_test.c b/tools/testing/selftests/namespaces/listns_efault_test.c
index ac3b208264f5..c20c6a812217 100644
--- a/tools/testing/selftests/namespaces/listns_efault_test.c
+++ b/tools/testing/selftests/namespaces/listns_efault_test.c
@@ -177,6 +177,12 @@ TEST(listns_partial_fault_with_ns_cleanup)
ASSERT_EQ(ret, iter_pid);
close(iter_pidfd);
+ /* If listns() is not supported the iterator exits cleanly via ENOSYS */
+ if (WIFEXITED(status) && WEXITSTATUS(status) == PIDFD_SKIP) {
+ munmap(map, page_size);
+ SKIP(return, "listns() not supported");
+ }
+
/* Should have been killed */
ASSERT_TRUE(WIFSIGNALED(status));
ASSERT_EQ(WTERMSIG(status), SIGKILL);
@@ -387,6 +393,12 @@ TEST(listns_late_fault_with_ns_cleanup)
ASSERT_EQ(ret, iter_pid);
close(iter_pidfd);
+ /* If listns() is not supported the iterator exits cleanly via ENOSYS */
+ if (WIFEXITED(status) && WEXITSTATUS(status) == PIDFD_SKIP) {
+ munmap(map, page_size);
+ SKIP(return, "listns() not supported");
+ }
+
/* Should have been killed */
ASSERT_TRUE(WIFSIGNALED(status));
ASSERT_EQ(WTERMSIG(status), SIGKILL);
@@ -523,6 +535,12 @@ TEST(listns_mnt_ns_cleanup_on_fault)
ASSERT_EQ(ret, iter_pid);
close(iter_pidfd);
+ /* If listns() is not supported the iterator exits cleanly via ENOSYS */
+ if (WIFEXITED(status) && WEXITSTATUS(status) == PIDFD_SKIP) {
+ munmap(map, page_size);
+ SKIP(return, "listns() not supported");
+ }
+
/* Should have been killed */
ASSERT_TRUE(WIFSIGNALED(status));
ASSERT_EQ(WTERMSIG(status), SIGKILL);
--
2.53.0
next prev parent reply other threads:[~2026-04-07 14:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-07 14:35 [PATCH 0/3] selftests/namespaces: Fix test hangs and false failures Ricardo B. Marlière
2026-04-07 14:35 ` [PATCH 1/3] selftests/namespaces: Kill grandchild in nsid fixture teardown Ricardo B. Marlière
2026-04-07 14:35 ` [PATCH 2/3] selftests/namespaces: Fix waitpid race in listns_efault_test cleanup Ricardo B. Marlière
2026-04-07 14:35 ` Ricardo B. Marlière [this message]
2026-04-09 13:06 ` [PATCH 0/3] selftests/namespaces: Fix test hangs and false failures Christian Brauner
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260407-selftests-namespaces_fixes-v1-3-59109909d88b@suse.com \
--to=rbm@suse.com \
--cc=brauner@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=shuah@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®