Skip to contentSkip to conversation

selftests/proc: Skip setns-dcache without UNIX sockets

PATCH New Chhabilal Dangal 1 participant 1 message Sep 14

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/proc: Skip setns-dcache without UNIX sockets

setns-dcache uses an AF_UNIX socket to distinguish network namespaces. When CONFIG_UNIX is disabled, socket(AF_UNIX, ...) returns -EAFNOSUPPORT, but the test reports the unsupported configuration as a failure.

Treat EAFNOSUPPORT as a skip instead.

The change was verified with CONFIG_UNIX=n under QEMU, where the test now exits with KSFT_SKIP, and with CONFIG_UNIX=y on the host, where the test continues to pass.

Fixes 1fde6f21d90f ("proc: fix /proc/net/* after setns(2)")
---
 tools/testing/selftests/proc/setns-dcache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/setns-dcache.c +3 -1
index 60ab197a7..f4e958068 100644
@@ -17,7 +17,7 @@
  * Test that setns(CLONE_NEWNET) points to new /proc/net content even
  * if old one is in dcache.
  *
- * FIXME /proc/net/unix is under CONFIG_UNIX which can be disabled.
+ * Skip if CONFIG_UNIX is disabled.
  */
 #undef NDEBUG
 #include <assert.h>
@@ -59,6 +59,8 @@ int main(void)
 	}
 	/* Distinguisher between two otherwise empty net namespaces. */
 	if (socket(AF_UNIX, SOCK_STREAM, 0) == -1) {
+		if (errno == EAFNOSUPPORT)
+			return 4;
 		return 1;
 	}
 
Signature · 1 line
2.55.0