]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: handle ENOSYS in multiplexing syscall tests
authorKarel Zak <kzak@redhat.com>
Tue, 16 Jun 2026 07:24:40 +0000 (09:24 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 16 Jun 2026 07:24:40 +0000 (09:24 +0200)
On ppc64le, __NR_select is defined at compile time, so test_mkfds -W
lists "select" as available. However, the kernel returns ENOSYS at
runtime. The helper process prints its PID, then calls select() which
fails immediately with ENOSYS. This creates a race where the bash
script's kill -0 liveness check can succeed while the process is
still dying, causing lsfd to run against a dead process and produce
wrong output.

Exit with EXIT_ENOSYS (23) instead of EXIT_FAILURE when the
multiplexer syscall returns ENOSYS. This applies to both
DEFUN_WAIT_EVENT_SELECT and DEFUN_WAIT_EVENT_POLL macros.

In the bash test, check the wait exit code for 23 after the coproc
finishes and skip the subtest cleanly.

Signed-off-by: Karel Zak <kzak@redhat.com>
tests/helpers/test_mkfds.c
tests/helpers/test_mkfds.h
tests/ts/lsfd/mkfds-multiplexing

index 746174e802fabd94b737a9ea5ab64ddb2b29594a..302c3d33c42cc401c9bcb8e59ded84d18ab487ad 100644 (file)
@@ -78,7 +78,7 @@
 #define EXIT_EPROTONOSUPPORT 20
 #define EXIT_EACCES 21
 #define EXIT_ENOENT 22
-#define EXIT_ENOSYS 23
+/* EXIT_ENOSYS also defined in test_mkfds.h */
 #define EXIT_EADDRNOTAVAIL 24
 #define EXIT_ENODEV 25
 
@@ -4551,8 +4551,11 @@ static void sighandler_nop(int si _U_)
                SETUP_SIG_HANDLER                                       \
                                                                        \
                if (SYSCALL_INVOCATION < 0                              \
-                   && errno != EINTR)                                  \
+                   && errno != EINTR) {                                \
+                       if (errno == ENOSYS)                            \
+                               errx(EXIT_ENOSYS, "no syscall: " SYSCALL); \
                        err(EXIT_FAILURE, "failed in " SYSCALL);        \
+               }                                                       \
        }
 
 DEFUN_WAIT_EVENT_SELECT(default,
index 1002ee19d3a480a21c350723da1fdef78e417a49..e7a1f06e55be15f364db803c35478c6b399bc490 100644 (file)
@@ -23,6 +23,8 @@
 #include <stdbool.h>
 #include <stddef.h>
 
+#define EXIT_ENOSYS 23
+
 enum multiplexing_mode {
    MX_READ   = 1 << 0,
    MX_WRITE  = 1 << 1,
@@ -72,8 +74,11 @@ struct fdesc {
                SETUP_SIG_HANDLER                                       \
                                                                        \
                if (SYSCALL_INVOCATION < 0                              \
-                   && errno != EINTR)                                  \
+                   && errno != EINTR) {                                \
+                       if (errno == ENOSYS)                            \
+                               errx(EXIT_ENOSYS, "no syscall: " SYSCALL); \
                        err(EXIT_FAILURE, "failed in " SYSCALL);        \
+               }                                                       \
                free(pfds);                                             \
        }
 
index fdb175f8a545a89ef27f561ec6bc16a6083f3934..79f4d55309c7d19e761b7f39cd3c9d5be28963ce 100755 (executable)
@@ -89,6 +89,9 @@ for multiplexer in pselect6 select poll ppoll; do
     fi
 
     wait "$MKFDS_CPID"
+    if [ $? -eq 23 ]; then
+       ts_skip "the $multiplexer syscall is not available (ENOSYS)"
+    fi
     ts_finalize_subtest
 done