The setns-dcache test looks for /proc/net/unix, which doesn't exist
if CONFIG_UNIX is disabled in the kernel, causing the test to fail.

Fixed this by checking if the file exists right at the start of the
test. If it's missing, skip the test cleanly. This also removes
the old FIXME note.

Signed-off-by: Manish Baing <[email protected]>
---
 tools/testing/selftests/proc/setns-dcache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/proc/setns-dcache.c 
b/tools/testing/selftests/proc/setns-dcache.c
index 60ab197a73fc..35665e7894b2 100644
--- a/tools/testing/selftests/proc/setns-dcache.c
+++ b/tools/testing/selftests/proc/setns-dcache.c
@@ -17,7 +17,6 @@
  * 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.
  */
 #undef NDEBUG
 #include <assert.h>
@@ -32,6 +31,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <sys/socket.h>
+#include "kselftest.h"
 
 static pid_t pid = -1;
 
@@ -48,6 +48,9 @@ int main(void)
        char _ = 0;
        int nsfd;
 
+       if (access("/proc/net/unix", F_OK) != 0)
+               ksft_exit_skip("CONFIG_UNIX is disabled or /proc/net/unix is 
missing\n");
+
        atexit(f);
 
        /* Check for priviledges and syscall availability straight away. */
-- 
2.43.0


Reply via email to