]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lsfd: test: Adapt test cases for pidfs
authorXi Ruoyao <xry111@xry111.site>
Wed, 27 Mar 2024 20:01:02 +0000 (04:01 +0800)
committerXi Ruoyao <xry111@xry111.site>
Wed, 3 Apr 2024 09:28:37 +0000 (17:28 +0800)
On Linux >= 6.9, pidfds are from pidfs instead of anonymous inode.
Thus:

STTYPE is REG on Linux >= 6.9, UNKN on Linux < 6.9.

KNAME is pidfd:[inode number] on Linux >= 6.9, anon_inode:[pidfd] on
Linux < 6.9.

And ainode_class test cannot work on Linux >= 6.9, just skip this sub
test if STTYPE is REG.

Signed-off-by: Xi Ruoyao <xry111@xry111.site>
tests/expected/lsfd/column-name-pidfd
tests/expected/lsfd/column-type-pidfd
tests/expected/lsfd/mkfds-pidfd
tests/ts/lsfd/column-ainodeclass
tests/ts/lsfd/column-name
tests/ts/lsfd/column-type
tests/ts/lsfd/mkfds-pidfd

index 10e3c5e7f5343e971d5bb6e04d3d3ce58744200a..68787d69fc590da8279601b7fd4204a9701ec86c 100644 (file)
@@ -1,2 +1,2 @@
-3 anon_inode:[pidfd] pid=1 comm= nspid=1
+3 [KNAME] pid=1 comm= nspid=1
 pidfd:ASSOC,KNAME,NAME: 0
index 6c9a9632ea9637263b72fde8544f16647165ab1d..a4379807d461f3281aead0cb91d56767370b8ecf 100644 (file)
@@ -1,2 +1,2 @@
-3 UNKN pidfd
+3 [STTYPE] pidfd
 pidfd:ASSOC,STTYPE,TYPE: 0
index 9484699204d4dd7f153a1bec2c969a59d00668d4..bce4dd42a2c085de327f109edbef54c2fb32691a 100644 (file)
@@ -1,2 +1,2 @@
-3 UNKN anon_inodefs pid=1 comm=systemd nspid=1 systemd     1
+3 [STTYPE] [SOURCE] pid=1 comm=systemd nspid=1 systemd     1
 ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID: 0
index 6829494f0e640fd0fcff1f21090b1b40f352b801..ab2abebd6ade225765a264dce383e8e7487cb0ac 100755 (executable)
@@ -42,10 +42,18 @@ for C in pidfd inotify; do
        fi
        wait "${MKFDS_PID}"
     } > "$TS_OUTPUT" 2>&1
+
     if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
        ts_skip_subtest "pidfd_open(2) is not available"
        continue
     fi
+
+    STTYPE="$(head -n1 "$TS_OUTPUT" | awk '{print $2}')"
+    if [ "$C-$STTYPE" == "pidfd-REG" ]; then
+       ts_skip_subtest "pidfd is from pidfs instead of anon inode"
+       continue
+    fi
+
     ts_finalize_subtest
 done
 
index 8bf8f42178ab3aa7f9cab4cfc0e85a0c96f90bb1..9c67de889351003da127bfc14c09c0a5f66129a6 100755 (executable)
@@ -64,10 +64,17 @@ for C in ro-regular-file pidfd socketpair; do
        fi
     } > "$TS_OUTPUT" 2>&1
     wait "${MKFDS_PID}"
+
     if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
        ts_skip_subtest "pidfd_open(2) is not available"
        continue
     fi
+
+    case $C in
+    pidfd)
+       sed -i -E 's/(pidfd|anon_inode):\[[a-zA-Z]+\]/[KNAME]/' "$TS_OUTPUT"
+    esac
+
     ts_finalize_subtest
 done
 
index 77bc5c940068995d494ee760ecea50efa5e5f470..1b8aa8c6fc511a650aac1119f897e6084f17a967 100755 (executable)
@@ -50,10 +50,17 @@ for C in ro-regular-file pidfd inotify socketpair; do
        fi
        wait "${MKFDS_PID}"
     } > "$TS_OUTPUT" 2>&1
+
     if [ "$C-$?" == "pidfd-$TS_EXIT_NOTSUPP" ]; then
        ts_skip_subtest "pidfd_open(2) is not available"
        continue
     fi
+
+    case $C in
+    pidfd)
+       sed -i -E 's/UNKN|REG/[STTYPE]/' "$TS_OUTPUT"
+    esac
+
     ts_finalize_subtest
 done
 
index c0fae4f70a5d0b952b9cf275cbdf86ba08680aec..9b0ff33c60a709d3f989c1bf1539e6f1edd432f8 100755 (executable)
@@ -44,8 +44,12 @@ EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})"
     fi
     wait ${MKFDS_PID}
 } > $TS_OUTPUT 2>&1
+
 if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
     ts_skip "pidfd_open(2) is not available"
 fi
 
+sed -i -E -e 's/UNKN|REG/[STTYPE]/' -e 's/pidfs|anon_inodefs/[SOURCE]/' \
+    $TS_OUTPUT
+
 ts_finalize