diff options
author | Xi Ruoyao <xry111@xry111.site> | 2024-03-28 04:01:02 +0800 |
---|---|---|
committer | Xi Ruoyao <xry111@xry111.site> | 2024-04-03 17:28:37 +0800 |
commit | 04db2ba9008e9635286b1aafc8ecd9533a0a91bf (patch) | |
tree | 6eee23d6f3598483a04be2d581b0e326d5962db7 | |
parent | b1a48efd173c7f37d8df39a84eb25b4440335661 (diff) | |
download | util-linux-04db2ba9008e9635286b1aafc8ecd9533a0a91bf.tar.gz |
lsfd: test: Adapt test cases for pidfs
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>
-rw-r--r-- | tests/expected/lsfd/column-name-pidfd | 2 | ||||
-rw-r--r-- | tests/expected/lsfd/column-type-pidfd | 2 | ||||
-rw-r--r-- | tests/expected/lsfd/mkfds-pidfd | 2 | ||||
-rwxr-xr-x | tests/ts/lsfd/column-ainodeclass | 8 | ||||
-rwxr-xr-x | tests/ts/lsfd/column-name | 7 | ||||
-rwxr-xr-x | tests/ts/lsfd/column-type | 7 | ||||
-rwxr-xr-x | tests/ts/lsfd/mkfds-pidfd | 4 |
7 files changed, 29 insertions, 3 deletions
diff --git a/tests/expected/lsfd/column-name-pidfd b/tests/expected/lsfd/column-name-pidfd index 10e3c5e7f5..68787d69fc 100644 --- a/tests/expected/lsfd/column-name-pidfd +++ b/tests/expected/lsfd/column-name-pidfd @@ -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 diff --git a/tests/expected/lsfd/column-type-pidfd b/tests/expected/lsfd/column-type-pidfd index 6c9a9632ea..a4379807d4 100644 --- a/tests/expected/lsfd/column-type-pidfd +++ b/tests/expected/lsfd/column-type-pidfd @@ -1,2 +1,2 @@ -3 UNKN pidfd +3 [STTYPE] pidfd pidfd:ASSOC,STTYPE,TYPE: 0 diff --git a/tests/expected/lsfd/mkfds-pidfd b/tests/expected/lsfd/mkfds-pidfd index 9484699204..bce4dd42a2 100644 --- a/tests/expected/lsfd/mkfds-pidfd +++ b/tests/expected/lsfd/mkfds-pidfd @@ -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 diff --git a/tests/ts/lsfd/column-ainodeclass b/tests/ts/lsfd/column-ainodeclass index 6829494f0e..ab2abebd6a 100755 --- a/tests/ts/lsfd/column-ainodeclass +++ b/tests/ts/lsfd/column-ainodeclass @@ -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 diff --git a/tests/ts/lsfd/column-name b/tests/ts/lsfd/column-name index 8bf8f42178..9c67de8893 100755 --- a/tests/ts/lsfd/column-name +++ b/tests/ts/lsfd/column-name @@ -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 diff --git a/tests/ts/lsfd/column-type b/tests/ts/lsfd/column-type index 77bc5c9400..1b8aa8c6fc 100755 --- a/tests/ts/lsfd/column-type +++ b/tests/ts/lsfd/column-type @@ -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 diff --git a/tests/ts/lsfd/mkfds-pidfd b/tests/ts/lsfd/mkfds-pidfd index c0fae4f70a..9b0ff33c60 100755 --- a/tests/ts/lsfd/mkfds-pidfd +++ b/tests/ts/lsfd/mkfds-pidfd @@ -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 |