]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (refactor (test_mkfds, lsfd)) use TS_EXIT_NOTSUPP instead of EXIT_ENOSYS
authorMasatake YAMATO <yamato@redhat.com>
Mon, 22 Jan 2024 10:15:00 +0000 (19:15 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Mon, 22 Jan 2024 12:21:44 +0000 (21:21 +0900)
Suggested by Thomas Weißschuh in #2722.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
tests/helpers/test_mkfds.c
tests/ts/lsfd/column-ainodeclass
tests/ts/lsfd/column-name
tests/ts/lsfd/column-type
tests/ts/lsfd/lsfd-functions.bash
tests/ts/lsfd/mkfds-bpf-map
tests/ts/lsfd/mkfds-bpf-prog
tests/ts/lsfd/mkfds-netns
tests/ts/lsfd/mkfds-pidfd

index deaa759e920343cc5689f4664c79854418b4e5af..78360f7fa593409971c9cbd2db50693cbe15a025 100644 (file)
@@ -20,6 +20,7 @@
 #include "c.h"
 #include "xalloc.h"
 #include "test_mkfds.h"
+#include "exitcodes.h"
 
 #include <arpa/inet.h>
 #include <ctype.h>
@@ -64,7 +65,6 @@
 #include <time.h>
 #include <unistd.h>
 
-#define EXIT_ENOSYS 17
 #define EXIT_EPERM  18
 #define EXIT_ENOPROTOOPT 19
 #define EXIT_EPROTONOSUPPORT 20
@@ -1171,8 +1171,7 @@ static void *make_pidfd(const struct factory *factory, struct fdesc fdescs[],
 
        int fd = pidfd_open(pid, 0);
        if (fd < 0)
-               err((errno == ENOSYS? EXIT_ENOSYS: EXIT_FAILURE),
-                   "failed in pidfd_open(%d)", (int)pid);
+               err_nosys(EXIT_FAILURE, "failed in pidfd_open(%d)", (int)pid);
        free_arg(&target_pid);
 
        if (fd != fdescs[0].fd) {
@@ -2235,8 +2234,7 @@ static void *make_netns(const struct factory *factory _U_, struct fdesc fdescs[]
 
        int ns = ioctl(sd, SIOCGSKNS);
        if (ns < 0)
-               err((errno == ENOSYS? EXIT_ENOSYS: EXIT_FAILURE),
-                   "failed in ioctl(SIOCGSKNS)");
+               err_nosys(EXIT_FAILURE, "failed in ioctl(SIOCGSKNS)");
        close(sd);
 
        if (ns != fdescs[0].fd) {
@@ -2942,8 +2940,7 @@ static void *make_bpf_prog(const struct factory *factory, struct fdesc fdescs[],
 
        bfd = syscall(SYS_bpf, BPF_PROG_LOAD, &attr, sizeof(attr));
        if (bfd < 0)
-               err((errno == ENOSYS? EXIT_ENOSYS: EXIT_FAILURE),
-                   "failed in bpf(BPF_PROG_LOAD)");
+               err_nosys(EXIT_FAILURE, "failed in bpf(BPF_PROG_LOAD)");
 
        if (bfd != fdescs[0].fd) {
                if (dup2(bfd, fdescs[0].fd) < 0) {
@@ -3044,8 +3041,7 @@ static void *make_bpf_map(const struct factory *factory, struct fdesc fdescs[],
 
        bfd = syscall(SYS_bpf, BPF_MAP_CREATE, &attr, sizeof(attr));
        if (bfd < 0)
-               err((errno == ENOSYS? EXIT_ENOSYS: EXIT_FAILURE),
-                   "failed in bpf(BPF_MAP_CREATE)");
+               err_nosys(EXIT_FAILURE, "failed in bpf(BPF_MAP_CREATE)");
 
        if (bfd != fdescs[0].fd) {
                if (dup2(bfd, fdescs[0].fd) < 0) {
index 3a10026c214e68545fde16110ef18941ad2aea20..6829494f0e640fd0fcff1f21090b1b40f352b801 100755 (executable)
@@ -42,7 +42,7 @@ for C in pidfd inotify; do
        fi
        wait "${MKFDS_PID}"
     } > "$TS_OUTPUT" 2>&1
-    if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+    if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
        ts_skip_subtest "pidfd_open(2) is not available"
        continue
     fi
index a9d46879ad2b133a64b9ab2298dd2bc3c0dd8f4c..8bf8f42178ab3aa7f9cab4cfc0e85a0c96f90bb1 100755 (executable)
@@ -64,7 +64,7 @@ for C in ro-regular-file pidfd socketpair; do
        fi
     } > "$TS_OUTPUT" 2>&1
     wait "${MKFDS_PID}"
-    if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+    if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
        ts_skip_subtest "pidfd_open(2) is not available"
        continue
     fi
index 8ededd44f3a5743be692274d3ccb58dadc858b57..77bc5c940068995d494ee760ecea50efa5e5f470 100755 (executable)
@@ -50,7 +50,7 @@ for C in ro-regular-file pidfd inotify socketpair; do
        fi
        wait "${MKFDS_PID}"
     } > "$TS_OUTPUT" 2>&1
-    if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+    if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
        ts_skip_subtest "pidfd_open(2) is not available"
        continue
     fi
index d9a35956d89da8cfe9e63d51de67c14579662aec..076ead29f34450bca59cead52fce0c39f7b7a83d 100644 (file)
@@ -16,7 +16,6 @@
 #
 
 # The exit-status used in a test target.
-readonly ENOSYS=17
 readonly EPERM=18
 readonly ENOPROTOOPT=19
 readonly EPROTONOSUPPORT=20
index 0782ef043585453e9d81203ae4cadac897ecf9a0..7821fe50625ba8e9eb69fc9688e9298008eee1f4 100755 (executable)
@@ -42,7 +42,7 @@ NAME=mkfds_map
     wait "${MKFDS_PID}"
 } > "$TS_OUTPUT" 2>&1
 
-if [ "$?" == "$ENOSYS" ]; then
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
     ts_skip "bpf(2) is not available"
 fi
 
index c26843fac0723bc0342ff7bf24843dd07b475298..b2a7275f66da0d89a6226a8fad5c851f8e487c4b 100755 (executable)
@@ -42,7 +42,7 @@ NAME=mkdfs_prog
     wait "${MKFDS_PID}"
 } > "$TS_OUTPUT" 2>&1
 
-if [ "$?" == "$ENOSYS" ]; then
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
     ts_skip "bpf(2) is not available"
 fi
 
index 3666879786322777f625c2aadb913e5d028aa1ad..df11c95f309eb03b05d36b5505df95e8a1b75b7e 100755 (executable)
@@ -65,7 +65,7 @@ INO_NS=
     fi
     wait "${MKFDS_PID}"
 } > "$TS_OUTPUT" 2>&1
-if [ "$?" == "$ENOSYS" ]; then
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
     ts_skip "ioctl(fd, SIOCGSKNS) is not available"
 fi
 
index b5eaef94e95058276dfee69814abb6986e9449a3..c0fae4f70a5d0b952b9cf275cbdf86ba08680aec 100755 (executable)
@@ -44,7 +44,7 @@ EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})"
     fi
     wait ${MKFDS_PID}
 } > $TS_OUTPUT 2>&1
-if [ "$?" == "$ENOSYS" ]; then
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
     ts_skip "pidfd_open(2) is not available"
 fi