[PATCH] selftests/pidfd: skip setns tests without namespace ioctls

From: linfordWu

Date: Thu Oct 29 2026 - 10:12:16 EST


Kernels without the pidfd namespace ioctls return ENOTTY. The
current_nsset fixture expects only EOPNOTSUPP and reports a failure for
every namespace before running the tests.

Skip the fixture when ENOTTY is returned so unsupported kernels report
skipped tests instead of failures.

Signed-off-by: linfordWu <linfordwu@xxxxxxx>
---
tools/testing/selftests/pidfd/pidfd_setns_test.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/tools/testing/selftests/pidfd/pidfd_setns_test.c b/tools/testing/selftests/pidfd/pidfd_setns_test.c
index 107edecff..8856e3e19 100644
--- a/tools/testing/selftests/pidfd/pidfd_setns_test.c
+++ b/tools/testing/selftests/pidfd/pidfd_setns_test.c
@@ -126,6 +126,9 @@ FIXTURE_SETUP(current_nsset)

self->child_pidfd_derived_nsfds[i] = ioctl(self->pidfd, info->pidfd_ioctl, 0);
if (self->child_pidfd_derived_nsfds[i] < 0) {
+ if (errno == ENOTTY)
+ SKIP(return,
+ "Kernel does not support deriving namespaces from pidfds");
EXPECT_EQ(errno, EOPNOTSUPP) {
TH_LOG("%m - Failed to derive %s namespace from pidfd of process %d",
info->name, self->pid);
--
2.43.0