summaryrefslogtreecommitdiffstats
path: root/tests/ts/lsfd
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-14 19:33:32 +0000
commit8bb05ac73a5b448b339ce0bc8d396c82c459b47f (patch)
tree1fdda006866bca20d41cb206767ea5241e36852f /tests/ts/lsfd
parentAdding debian version 2.39.3-11. (diff)
downloadutil-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.tar.xz
util-linux-8bb05ac73a5b448b339ce0bc8d396c82c459b47f.zip
Merging upstream version 2.40.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'tests/ts/lsfd')
-rwxr-xr-xtests/ts/lsfd/column-ainodeclass4
-rwxr-xr-xtests/ts/lsfd/column-deleted61
-rwxr-xr-xtests/ts/lsfd/column-kthread2
-rwxr-xr-xtests/ts/lsfd/column-name20
-rwxr-xr-xtests/ts/lsfd/column-source51
-rwxr-xr-xtests/ts/lsfd/column-source-with-root44
-rwxr-xr-xtests/ts/lsfd/column-type4
-rwxr-xr-xtests/ts/lsfd/column-xmode202
-rwxr-xr-xtests/ts/lsfd/filter-broken-exp (renamed from tests/ts/lsfd/option-filter-broken-exp)5
-rwxr-xr-xtests/ts/lsfd/filter-floating-point-nums90
-rw-r--r--tests/ts/lsfd/lsfd-functions.bash44
-rwxr-xr-xtests/ts/lsfd/mkfds-bpf-map49
-rwxr-xr-xtests/ts/lsfd/mkfds-bpf-prog49
-rwxr-xr-xtests/ts/lsfd/mkfds-cdev-tun65
-rwxr-xr-xtests/ts/lsfd/mkfds-directory2
-rwxr-xr-xtests/ts/lsfd/mkfds-eventfd104
-rwxr-xr-xtests/ts/lsfd/mkfds-eventpoll46
-rwxr-xr-xtests/ts/lsfd/mkfds-inotify74
-rwxr-xr-xtests/ts/lsfd/mkfds-inotify-btrfs91
-rwxr-xr-xtests/ts/lsfd/mkfds-mapped-packet-socket2
-rwxr-xr-xtests/ts/lsfd/mkfds-mqueue83
-rwxr-xr-xtests/ts/lsfd/mkfds-multiplexing70
-rwxr-xr-xtests/ts/lsfd/mkfds-netlink-groups2
-rwxr-xr-xtests/ts/lsfd/mkfds-netlink-protocol2
-rwxr-xr-xtests/ts/lsfd/mkfds-netns5
-rwxr-xr-xtests/ts/lsfd/mkfds-pidfd4
-rwxr-xr-xtests/ts/lsfd/mkfds-ping6
-rwxr-xr-xtests/ts/lsfd/mkfds-pipe-no-fork2
-rwxr-xr-xtests/ts/lsfd/mkfds-pty73
-rwxr-xr-xtests/ts/lsfd/mkfds-raw2
-rwxr-xr-xtests/ts/lsfd/mkfds-raw62
-rwxr-xr-xtests/ts/lsfd/mkfds-ro-block-device2
-rwxr-xr-xtests/ts/lsfd/mkfds-ro-regular-file2
-rwxr-xr-xtests/ts/lsfd/mkfds-rw-character-device2
-rwxr-xr-xtests/ts/lsfd/mkfds-signalfd64
-rwxr-xr-xtests/ts/lsfd/mkfds-socketpair95
-rwxr-xr-xtests/ts/lsfd/mkfds-symlink2
-rwxr-xr-xtests/ts/lsfd/mkfds-tcp6
-rwxr-xr-xtests/ts/lsfd/mkfds-tcp66
-rwxr-xr-xtests/ts/lsfd/mkfds-timerfd109
-rwxr-xr-xtests/ts/lsfd/mkfds-timerfd-alarm56
-rwxr-xr-xtests/ts/lsfd/mkfds-udp24
-rwxr-xr-xtests/ts/lsfd/mkfds-udp624
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-dgram8
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-in-netns4
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-stream8
-rwxr-xr-xtests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag58
-rwxr-xr-xtests/ts/lsfd/option-inet70
-rwxr-xr-xtests/ts/lsfd/option-pid2
-rwxr-xr-xtests/ts/lsfd/option-summary4
50 files changed, 1709 insertions, 97 deletions
diff --git a/tests/ts/lsfd/column-ainodeclass b/tests/ts/lsfd/column-ainodeclass
index 6391c48..6829494 100755
--- a/tests/ts/lsfd/column-ainodeclass
+++ b/tests/ts/lsfd/column-ainodeclass
@@ -38,11 +38,11 @@ for C in pidfd inotify; do
${TS_CMD_LSFD} -n -o ASSOC,STTYPE,AINODECLASS -p "${PID}" -Q "${EXPR}"
echo "$C"':ASSOC,STTYPE,AINODECLASS': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
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
diff --git a/tests/ts/lsfd/column-deleted b/tests/ts/lsfd/column-deleted
new file mode 100755
index 0000000..128cd0e
--- /dev/null
+++ b/tests/ts/lsfd/column-deleted
@@ -0,0 +1,61 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="DELETED column"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR=
+
+C=make-regular-file
+ts_init_subtest $C
+{
+ target=util-linux-lsfd-test-make-regular-file
+ coproc MKFDS { "$TS_HELPER_MKFDS" "$C" "$FD" file="$target" delete=1; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "$PID" -n -o DELETED -Q "${EXPR}"
+ echo "$C: DELETED: " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+C=ro-regular-file
+ts_init_subtest $C
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" "$C" "$FD"; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "$PID" -n -o DELETED -Q "${EXPR}"
+ echo "$C: DELETED: " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/column-kthread b/tests/ts/lsfd/column-kthread
index 0b093e9..2238ade 100755
--- a/tests/ts/lsfd/column-kthread
+++ b/tests/ts/lsfd/column-kthread
@@ -31,7 +31,7 @@ ts_check_prog "ps"
ts_cd "$TS_OUTDIR"
{
- "$TS_CMD_LSFD" -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \
+ "$TS_CMD_LSFD" --threads -o COMMAND,PID,USER,MODE,TYPE,NAME,KTHREAD \
-Q '(PID < 3) and ((ASSOC == "cwd") or (ASSOC == "rtd"))'
echo $?
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/column-name b/tests/ts/lsfd/column-name
index 5dc491a..8bf8f42 100755
--- a/tests/ts/lsfd/column-name
+++ b/tests/ts/lsfd/column-name
@@ -60,15 +60,31 @@ for C in ro-regular-file pidfd socketpair; do
}
echo "$C"':ASSOC,KNAME,NAME': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
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
ts_finalize_subtest
done
+C=make-regular-file
+ts_init_subtest deleted-file
+{
+ target=tmp-column-name
+ coproc MKFDS { "$TS_HELPER_MKFDS" $C $FD file=tmp-column-name delete=1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ ${TS_CMD_LSFD} -n -o DELETED,NAME -p "${PID}" -Q "${EXPR}" |
+ sed -e 's#.*/\([^/]\+\)#\1#'
+ echo "$C: DELETED,NAME: " ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
ts_finalize
diff --git a/tests/ts/lsfd/column-source b/tests/ts/lsfd/column-source
new file mode 100755
index 0000000..a74f9de
--- /dev/null
+++ b/tests/ts/lsfd/column-source
@@ -0,0 +1,51 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="SOURCE column"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+
+ts_cd "$TS_OUTDIR"
+
+declare -a NAMESPACES=(
+ cgorup
+ ipc
+ mnt
+ net
+ pid
+ pid4c
+ # older kernel doesn't support time namespace.
+ # time
+ # time4c
+ user
+ uts
+)
+ts_init_subtest namespace-ASSOC
+{
+ EXPR="false"
+ for ns in "${NAMESPACES[@]}"; do
+ EXPR=${EXPR}' || (ASSOC == "'"$ns"'")'
+ done
+ ${TS_CMD_LSFD} -p $$ -n -o ASSOC,SOURCE -Q "$EXPR"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/column-source-with-root b/tests/ts/lsfd/column-source-with-root
new file mode 100755
index 0000000..c00ee15
--- /dev/null
+++ b/tests/ts/lsfd/column-source-with-root
@@ -0,0 +1,44 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="SOURCE column (requiring the root privilege)"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+EXPR='(NAME =~ "/SYSV.*")'
+ts_init_subtest SysVIPC-shmem
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" sysvshm; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "$PID" -n -o ASSOC,SOURCE -Q "${EXPR}"
+ echo 'ASSOC,SOURCE': $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/column-type b/tests/ts/lsfd/column-type
index cf6175e..77bc5c9 100755
--- a/tests/ts/lsfd/column-type
+++ b/tests/ts/lsfd/column-type
@@ -46,11 +46,11 @@ for C in ro-regular-file pidfd inotify socketpair; do
${TS_CMD_LSFD} -n -o ASSOC,STTYPE,TYPE -p "${PID}" -Q "${EXPR}"
echo "$C"':ASSOC,STTYPE,TYPE': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
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
diff --git a/tests/ts/lsfd/column-xmode b/tests/ts/lsfd/column-xmode
new file mode 100755
index 0000000..1e719a4
--- /dev/null
+++ b/tests/ts/lsfd/column-xmode
@@ -0,0 +1,202 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="MODE and XMODE columns"
+
+. "$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 "stat"
+
+ts_cd "$TS_OUTDIR"
+
+INO=$(stat -c '%i' "$TS_HELPER_MKFDS")
+PID=
+FD=3
+
+
+EXPR="(FD == 3)"
+ts_init_subtest "MODE-r-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
+ echo "MODE(r-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_init_subtest "XMODE-r-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(r-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+EXPR="(FD == $((FD + 1)))"
+ts_init_subtest "MODE-w-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD $((FD + 1)); }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
+ echo "MODE(w-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_init_subtest "XMODE-w-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" pipe-no-fork $FD $((FD + 1)); }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(w-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+EXPR='(ASSOC == "mem") and (INODE == '"$INO"') and (MODE != "r--") and (MODE != "rw-") and (MODE != "rwx")'
+ts_init_subtest "MODE-x-bit"
+if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+else
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o MODE -p "${PID}" -Q "${EXPR}"
+ echo "MODE(x-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ ts_finalize_subtest
+fi
+
+ts_init_subtest "XMODE-x-bit"
+if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+else
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(x-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ ts_finalize_subtest
+fi
+
+FILE=./test_mkfds_make_regular_file
+EXPR='(FD == '"$FD"')'
+ts_init_subtest "XMODE-D-bit"
+{
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" delete=1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(D-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+for m in flock-sh posix-r- ofd-r-; do
+ ts_init_subtest "XMODE-l-bit-$m"
+ {
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(l-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip_subtest "$m lock is not available"
+ continue
+ fi
+ ts_finalize_subtest
+done
+
+ts_init_subtest "XMODE-l-bit-lease-r"
+f=ro-regular-file-read-lease
+touch "$f"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" ro-regular-file $FD file=$f read-lease=1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(l-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+rm -f "$f"
+ts_finalize_subtest
+
+for m in flock-ex posix--w posix-rw ofd--w ofd-rw lease-w; do
+ ts_init_subtest "XMODE-L-bit-$m"
+ {
+ rm -f "${FILE}"
+ coproc MKFDS { "$TS_HELPER_MKFDS" make-regular-file $FD file="$FILE" lock=$m; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(L-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+ wait "${MKFDS_PID}"
+ if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip_subtest "$m lock is not available"
+ continue
+ fi
+ ts_finalize_subtest
+done
+
+M0=6
+M1=9
+EXPR="(FD == $M0) or (FD == $M1)"
+ts_init_subtest "XMODE-m-bit"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" eventpoll $FD $M0 $M1; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q "${EXPR}"
+ echo "XMODE(m-bit): " $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+wait "${MKFDS_PID}"
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/option-filter-broken-exp b/tests/ts/lsfd/filter-broken-exp
index bedf439..1854e50 100755
--- a/tests/ts/lsfd/option-filter-broken-exp
+++ b/tests/ts/lsfd/filter-broken-exp
@@ -25,12 +25,13 @@ ts_check_test_command "$TS_CMD_LSFD"
ts_cd "$TS_OUTDIR"
{
- $TS_CMD_LSFD -Q ''
$TS_CMD_LSFD -Q '('
$TS_CMD_LSFD -Q ')'
$TS_CMD_LSFD -Q '(FD == 1)garbage'
- $TS_CMD_LSFD -Q 'FD'
$TS_CMD_LSFD -Q 'NOSUCHCOLUMN'
} > $TS_OUTPUT 2>&1
+sed -i -e 's/syntax error.*/<bison syntax error message removed>/g' \
+ $TS_OUTPUT $TS_ERRLOG
+
ts_finalize
diff --git a/tests/ts/lsfd/filter-floating-point-nums b/tests/ts/lsfd/filter-floating-point-nums
new file mode 100755
index 0000000..7f66dd5
--- /dev/null
+++ b/tests/ts/lsfd/filter-floating-point-nums
@@ -0,0 +1,90 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="timerfd"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=realtime remaining=0 interval=10 interval-nanofrac=000050000; }
+ if read -u ${MKFDS[0]} PID; then
+
+ PID_1=$((PID -1))
+ EXPR="(PID > ${PID_1}.9) and (PID < ${PID}.1) and (ASSOC == 'exe')"
+ PID_0=$(${TS_CMD_LSFD} -n -r -o PID -Q "$EXPR")
+ echo "pid in a range:" $?
+
+ if [[ "${PID_0}" == "${PID}" ]]; then
+ echo "coparing pids": $?
+ else
+ echo "coparing pids": $? "PID_0:${PID_0} == PID:${PID}"
+ fi
+
+ EXPR='(TIMERFD.INTERVAL < 10.000051) and (TIMERFD.INTERVAL > 10)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL <= 10) and (TIMERFD.INTERVAL > 9.99)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL >= 10)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL >= 10.0)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+
+ EXPR='(TIMERFD.INTERVAL < 10) and (0 < TIMERFD.INTERVAL)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL < 10) and (0.0 < TIMERFD.INTERVAL)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL > 11)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL == 10.00005)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ EXPR='(TIMERFD.INTERVAL == 10.000051)'
+ ${TS_CMD_LSFD} -n -r -o FD,TIMERFD.INTERVAL -p "$PID" -Q "$EXPR"
+ echo "FD,TIMERFD.INTERVAL: $EXPR": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/lsfd-functions.bash b/tests/ts/lsfd/lsfd-functions.bash
index d9a3595..3a3f58f 100644
--- a/tests/ts/lsfd/lsfd-functions.bash
+++ b/tests/ts/lsfd/lsfd-functions.bash
@@ -16,11 +16,11 @@
#
# The exit-status used in a test target.
-readonly ENOSYS=17
readonly EPERM=18
readonly ENOPROTOOPT=19
readonly EPROTONOSUPPORT=20
-readonly EACCESS=21
+readonly EACCES=21
+readonly ENOENT=22
function lsfd_wait_for_pausing {
ts_check_prog "sleep"
@@ -59,7 +59,7 @@ function lsfd_compare_dev {
fi
}
-lsfd_strip_type_stream()
+function lsfd_strip_type_stream
{
# lsfd changes the output of NAME column for a unix stream socket
# whether the kernel reports it is a "UNIX-STREAM" socket or a
@@ -68,7 +68,7 @@ lsfd_strip_type_stream()
sed -e 's/ type=stream//'
}
-lsfd_make_state_connected()
+function lsfd_make_state_connected
{
# Newer kernels report the states of unix dgram sockets created by
# sockerpair(2) are "connected" via /proc/net/unix though Older
@@ -83,3 +83,39 @@ lsfd_make_state_connected()
# to that on newer kernels.
sed -e 's/state=unconnected/state=connected/'
}
+
+function lsfd_check_mkfds_factory
+{
+ local FACTORY=$1
+
+ ts_check_test_command "$TS_HELPER_MKFDS"
+ if ! "$TS_HELPER_MKFDS" --is-available "$FACTORY"; then
+ ts_skip "test_mkfds has no factory for $FACTORY"
+ fi
+}
+
+function lsfd_check_sockdiag
+{
+ local family=$1
+
+ ts_check_test_command "$TS_HELPER_MKFDS"
+
+ local msg
+ local err
+
+ msg=$("$TS_HELPER_MKFDS" -c sockdiag 9 family=$family 2>&1)
+ err=$?
+
+ case $err in
+ 0)
+ return;;
+ $EPROTONOSUPPORT)
+ ts_skip "NETLINK_SOCK_DIAG protocol is not supported in socket(2)";;
+ $EACCES)
+ ts_skip "sending a msg via a sockdiag netlink socket is not permitted";;
+ $ENOENT)
+ ts_skip "sockdiag netlink socket is not available";;
+ *)
+ ts_failed "failed to create a sockdiag netlink socket $family ($err): $msg";;
+ esac
+}
diff --git a/tests/ts/lsfd/mkfds-bpf-map b/tests/ts/lsfd/mkfds-bpf-map
new file mode 100755
index 0000000..7821fe5
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-bpf-map
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="bpf-map files"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+NAME=mkfds_map
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" bpf-map "$FD" map-type-id=2 name="$NAME"; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -r -n -oBPF-MAP.TYPE,BPF-MAP.TYPE.RAW,BPF.NAME -p "${PID}" -Q "(FD == $FD)"
+ echo "BPF-MAP.TYPE,BPF-MAP.TYPE.RAW,BPF.NAME": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip "bpf(2) is not available"
+fi
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-bpf-prog b/tests/ts/lsfd/mkfds-bpf-prog
new file mode 100755
index 0000000..b2a7275
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-bpf-prog
@@ -0,0 +1,49 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="bpf-prog files"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+ts_skip_docker
+
+. "$TS_SELF/lsfd-functions.bash"
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+NAME=mkdfs_prog
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" bpf-prog "$FD" prog-type-id=2 name="$NAME"; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ "${TS_CMD_LSFD}" -r -n -oBPF-PROG.TYPE,BPF-PROG.TYPE.RAW,BPF.NAME -p "${PID}" -Q "(FD == $FD)"
+ echo "BPF-PROG.TYPE,BPF-PROG.TYPE.RAW,BPF.NAME": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
+ ts_skip "bpf(2) is not available"
+fi
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-cdev-tun b/tests/ts/lsfd/mkfds-cdev-tun
new file mode 100755
index 0000000..7354509
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-cdev-tun
@@ -0,0 +1,65 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="tun device and interface behind the device"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+[[ -e /dev/net/tun ]] || ts_skip "/dev/net/tun doest not exist"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+IFNAME=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" cdev-tun $FD ; }
+ if read -u ${MKFDS[0]} PID IFNAME; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'ASSOC,MODE,TYPE,SOURCE': $?
+
+ output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o NAME -Q "${EXPR}")
+ if [[ "$output" == "iface=$IFNAME" ]]; then
+ echo 'NAME': $?
+ else
+ echo 'NAME': $?
+ echo "expected NAME: iface=$IFNAME"
+ echo "output NAME: $output"
+ fi
+
+ output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o TUN.IFACE -Q "${EXPR}")
+ if [[ "$output" == "$IFNAME" ]]; then
+ echo 'TUN.IFACE': $?
+ else
+ echo 'TUN.IFAEC': $?
+ echo "expected TUN.IFACE: $IFNAME"
+ echo "output TUN.IFACE: $output"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-directory b/tests/ts/lsfd/mkfds-directory
index ef769c9..738cb86 100755
--- a/tests/ts/lsfd/mkfds-directory
+++ b/tests/ts/lsfd/mkfds-directory
@@ -101,7 +101,7 @@ esac
echo 'stat reports:' "$(stat -c %h /)"
fi
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-eventfd b/tests/ts/lsfd/mkfds-eventfd
new file mode 100755
index 0000000..02c86a6
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-eventfd
@@ -0,0 +1,104 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="eventfd with fork"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID0=
+PID1=
+FD0=3
+FD1=4
+EXPR=
+ID0=
+ID1=
+NAME0=
+NAME1=
+ENDPOINTS=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" eventfd $FD0 $FD1 ; }
+ if read -u ${MKFDS[0]} PID0 PID1; then
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID0}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'parent: ASSOC,MODE,TYPE,SOURCE': $?
+
+ NAME0=$(${TS_CMD_LSFD} -p "${PID0}" --raw -n -o NAME -Q "${EXPR}")
+ echo 'parent: NAME': $?
+
+ ID0=$(${TS_CMD_LSFD} -p "${PID0}" --raw -n -o EVENTFD.ID -Q "${EXPR}")
+ echo 'parent: ID': $?
+
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID1}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'child: ASSOC,MODE,TYPE,SOURCE': $?
+
+ NAME1=$(${TS_CMD_LSFD} -p "${PID1}" --raw -n -o NAME -Q "${EXPR}")
+ echo 'child: NAME': $?
+
+ ID1=$(${TS_CMD_LSFD} -p "${PID1}" --raw -n -o EVENTFD.ID -Q "${EXPR}")
+ echo 'child: ID': $?
+
+ if [ "${NAME0}" == "${NAME1}" ]; then
+ echo 'NAME[STR]:' $?
+ else
+ echo 'NAME[STR]:' $?
+ echo NAME0: "${NAME0}"
+ echo NAME1: "${NAME1}"
+ fi
+
+ if [ "${ID0}" == "${ID1}" ]; then
+ echo 'ID[STR]:' $?
+ else
+ echo 'ID[STR]:' $?
+ echo ID0: "${ID0}"
+ echo ID0: "${ID1}"
+ fi
+
+ if [ "${NAME0}" == "id=${ID1}" ]; then
+ echo 'NAMExID[STR]:' $?
+ else
+ echo 'NAMExID[STR]:' $?
+ echo NAME0: "${NAME0}"
+ echo ID0: "${ID0}"
+ fi
+
+ EXPR='(EVENTFD.ID == '"${ID0}"')'
+ ENDPOINTS=$(${TS_CMD_LSFD} --raw -n -o PID,ASSOC,ENDPOINTS -Q "${EXPR}")
+ tmp=$(printf "%d %d %d,test_mkfds,%d\n%d %d %d,test_mkfds,%d" \
+ "$PID0" "$FD0" "$PID1" "$FD1" \
+ "$PID1" "$FD1" "$PID0" "$FD0")
+ if [ "$ENDPOINTS" == "$tmp" ]; then
+ echo 'ENDPOINTS[STR]:' $?
+ else
+ echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS:' "$ENDPOINTS"
+ echo 'lsfd:' "$tmp"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-eventpoll b/tests/ts/lsfd/mkfds-eventpoll
new file mode 100755
index 0000000..230d6c4
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-eventpoll
@@ -0,0 +1,46 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="eventpoll targets"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD0=3
+FD1=5
+FD2=7
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" eventpoll $FD0 $FD1 $FD2 ; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME,EVENTPOLL.TFDS -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME,EVENTPOLL.TFDS': $?
+ ${TS_CMD_LSFD} -J -p "${PID}" -n -o ASSOC,TYPE,NAME,EVENTPOLL.TFDS -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME,EVENTPOLL.TFDS (JSON)': $?
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-inotify b/tests/ts/lsfd/mkfds-inotify
new file mode 100755
index 0000000..a44fd77
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-inotify
@@ -0,0 +1,74 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="inotify"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_prog "stat"
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+dir=/proc
+file=/proc/cmdline
+PROC="$(stat -c %i $dir)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $dir)"
+CMDLINE="$(stat -c %i $file)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $file)"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" inotify $FD dir=$dir file=$file ; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
+ INODES_RAW=$(${TS_CMD_LSFD} --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW": $?
+ if [[ "$INODES_RAW" == "${CMDLINE}"'\x0a'"${PROC}" ]]; then
+ echo "INOTIFY.INODES.RAW" == CMDLINE'\x0a'PROC
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW"
+ echo "CMDLINE": "$CMDLINE"
+ echo "PROC": "$PROC"
+ fi
+ INODES_RAW_JSON=$(${TS_CMD_LSFD} -J --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW (JSON)": $?
+ EXPECTED_JSON=$(cat<<EOF
+{
+ "lsfd": [
+ {
+ "inotify.inodes.raw": [
+ "$CMDLINE", "$PROC"
+ ]
+ }
+ ]
+}
+EOF
+ )
+ if [[ "$INODES_RAW_JSON" == "${EXPECTED_JSON}" ]]; then
+ echo "INOTIFY.INODES.RAW" == EXPECTED_JSON
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW_JSON"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-inotify-btrfs b/tests/ts/lsfd/mkfds-inotify-btrfs
new file mode 100755
index 0000000..5dc8e97
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-inotify-btrfs
@@ -0,0 +1,91 @@
+#!/bin/bash
+#
+# Copyright (C) 2024 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="inotify on btrfs"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_nonroot
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_CMD_FINDMNT"
+ts_check_prog "stat"
+ts_check_prog "sed"
+ts_check_prog "mkfs.btrfs"
+ts_check_prog "dd"
+
+ts_cd "$TS_OUTDIR"
+
+IMG=img.btrfs
+MNTPNT=mntpnt
+mkdir -p $MNTPNT
+dd if=/dev/zero of=$IMG bs=114294784 count=1 status=none
+if ! mkfs.btrfs -q $IMG; then
+ ts_skip "failed to make a btrfs image: $IMG"
+fi
+if ! mount $IMG $MNTPNT; then
+ ts_skip "failed to mount a btrfs image, $IMG to $MNTPNT"
+fi
+trap "umount $MNTPNT; rm -f $IMG" EXIT
+
+if ! touch $MNTPNT/fstab; then
+ ts_skip "failed to touch a file on a btrfs filesystem: $MNTPNT/fstab"
+fi
+
+PID=
+FD=3
+ROOT="$(stat -c %i $MNTPNT)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $MNTPNT)"
+FSTAB="$(stat -c %i $MNTPNT/fstab)"@"$($TS_CMD_FINDMNT --raw --noheadings -oMAJ:MIN --target $MNTPNT/fstab)"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" inotify $FD dir=$MNTPNT file=$MNTPNT/fstab; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(PID == '"${PID}"') and (FD == '"$FD"')'
+ INODES_RAW=$(${TS_CMD_LSFD} --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW": $?
+ if [[ "$INODES_RAW" == "${FSTAB}"'\x0a'"${ROOT}" ]]; then
+ echo "INOTIFY.INODES.RAW" == FSTAB'\x0a'ROOT
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW"
+ echo "FSTAB": "$FSTAB"
+ echo "ROOT": "$ROOT"
+ fi
+ INODES_RAW_JSON=$(${TS_CMD_LSFD} -J --raw -n -o INOTIFY.INODES.RAW -Q "${EXPR}")
+ echo "INOTIFY.INODES.RAW (JSON)": $?
+ EXPECTED_JSON=$(cat<<EOF
+{
+ "lsfd": [
+ {
+ "inotify.inodes.raw": [
+ "$FSTAB", "$ROOT"
+ ]
+ }
+ ]
+}
+EOF
+ )
+ if [[ "$INODES_RAW_JSON" == "${EXPECTED_JSON}" ]]; then
+ echo "INOTIFY.INODES.RAW" == EXPECTED_JSON
+ else
+ echo "INOTIFY.INODES.RAW": "$INODES_RAW_JSON"
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-mapped-packet-socket b/tests/ts/lsfd/mkfds-mapped-packet-socket
index a1fb68f..12c5ef6 100755
--- a/tests/ts/lsfd/mkfds-mapped-packet-socket
+++ b/tests/ts/lsfd/mkfds-mapped-packet-socket
@@ -49,7 +49,7 @@ for SOCKTYPE in RAW DGRAM; do
${TS_CMD_LSFD} -p "$PID" -n -o NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL -Q "${EXPR}"
echo 'NAME,SOCK.TYPE,SOCK.PROTONAME,PACKET.IFACE,PACKET.PROTOCOL': $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
ERR=$?
diff --git a/tests/ts/lsfd/mkfds-mqueue b/tests/ts/lsfd/mkfds-mqueue
new file mode 100755
index 0000000..bd22132
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-mqueue
@@ -0,0 +1,83 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="mqueue with fork"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_native_byteorder
+
+ts_cd "$TS_OUTDIR"
+
+MQUEUE=/mkfds-mqueue
+PID0=
+PID1=
+FD0=3
+FD1=4
+EXPR=
+INODE0=
+INODE1=
+ENDPOINTS=
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" mqueue $FD0 $FD1 path=${MQUEUE}; }
+ if read -u ${MKFDS[0]} PID0 PID1; then
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID0}" -n -o ASSOC,MODE,TYPE,SOURCE,NAME -Q "${EXPR}"
+ echo 'parent: ASSOC,MODE,TYPE,SOURCE,NAME': $?
+
+ INODE0=$(${TS_CMD_LSFD} -p "${PID0}" --raw -n -o INODE -Q "${EXPR}")
+ echo 'parent: INODE': $?
+
+ EXPR='(FD == '"$FD0"') or (FD =='"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID1}" -n -o ASSOC,MODE,TYPE,SOURCE -Q "${EXPR}"
+ echo 'child: ASSOC,MODE,TYPE,SOURCE': $?
+
+ INODE1=$(${TS_CMD_LSFD} -p "${PID1}" --raw -n -o INODE -Q "${EXPR}")
+ echo 'child: INODE': $?
+
+ if [ "${INODE0}" == "${INODE1}" ]; then
+ echo 'INODE[STR]:' $?
+ else
+ echo 'INODE[STR]:' $?
+ echo INODE0: "${INODE0}"
+ echo INODE1: "${INODE1}"
+ fi
+
+ EXPR='(INODE == '"${INODE0}"') and (TYPE == "mqueue")'
+ ENDPOINTS=$(${TS_CMD_LSFD} --raw -n -o PID,ASSOC,ENDPOINTS -Q "${EXPR}")
+ tmp=$(printf "%d %d %d,test_mkfds,%d-w\n%d %d %d,test_mkfds,%dr-" \
+ "$PID0" "$FD0" "$PID1" "$FD1" \
+ "$PID1" "$FD1" "$PID0" "$FD0")
+ if [ "$ENDPOINTS" == "$tmp" ]; then
+ echo 'ENDPOINTS[STR]:' $?
+ else
+ echo 'ENDPOINTS[STR]:' $?
+ echo 'ENDPOINTS:' "$ENDPOINTS"
+ echo 'lsfd:' "$tmp"
+ grep mqueue /proc/self/mountinfo
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-multiplexing b/tests/ts/lsfd/mkfds-multiplexing
new file mode 100755
index 0000000..8cc7f31
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-multiplexing
@@ -0,0 +1,70 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="XMODE.m for classical system calls for multiplexing"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+# /proc/${PID}/syscall is rendered in the host side byteorder.
+ts_skip_qemu_user
+
+ts_check_prog "grep"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+
+for multiplexer in pselect6 select poll ppoll; do
+ ts_init_subtest "${multiplexer}"
+ if ! "$TS_HELPER_MKFDS" -W | grep -q "^$multiplexer\$"; then
+ ts_skip_subtest "the multiplexer ${multiplexer} is not available"
+ continue
+ fi
+
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" -w "$multiplexer" multiplexing {10..22}; }
+ } > "$TS_OUTPUT" 2>&1
+
+ if read -r -u "${MKFDS[0]}" PID; then
+ if ! cat /proc/"${PID}"/syscall > /dev/null 2>&1; then
+ kill -CONT "${PID}"
+ wait "${MKFDS_PID}"
+ ts_skip_subtest "cannot open /proc/${PID}/syscall"
+ continue
+ fi
+ {
+ "${TS_CMD_LSFD}" -n -o ASSOC,XMODE -p "${PID}" -Q '(FD >= 10) && (FD <= 22)'
+ echo "[$multiplexer] ASSOC,XMODE: $?"
+
+ # For debugging
+ if [[ $("${TS_CMD_LSFD}" -n -o XMODE -p "${PID}" -Q '(FD == 10)') != "r----m" ]]; then
+ cat /proc/"${PID}"/syscall
+ fi
+
+ echo DONE >&"${MKFDS[1]}"
+ } >> "$TS_OUTPUT" 2>&1
+ fi
+
+ wait "${MKFDS_PID}"
+ ts_finalize_subtest
+done
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-netlink-groups b/tests/ts/lsfd/mkfds-netlink-groups
index 896b50c..b7646c2 100755
--- a/tests/ts/lsfd/mkfds-netlink-groups
+++ b/tests/ts/lsfd/mkfds-netlink-groups
@@ -47,7 +47,7 @@ NETLINK_GROUPS=5
else
printf "LPORT: FAILED (PID: %d != NETLINK.LPORT: %d)\n" "${PID}" "${NETLINK_LPORT}"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-netlink-protocol b/tests/ts/lsfd/mkfds-netlink-protocol
index c1a5ffc..abf2eb2 100755
--- a/tests/ts/lsfd/mkfds-netlink-protocol
+++ b/tests/ts/lsfd/mkfds-netlink-protocol
@@ -46,7 +46,7 @@ NETLINK_GROUPS=5
else
printf "LPORT: FAILED (PID: %d != NETLINK.LPORT: %d)\n" "${PID}" "${NETLINK_LPORT}"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-netns b/tests/ts/lsfd/mkfds-netns
index cd110f6..0fbaec8 100755
--- a/tests/ts/lsfd/mkfds-netns
+++ b/tests/ts/lsfd/mkfds-netns
@@ -25,6 +25,7 @@ ts_skip_docker
. "$TS_SELF/lsfd-functions.bash"
ts_check_test_command "$TS_CMD_LSFD"
ts_check_test_command "$TS_HELPER_MKFDS"
+lsfd_check_mkfds_factory netns
ts_cd "$TS_OUTDIR"
@@ -61,11 +62,11 @@ INO_NS=
echo "NAME_FD: $NAME_FD" == "net:[INO_NS: $INO_NS]": $?
fi
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
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
diff --git a/tests/ts/lsfd/mkfds-pidfd b/tests/ts/lsfd/mkfds-pidfd
index aad693f..c0fae4f 100755
--- a/tests/ts/lsfd/mkfds-pidfd
+++ b/tests/ts/lsfd/mkfds-pidfd
@@ -40,11 +40,11 @@ EXPR="(PID != ${TARGET}) and (FD == 3) and (PIDFD.PID == ${TARGET})"
${TS_CMD_LSFD} -n -o ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID -p "${PID}" -p ${TARGET} -Q "${EXPR}"
echo 'ASSOC,STTYPE,SOURCE,NAME,PIDFD.COMM,PIDFD.PID': $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
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
diff --git a/tests/ts/lsfd/mkfds-ping b/tests/ts/lsfd/mkfds-ping
index c2ca049..2baafde 100755
--- a/tests/ts/lsfd/mkfds-ping
+++ b/tests/ts/lsfd/mkfds-ping
@@ -90,7 +90,7 @@ ERRMSG=
for i in 0 1; do
ERRMSG=$("$TS_HELPER_MKFDS" -c -q "${FACTORY[$i]}" 3 id=$ID 2>&1)
ERR="$?"
- if [[ "$ERR" == "$EACCESS" ]]; then
+ if [[ "$ERR" == "$EACCES" ]]; then
case "$ERRMSG" in
*bind*)
MSG="making ${TYPE[$i]} socket with specifying id is not allowed (blocked by SELinux?)"
@@ -122,7 +122,7 @@ for i in 0 1; do
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \
-p "${PID}" -Q "${EXPR[$i]}"
echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -132,7 +132,7 @@ for i in 0 1; do
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID \
-p "${PID}" -Q "${EXPR[$i]}"
echo "ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,${COLNS[$i]}.LADDR,${COLNS[$i]}.RADDR,PING.ID": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
} > "$TS_OUTPUT" 2>&1
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-pipe-no-fork b/tests/ts/lsfd/mkfds-pipe-no-fork
index e28aa9d..f2f950a 100755
--- a/tests/ts/lsfd/mkfds-pipe-no-fork
+++ b/tests/ts/lsfd/mkfds-pipe-no-fork
@@ -116,7 +116,7 @@ EOF
echo EXPECTED_LSFD_ENDPOINTS_JSON: "${EXPECTED_LSFD_ENDPOINTS_JSON}"
fi
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-pty b/tests/ts/lsfd/mkfds-pty
new file mode 100755
index 0000000..cc781eb
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-pty
@@ -0,0 +1,73 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="ptmx and associated pts"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD0=5
+FD1=6
+INDEX=
+
+col_test()
+{
+ local col=$1
+ local expected=$2
+ local output
+
+ output=$(${TS_CMD_LSFD} -p "${PID}" -n --raw -o "$col" -Q "${EXPR}")
+ echo "$col": $?
+ if [[ "$output" != "$expected" ]]; then
+ echo "expected ${col} -Q ${EXPR}: ${expected}"
+ echo "output ${col} -Q ${EXPR}: ${output}"
+ fi
+}
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" pty $FD0 $FD1 ; }
+ if read -u ${MKFDS[0]} PID INDEX; then
+ EXPR='(FD == '$FD0')'
+ columns=ASSOC,MODE,TYPE,SOURCE
+ ${TS_CMD_LSFD} -p "${PID}" -n -r -o "$columns" -Q "${EXPR}"
+ echo "$columns": $?
+
+ col_test NAME "tty-index=${INDEX}"
+ col_test ENDPOINTS "${PID},test_mkfds,${FD1}r-"
+ col_test PTMX.TTY-INDEX "$INDEX"
+
+ EXPR='(FD == '$FD1')'
+ columns=ASSOC,MODE,TYPE
+ ${TS_CMD_LSFD} -p "${PID}" -n -r -o "$columns" -Q "${EXPR}"
+ echo "$columns": $?
+
+ col_test SOURCE "pts:${INDEX}"
+ col_test NAME "/dev/pts/${INDEX}"
+ col_test ENDPOINTS "${PID},test_mkfds,${FD0}rw"
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait ${MKFDS_PID}
+} > $TS_OUTPUT 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-raw b/tests/ts/lsfd/mkfds-raw
index 0260ba1..5770340 100755
--- a/tests/ts/lsfd/mkfds-raw
+++ b/tests/ts/lsfd/mkfds-raw
@@ -40,7 +40,7 @@ PROTOCOL=5
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,RAW.PROTOCOL \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET.LADDR,INET.RADDR,RAW.PROTOCOL': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-raw6 b/tests/ts/lsfd/mkfds-raw6
index 0b82fff..1eddea2 100755
--- a/tests/ts/lsfd/mkfds-raw6
+++ b/tests/ts/lsfd/mkfds-raw6
@@ -41,7 +41,7 @@ PROTOCOL=5
-o ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,RAW.PROTOCOL \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,NAME,SOCK.STATE,SOCK.TYPE,INET6.LADDR,INET6.RADDR,RAW.PROTOCOL': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-ro-block-device b/tests/ts/lsfd/mkfds-ro-block-device
index ad5a492..7b14630 100755
--- a/tests/ts/lsfd/mkfds-ro-block-device
+++ b/tests/ts/lsfd/mkfds-ro-block-device
@@ -72,7 +72,7 @@ EXPR=
lsfd_compare_dev "${TS_CMD_LSFD}" "${LSFD_LOOP_BDEV}" "${EXPR}"
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-ro-regular-file b/tests/ts/lsfd/mkfds-ro-regular-file
index a2c4c26..367a07d 100755
--- a/tests/ts/lsfd/mkfds-ro-regular-file
+++ b/tests/ts/lsfd/mkfds-ro-regular-file
@@ -70,7 +70,7 @@ EXPR=
lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}"
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-rw-character-device b/tests/ts/lsfd/mkfds-rw-character-device
index 85dd29c..3df2944 100755
--- a/tests/ts/lsfd/mkfds-rw-character-device
+++ b/tests/ts/lsfd/mkfds-rw-character-device
@@ -42,7 +42,7 @@ EXPR=
lsfd_compare_dev "${TS_CMD_LSFD}" $target "${EXPR}"
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-signalfd b/tests/ts/lsfd/mkfds-signalfd
new file mode 100755
index 0000000..ecc7379
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-signalfd
@@ -0,0 +1,64 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="signalfd"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+# s390x and riscv64 reported the same error:
+#
+# lsfd: signalfd ...
+# diff-{{{
+# --- /home/runner/work/util-linux/util-linux/tests/expected/lsfd/mkfds-signalfd 2023-06-08 10:20:13.520555037 +0000
+# +++ /home/runner/work/util-linux/util-linux/tests/output/lsfd/mkfds-signalfd 2023-06-08 11:12:21.150054369 +0000
+# @@ -1,2 +1,2 @@
+# - 3 signalfd mask=FPE,USR1,42 FPE,USR1,42
+# + 3 signalfd mask=FPE,USR1,44 FPE,USR1,44
+# ASSOC,TYPE,NAME,SIGNALFD.MASK: 0
+# }}}-diff
+#
+# FAILED (lsfd/mkfds-signalfd)
+#
+# The error is nothing to do with endianness; the endian s390x is
+# big-endian. riscv64 is little-endian.
+#
+# So Qemu's user emulation is suspicious.
+ts_skip_qemu_user
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+
+COL=ASSOC,TYPE,NAME,SIGNALFD.MASK
+EXPR='(FD == '"$FD"')'
+
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" signalfd $FD; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "${PID}" -n -o "${COL}" -Q "${EXPR}"
+ echo "${COL}": $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-socketpair b/tests/ts/lsfd/mkfds-socketpair
index 3ffd088..3ef60c7 100755
--- a/tests/ts/lsfd/mkfds-socketpair
+++ b/tests/ts/lsfd/mkfds-socketpair
@@ -20,6 +20,7 @@ TS_DESC="AF_UNIX socket pair created with socketpair(2)"
. "$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"
@@ -28,11 +29,14 @@ ts_check_prog "sed"
ts_cd "$TS_OUTDIR"
+lsfd_check_sockdiag "unix"
+
PID=
FD0=3
FD1=4
EXPR=
+ts_init_subtest "DGRAM"
{
coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=DGRAM; }
if read -u ${MKFDS[0]} PID; then
@@ -40,9 +44,96 @@ EXPR=
${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-DGRAM/UNIX/'
echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]}
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+
+wait ${MKFDS_PID}
+ts_finalize_subtest
+
+ts_init_subtest "STREAM"
+{
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(PID == '"${PID}"') and ((FD == '"$FD0"') or (FD == '"$FD1"'))'
+ ${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-STREAM/UNIX/'
+ echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+} > "$TS_OUTPUT" 2>&1
+
+wait ${MKFDS_PID}
+ts_finalize_subtest
+
+mkfds_socketpair_stream_endpoint()
+{
+ ts_init_subtest "STREAM-ENDPOINT"
+ if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+ return
+ fi
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS -Q "${EXPR}" | sed -e "s/${PID}/1/g"
+ echo 'ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
+ wait ${MKFDS_PID}
+ ts_finalize_subtest
+}
+
+mkfds_socketpair_stream_shutdown_state()
+{
+ ts_init_subtest "STREAM-SHUTDOWN-STATE"
+ if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+ return
+ fi
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM halfclose=1; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.SHUTDOWN -Q "${EXPR}"
+ echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.SHUTDOWN': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
+ wait ${MKFDS_PID}
+ ts_finalize_subtest
+}
+
+mkfds_socketpair_stream_endpoint_halfclose()
+{
+ ts_init_subtest "STREAM-ENDPOINT-halfclose"
+ if [ "$QEMU_USER" == "1" ]; then
+ ts_skip_subtest "running under qemu-user emulation"
+ return
fi
+ {
+ coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM halfclose=1; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS -Q "${EXPR}" | sed -e "s/${PID}/1/g"
+ echo 'ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ } > "$TS_OUTPUT" 2>&1
+
wait ${MKFDS_PID}
-} > $TS_OUTPUT 2>&1
+ ts_finalize_subtest
+}
+
+mkfds_socketpair_stream_endpoint
+mkfds_socketpair_stream_shutdown_state
+mkfds_socketpair_stream_endpoint_halfclose
ts_finalize
diff --git a/tests/ts/lsfd/mkfds-symlink b/tests/ts/lsfd/mkfds-symlink
index 4825645..56eccca 100755
--- a/tests/ts/lsfd/mkfds-symlink
+++ b/tests/ts/lsfd/mkfds-symlink
@@ -37,7 +37,7 @@ EXPR=
${TS_CMD_LSFD} -n -o ASSOC,MODE,TYPE,NAME,FLAGS -Q "${EXPR}"
echo 'ASSOC,MODE,TYPE,NAME,FLAGS': $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/mkfds-tcp b/tests/ts/lsfd/mkfds-tcp
index e531a7b..666cf6a 100755
--- a/tests/ts/lsfd/mkfds-tcp
+++ b/tests/ts/lsfd/mkfds-tcp
@@ -34,15 +34,15 @@ EXPR='(TYPE == "TCP") and (FD >= 3) and (FD <= 5)'
{
coproc MKFDS { "$TS_HELPER_MKFDS" tcp $FDS $FDC $FDA \
- server-port=34567 \
- client-port=23456 ; }
+ server-port=56789 \
+ client-port=45678 ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
-o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-tcp6 b/tests/ts/lsfd/mkfds-tcp6
index 7368bfa..bffa630 100755
--- a/tests/ts/lsfd/mkfds-tcp6
+++ b/tests/ts/lsfd/mkfds-tcp6
@@ -35,15 +35,15 @@ EXPR='(TYPE == "TCPv6") and (FD >= 3) and (FD <= 5)'
{
coproc MKFDS { "$TS_HELPER_MKFDS" tcp6 $FDS $FDC $FDA \
- server-port=34567 \
- client-port=23456 ; }
+ server-port=56789 \
+ client-port=45678 ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
-o ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT \
-p "${PID}" -Q "${EXPR}"
echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,TCP.LADDR,TCP.LPORT,TCP.RADDR,TCP.RPORT': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-timerfd b/tests/ts/lsfd/mkfds-timerfd
new file mode 100755
index 0000000..d2e0b8a
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-timerfd
@@ -0,0 +1,109 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="timerfd"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_check_prog "sed"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR='(FD == '"$FD"')'
+
+ts_init_subtest "realtime-remaining-and-interval"
+{
+ clock=realtime
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=99 interval=5 interval-nanofrac=123456789; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}" | \
+ sed -e 's/remaining=[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/remaining=100.987654321/'
+ echo 'ASSOC,TYPE,NAME': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}" | \
+ sed -e 's/^ *[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/100.987654321/'
+ echo 'TIMERFD.REMAINING': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "monotonic-remaining-only"
+{
+ clock=monotonic
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=99 interval=0 interval-nanofrac=0; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}" | \
+ sed -e 's/remaining=[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]/remaining=100.987654321/'
+ echo 'ASSOC,TYPE,NAME': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}" | \
+ sed -e 's/^ *[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$/100.987654321/'
+ echo 'TIMERFD.REMAINING': ${PIPESTATUS[0]}
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_init_subtest "boottime-interval-only"
+{
+ clock=boottime
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=0 interval=10 interval-nanofrac=123456789; }
+ if read -u ${MKFDS[0]} PID; then
+ EXPR='(FD == '"$FD"')'
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}"
+ echo 'TIMERFD.REMAINING': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+} > "$TS_OUTPUT" 2>&1
+ts_finalize_subtest
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-timerfd-alarm b/tests/ts/lsfd/mkfds-timerfd-alarm
new file mode 100755
index 0000000..c7e6650
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-timerfd-alarm
@@ -0,0 +1,56 @@
+#!/bin/bash
+#
+# Copyright (C) 2023 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="timerfd associating alarm"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+
+ts_skip_capability WAKE_ALARM
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+PID=
+FD=3
+EXPR='(FD == '"$FD"')'
+
+{
+ for clock in realtime-alarm boottime-alarm; do
+ coproc MKFDS { "$TS_HELPER_MKFDS" timerfd $FD clockid=$clock remaining=0 interval=0 interval-nanofrac=0; }
+ if read -u ${MKFDS[0]} PID; then
+ ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,TYPE,NAME -Q "${EXPR}"
+ echo 'ASSOC,TYPE,NAME': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.CLOCKID -Q "${EXPR}"
+ echo 'CLOCKID': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.REMAINING -Q "${EXPR}"
+ echo 'TIMERFD.REMAINING': $?
+
+ ${TS_CMD_LSFD} -p "${PID}" -n -o TIMERFD.INTERVAL -Q "${EXPR}"
+ echo 'TIMERFD.INTERVAL': $?
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+ done
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/mkfds-udp b/tests/ts/lsfd/mkfds-udp
index e6e1f1c..3d1b272 100755
--- a/tests/ts/lsfd/mkfds-udp
+++ b/tests/ts/lsfd/mkfds-udp
@@ -51,8 +51,8 @@ LPORT=
for lite in 0 1; do
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
@@ -60,13 +60,13 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
server-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -85,13 +85,13 @@ for lite in 0 1; do
echo "NAME pattern match: FAILED (NAME=$NAME)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -115,13 +115,13 @@ for lite in 0 1; do
echo "LADDR/LPORT pattern match: FAILED (LADDR=$LADDR, LPORT=$LPORT)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-connect=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -130,7 +130,7 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo 'ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET.LADDR,INET.RADDR,UDP.LADDR,UDP.LPORT,UDP.RADDR,UDP.RPORT': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
done > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-udp6 b/tests/ts/lsfd/mkfds-udp6
index 75381ba..26bdacd 100755
--- a/tests/ts/lsfd/mkfds-udp6
+++ b/tests/ts/lsfd/mkfds-udp6
@@ -52,8 +52,8 @@ LPORT=
for lite in 0 1; do
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
@@ -61,13 +61,13 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
server-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -86,13 +86,13 @@ for lite in 0 1; do
echo "NAME pattern match: FAILED (NAME=$NAME)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-bind=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -116,13 +116,13 @@ for lite in 0 1; do
echo "LADDR/LPORT pattern match: FAILED (LADDR=$LADDR, LPORT=$LPORT)"
fi
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
coproc MKFDS { "$TS_HELPER_MKFDS" udp6 $FDS $FDC \
- server-port=34567 \
- client-port=23456 \
+ server-port=56789 \
+ client-port=45678 \
client-do-connect=no \
lite=$lite; }
if read -r -u "${MKFDS[0]}" PID; then
@@ -131,7 +131,7 @@ for lite in 0 1; do
-p "${PID}" -Q "${EXPR[$lite]}"
echo "ASSOC,TYPE,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,INET6.LADDR,INET6.RADDR,${COLNS[$lite]}.LADDR,${COLNS[$lite]}.LPORT,${COLNS[$lite]}.RADDR,${COLNS[$lite]}.RPORT": $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
done > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-unix-dgram b/tests/ts/lsfd/mkfds-unix-dgram
index c8b40eb..45a0b2d 100755
--- a/tests/ts/lsfd/mkfds-unix-dgram
+++ b/tests/ts/lsfd/mkfds-unix-dgram
@@ -35,7 +35,7 @@ make_state_connected()
{
# The first one is for rewriting NAME column.
# The second one is for rewriting STATE column.
- lsfd_make_state_connected | sed -e 's/unconnected/ connected/'
+ lsfd_make_state_connected | sed -e 's/unconnected/connected/'
}
{
@@ -43,11 +43,12 @@ make_state_connected()
path=test_mkfds-unix-dgram ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
+ -r \
-o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \
-p "${PID}" -Q "${EXPR}" | make_state_connected
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -56,11 +57,12 @@ make_state_connected()
abstract=true ; }
if read -r -u "${MKFDS[0]}" PID; then
${TS_CMD_LSFD} -n \
+ -r \
-o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \
-p "${PID}" -Q "${EXPR}" | make_state_connected
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': $?
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-unix-in-netns b/tests/ts/lsfd/mkfds-unix-in-netns
index cfca087..9ed4567 100755
--- a/tests/ts/lsfd/mkfds-unix-in-netns
+++ b/tests/ts/lsfd/mkfds-unix-in-netns
@@ -78,7 +78,7 @@ for t in stream dgram seqpacket; do
compare_net_namespaces "$t" "${PID}"
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -94,7 +94,7 @@ for t in stream dgram seqpacket; do
compare_net_namespaces "abstract $t" "${PID}"
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
} > "$TS_OUTPUT" 2>&1
diff --git a/tests/ts/lsfd/mkfds-unix-stream b/tests/ts/lsfd/mkfds-unix-stream
index fe08e72..3c31443 100755
--- a/tests/ts/lsfd/mkfds-unix-stream
+++ b/tests/ts/lsfd/mkfds-unix-stream
@@ -46,7 +46,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
-p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -59,7 +59,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
-p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
echo '(abs) ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -75,7 +75,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
echo '(shutdown) ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
# Surprisingly, the socket status doesn't change at all.
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
@@ -88,7 +88,7 @@ EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5)
-p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
- kill -CONT "${PID}"
+ echo DONE >&"${MKFDS[1]}"
fi
wait "${MKFDS_PID}"
diff --git a/tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag b/tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag
new file mode 100755
index 0000000..6189d0d
--- /dev/null
+++ b/tests/ts/lsfd/mkfds-unix-stream-requiring-sockdiag
@@ -0,0 +1,58 @@
+#!/bin/bash
+#
+# Copyright (C) 2022 Masatake YAMATO <yamato@redhat.com>
+#
+# This file is part of util-linux.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This file is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+TS_TOPDIR="${0%/*}/../.."
+TS_DESC="UNIX stream sockets"
+
+. "$TS_TOPDIR"/functions.sh
+ts_init "$*"
+ts_skip_qemu_user
+
+. "$TS_SELF/lsfd-functions.bash"
+
+ts_check_test_command "$TS_CMD_LSFD"
+ts_check_test_command "$TS_HELPER_MKFDS"
+
+ts_cd "$TS_OUTDIR"
+
+lsfd_check_sockdiag "unix"
+
+PID=
+FDS=3
+FDC=4
+FDA=5
+EXPR='(((TYPE == "UNIX-STREAM") or (TYPE == "UNIX")) and (FD >= 3) and (FD <= 5))'
+
+{
+ for t in stream seqpacket; do
+
+ coproc MKFDS { "$TS_HELPER_MKFDS" unix-stream $FDS $FDC $FDA \
+ path="test_mkfds-unix with newline ${t} $(printf 'a\nb\nc')" \
+ type=$t ; }
+ if read -r -u "${MKFDS[0]}" PID; then
+ ${TS_CMD_LSFD} -n \
+ -o ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH \
+ -p "${PID}" -Q "${EXPR}" | lsfd_strip_type_stream
+ echo 'ASSOC,STTYPE,NAME,SOCK.STATE,SOCK.TYPE,SOCK.LISTENING,UNIX.PATH': ${PIPESTATUS[0]}
+
+ echo DONE >&"${MKFDS[1]}"
+ fi
+ wait "${MKFDS_PID}"
+
+ done
+} > "$TS_OUTPUT" 2>&1
+
+ts_finalize
diff --git a/tests/ts/lsfd/option-inet b/tests/ts/lsfd/option-inet
index 011a9b3..7ca8837 100755
--- a/tests/ts/lsfd/option-inet
+++ b/tests/ts/lsfd/option-inet
@@ -25,23 +25,54 @@ ts_skip_docker
ts_check_test_command "$TS_CMD_LSFD"
ts_check_test_command "$TS_HELPER_MKFDS"
+ts_check_prog "mkfifo"
+
ts_cd "$TS_OUTDIR"
+FIFO=./test_mkfds-option-inet.fifo
{
- "$TS_HELPER_MKFDS" -q tcp 3 4 5 server-port=34567 client-port=23456 &
- PID0=$!
-
- "$TS_HELPER_MKFDS" -q tcp6 3 4 5 server-port=34567 client-port=23456 &
- PID1=$!
-
- "$TS_HELPER_MKFDS" -q ro-regular-file 3 file=/etc/passwd &
- PID2=$!
-
- "$TS_HELPER_MKFDS" -q udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1&
- PID3=$!
-
- "$TS_HELPER_MKFDS" -q udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1&
- PID4=$!
+ rm -f "${FIFO}"
+ if ! mkfifo "${FIFO}"; then
+ ts_finalize "failed in creating a fifo"
+ fi
+
+ "$TS_HELPER_MKFDS" -X tcp 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
+ if ! read PID0 < "${FIFO}"; then
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS tcp...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X tcp6 3 4 5 server-port=34567 client-port=23456 > "${FIFO}" &
+ if ! read PID1 < "${FIFO}"; then
+ kill -CONT "${PID0}"
+ wait "${PID0}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS tcp6...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X ro-regular-file 3 file=/etc/passwd > "${FIFO}" &
+ if ! read PID2 < "${FIFO}"; then
+ kill -CONT "${PID0}" "${PID1}"
+ wait "${PID0}" "${PID1}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS ro-regular-file...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X udp 3 4 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
+ if ! read PID3 < "${FIFO}"; then
+ kill -CONT "${PID0}" "${PID1}" "${PID2}"
+ wait "${PID0}" "${PID1}" "${PID2}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS udp...doesn't report its pid"
+ fi
+
+ "$TS_HELPER_MKFDS" -X udp6 3 4 lite=1 server-port=34567 client-port=23456 server-do-bind=1 client-do-bind=1 client-do-connect=1 > "${FIFO}" &
+ if ! read PID4 < "${FIFO}"; then
+ kill -CONT "${PID0}" "${PID1}" "${PID2}" "${PID3}"
+ wait "${PID0}" "${PID1}" "${PID2}" "${PID3}"
+ rm "${FIFO}"
+ ts_finalize "$TS_HELPER_MKFDS udp6 lite=1...doesn't report its pid"
+ fi
OPT='--inet'
echo "# $OPT"
@@ -85,14 +116,9 @@ ts_cd "$TS_OUTDIR"
-o ASSOC,TYPE,NAME \
-Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2) or (PID == $PID3) or (PID == $PID4)"
- kill -CONT "${PID0}"
- wait "${PID0}"
-
- kill -CONT "${PID1}"
- wait "${PID1}"
-
- kill -CONT "${PID2}"
- wait "${PID2}"
+ kill -CONT "${PID0}" "${PID1}" "${PID2}" "${PID3}" "${PID4}"
+ wait "${PID0}" "${PID1}" "${PID2}" "${PID3}" "${PID4}"
+ rm "${FIFO}"
} > "$TS_OUTPUT" 2>&1
ts_finalize
diff --git a/tests/ts/lsfd/option-pid b/tests/ts/lsfd/option-pid
index 0ea4353..003b624 100755
--- a/tests/ts/lsfd/option-pid
+++ b/tests/ts/lsfd/option-pid
@@ -72,7 +72,7 @@ POUT=
[ "${QOUT}" = "${POUT}" ]
echo "EQ[-p PID --pid=1]:" $?
- kill -CONT ${PID}
+ echo DONE >&"${MKFDS[1]}"
fi
wait ${MKFDS_PID}
} > $TS_OUTPUT 2>&1
diff --git a/tests/ts/lsfd/option-summary b/tests/ts/lsfd/option-summary
index 64bf54b..9813901 100755
--- a/tests/ts/lsfd/option-summary
+++ b/tests/ts/lsfd/option-summary
@@ -35,14 +35,14 @@ PIDS=
PID=
for i in {1..10}; do
- "$TS_HELPER_MKFDS" -q ro-regular-file $FD file=$F_GROUP &
+ "$TS_HELPER_MKFDS" -X -q ro-regular-file $FD file=$F_GROUP &
PID=$!
PIDS="${PIDS} ${PID} "
lsfd_wait_for_pausing "${PID}"
done
for i in {1..3}; do
- "$TS_HELPER_MKFDS" -q ro-regular-file $FD file=$F_PASSWD &
+ "$TS_HELPER_MKFDS" -X -q ro-regular-file $FD file=$F_PASSWD &
PID=$!
PIDS="${PIDS} ${PID} "
lsfd_wait_for_pausing "${PID}"