Skip to contentSkip to conversation

selftests/proc: skip setns-dcache if CONFIG_UNIX is disabled

PATCH New Manish Baing 1 participant 1 message Aug 15

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

PATCH 1/1 selftests/proc: skip setns-dcache if CONFIG_UNIX is disabled

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.

---
 tools/testing/selftests/proc/setns-dcache.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
tools/testing/selftests/proc/setns-dcache.c +4 -1
index 60ab197a73fc..35665e7894b2 100644
@@ -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. */
Signature · 1 line
2.43.0