]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
tests: (lsfd) skip if the platform doesn't provide pidfd_open(2)
authorMasatake YAMATO <yamato@redhat.com>
Sat, 25 Feb 2023 15:58:47 +0000 (00:58 +0900)
committerMasatake YAMATO <yamato@redhat.com>
Sun, 26 Feb 2023 08:26:47 +0000 (17:26 +0900)
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
17 files changed:
tests/expected/lsfd/column-ainodeclass-inotify [moved from tests/expected/lsfd/column-ainodeclass with 50% similarity]
tests/expected/lsfd/column-ainodeclass-pidfd [new file with mode: 0644]
tests/expected/lsfd/column-name [deleted file]
tests/expected/lsfd/column-name-pidfd [new file with mode: 0644]
tests/expected/lsfd/column-name-ro-regular-file [new file with mode: 0644]
tests/expected/lsfd/column-name-socketpair [new file with mode: 0644]
tests/expected/lsfd/column-type [deleted file]
tests/expected/lsfd/column-type-inotify [new file with mode: 0644]
tests/expected/lsfd/column-type-pidfd [new file with mode: 0644]
tests/expected/lsfd/column-type-ro-regular-file [new file with mode: 0644]
tests/expected/lsfd/column-type-socketpair [new file with mode: 0644]
tests/helpers/test_mkfds.c
tests/ts/lsfd/column-ainodeclass
tests/ts/lsfd/column-name
tests/ts/lsfd/column-type
tests/ts/lsfd/mkfds-pidfd
tests/ts/lsfd/mkfds-unix-in-netns

similarity index 50%
rename from tests/expected/lsfd/column-ainodeclass
rename to tests/expected/lsfd/column-ainodeclass-inotify
index d3428760f55a964ab70421a242d5f49d8f4dde9c..f93e19e1f8f6af4f1e35c8841315a15f73504832 100644 (file)
@@ -1,4 +1,2 @@
-    3   UNKN       pidfd
-pidfd:ASSOC,STTYPE,AINODECLASS: 0
     3   UNKN     inotify
 inotify:ASSOC,STTYPE,AINODECLASS: 0
