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)")
Signed-off-by: Chhabilal Dangal <[email protected]>
---
 tools/testing/selftests/proc/setns-dcache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/proc/setns-dcache.c 
b/tools/testing/selftests/proc/setns-dcache.c
index 60ab197a7..f4e958068 100644
--- a/tools/testing/selftests/proc/setns-dcache.c
+++ b/tools/testing/selftests/proc/setns-dcache.c
@@ -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;
        }
 
-- 
2.55.0


Reply via email to