diff --git a/tests/expected/lsfd/column-ainodeclass-pidfd b/tests/expected/lsfd/column-ainodeclass-pidfd
new file mode 100644 (file)
index 0000000..269cea5
--- /dev/null
@@ -0,0 +1,2 @@
+    3   UNKN       pidfd
+pidfd:ASSOC,STTYPE,AINODECLASS: 0
diff --git a/tests/expected/lsfd/column-name b/tests/expected/lsfd/column-name
deleted file mode 100644 (file)
index c8364fb..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-    3 /etc/passwd /etc/passwd
-ro-regular-file:ASSOC,KNAME,NAME: 0
-    3 anon_inode:[pidfd] pid=1 comm= nspid=1
-pidfd:ASSOC,KNAME,NAME: 0
-    3 socket:[INODENUM] state=connected type=dgram
-socketpair:ASSOC,KNAME,NAME: 0
diff --git a/tests/expected/lsfd/column-name-pidfd b/tests/expected/lsfd/column-name-pidfd
new file mode 100644 (file)
index 0000000..49abe81
--- /dev/null
@@ -0,0 +1,2 @@
+    3 anon_inode:[pidfd] pid=1 comm= nspid=1
+pidfd:ASSOC,KNAME,NAME: 0
diff --git a/tests/expected/lsfd/column-name-ro-regular-file b/tests/expected/lsfd/column-name-ro-regular-file
new file mode 100644 (file)
index 0000000..446a916
--- /dev/null
@@ -0,0 +1,2 @@
+    3 /etc/passwd /etc/passwd
+ro-regular-file:ASSOC,KNAME,NAME: 0
diff --git a/tests/expected/lsfd/column-name-socketpair b/tests/expected/lsfd/column-name-socketpair
new file mode 100644 (file)
index 0000000..bd94e56
--- /dev/null
@@ -0,0 +1,2 @@
+    3 socket:[INODENUM] state=connected type=dgram
+socketpair:ASSOC,KNAME,NAME: 0
diff --git a/tests/expected/lsfd/column-type b/tests/expected/lsfd/column-type
deleted file mode 100644 (file)
index 39684fa..0000000
+++ /dev/null
@@ -1,8 +0,0 @@
-    3    REG  REG
-ro-regular-file:ASSOC,STTYPE,TYPE: 0
-    3   UNKN pidfd
-pidfd:ASSOC,STTYPE,TYPE: 0
-    3   UNKN inotify
-inotify:ASSOC,STTYPE,TYPE: 0
-    3   SOCK UNIX
-socketpair:ASSOC,STTYPE,TYPE: 0
diff --git a/tests/expected/lsfd/column-type-inotify b/tests/expected/lsfd/column-type-inotify
new file mode 100644 (file)
index 0000000..69588d9
--- /dev/null
@@ -0,0 +1,2 @@
+    3   UNKN inotify
+inotify:ASSOC,STTYPE,TYPE: 0
diff --git a/tests/expected/lsfd/column-type-pidfd b/tests/expected/lsfd/column-type-pidfd
new file mode 100644 (file)
index 0000000..a3278d2
--- /dev/null
@@ -0,0 +1,2 @@
+    3   UNKN pidfd
+pidfd:ASSOC,STTYPE,TYPE: 0
diff --git a/tests/expected/lsfd/column-type-ro-regular-file b/tests/expected/lsfd/column-type-ro-regular-file
new file mode 100644 (file)
index 0000000..63b4356
--- /dev/null
@@ -0,0 +1,2 @@
+    3    REG  REG
+ro-regular-file:ASSOC,STTYPE,TYPE: 0
diff --git a/tests/expected/lsfd/column-type-socketpair b/tests/expected/lsfd/column-type-socketpair
new file mode 100644 (file)
index 0000000..22a61b7
--- /dev/null
@@ -0,0 +1,2 @@
+    3   SOCK UNIX
+socketpair:ASSOC,STTYPE,TYPE: 0
index e629c17d5f868bd7ac69f651731e15992b680bcd..6903b9e7254bb8ccfe1e828c6265cc658a449728 100644 (file)
@@ -739,7 +739,8 @@ static void *make_pidfd(const struct factory *factory, struct fdesc fdescs[],
 
        int fd = pidfd_open(pid, 0);
        if (fd < 0)
-               err(EXIT_FAILURE, "failed in pidfd_open(%d)", (int)pid);
+               err((errno == ENOSYS? EXIT_ENOSYS: EXIT_FAILURE),
+                   "failed in pidfd_open(%d)", (int)pid);
        free_arg(&target_pid);
 
        if (fd != fdescs[0].fd) {
index 54d6fd4355e571c1737e4090028cb1b74c0b9014..6391c48165f9e246e31cd22df830ab986ac773ff 100755 (executable)
@@ -20,9 +20,9 @@ TS_DESC="ainodeclass column"
 . "$TS_TOPDIR"/functions.sh
 ts_init "$*"
 
+. "$TS_SELF/lsfd-functions.bash"
 ts_check_test_command "$TS_CMD_LSFD"
 ts_check_test_command "$TS_HELPER_MKFDS"
-ts_skip_qemu_user
 
 ts_cd "$TS_OUTDIR"
 
@@ -30,8 +30,9 @@ PID=
 FD=3
 EXPR="(FD == 3)"
 
-{
-    for C in pidfd inotify; do
+for C in pidfd inotify; do
+    ts_init_subtest $C
+    {
        coproc MKFDS { "$TS_HELPER_MKFDS" $C $FD ; }
        if read -r -u "${MKFDS[0]}" PID; then
            ${TS_CMD_LSFD} -n -o ASSOC,STTYPE,AINODECLASS -p "${PID}" -Q "${EXPR}"
@@ -40,7 +41,12 @@ EXPR="(FD == 3)"
            kill -CONT "${PID}"
        fi
        wait "${MKFDS_PID}"
-    done
-} > "$TS_OUTPUT" 2>&1
+    } > "$TS_OUTPUT" 2>&1
+    if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+       ts_skip_subtest "pidfd_open(2) is not available"
+       continue
+    fi
+    ts_finalize_subtest
+done
 
 ts_finalize
index fcff5e806851659a2011d3f201d4642d534afeef..41015009df9209e54bdd47ca2ba841a1f1429464 100755 (executable)
@@ -20,10 +20,10 @@ TS_DESC="NAME and KNAME column"
 . "$TS_TOPDIR"/functions.sh
 ts_init "$*"
 
+. "$TS_SELF/lsfd-functions.bash"
 ts_check_test_command "$TS_CMD_LSFD"
 ts_check_test_command "$TS_HELPER_MKFDS"
 ts_check_prog "sed"
-ts_skip_qemu_user
 
 ts_cd "$TS_OUTDIR"
 
@@ -31,8 +31,9 @@ PID=
 FD=3
 EXPR="(FD == 3)"
 
-{
-    for C in ro-regular-file pidfd socketpair; do
+for C in ro-regular-file pidfd socketpair; do
+    ts_init_subtest $C
+    {
        coproc MKFDS {
            argv=()
            case $C in
@@ -52,8 +53,13 @@ EXPR="(FD == 3)"
 
            kill -CONT "${PID}"
        fi
-       wait "${MKFDS_PID}"
-    done
-} > "$TS_OUTPUT" 2>&1
+    } > "$TS_OUTPUT" 2>&1
+    wait "${MKFDS_PID}"
+    if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+       ts_skip_subtest "pidfd_open(2) is not available"
+       contiue
+    fi
+    ts_finalize_subtest
+done
 
 ts_finalize
index c875defa0e3c2563771c1bed97eb740fd4efe50a..cf6175efaa41c40193e2da7d06c50b3b658b1ec8 100755 (executable)
@@ -20,9 +20,9 @@ TS_DESC="TYPE and STTYPE column"
 . "$TS_TOPDIR"/functions.sh
 ts_init "$*"
 
+. "$TS_SELF/lsfd-functions.bash"
 ts_check_test_command "$TS_CMD_LSFD"
 ts_check_test_command "$TS_HELPER_MKFDS"
-ts_skip_qemu_user
 
 ts_cd "$TS_OUTDIR"
 
@@ -30,8 +30,9 @@ PID=
 FD=3
 EXPR="(FD == 3)"
 
-{
-    for C in ro-regular-file pidfd inotify socketpair; do
+for C in ro-regular-file pidfd inotify socketpair; do
+    ts_init_subtest $C
+    {
        coproc MKFDS {
            argv=()
            case $C in
@@ -48,7 +49,12 @@ EXPR="(FD == 3)"
            kill -CONT "${PID}"
        fi
        wait "${MKFDS_PID}"
-    done
-} > "$TS_OUTPUT" 2>&1
+    } > "$TS_OUTPUT" 2>&1
+    if [ "$C-$?" == "pidfd-$ENOSYS" ]; then
+       ts_skip_subtest "pidfd_open(2) is not available"
+       continue
+    fi
+    ts_finalize_subtest
+done
 
 ts_finalize
index ae4f65c83b3f6407a9cff0affeb2cc6f5a57dd1c..aad693ff117dcdbdadcdd3c2533164c637a59492 100755 (executable)
@@ -20,6 +20,7 @@ TS_DESC="pidfd"
 . "$TS_TOPDIR"/functions.sh
 ts_init "$*"
 
+. "$TS_SELF/lsfd-functions.bash"
 ts_check_test_command "$TS_CMD_LSFD"
 ts_check_test_command "$TS_HELPER_MKFDS"
 ts_check_prog "ps"
@@ -43,5 +44,8 @@ EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})"
     fi
     wait ${MKFDS_PID}
 } > $TS_OUTPUT 2>&1
+if [ "$?" == "$ENOSYS" ]; then
+    ts_skip "pidfd_open(2) is not available"
+fi
 
 ts_finalize
index 234208909c1c8cc0e092a300c79260baf003152c..f39406e2c0ed603850d037859584191d3e5da72c 100755 (executable)
@@ -20,7 +20,6 @@ TS_DESC="UNIX sockets made in a differenct net namespace"
 . "$TS_TOPDIR"/functions.sh
 ts_init "$*"
 ts_skip_nonroot
-ts_skip_qemu_user
 
 ts_check_test_command "$TS_CMD_LSFD"