]>
git.ipfire.org Git - thirdparty/util-linux.git/blob - tests/ts/lsns/filter
3 # Copyright (C) 2024 Masatake YAMATO <yamato@redhat.com>
5 # This file is part of util-linux.
7 # This file is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
12 # This file is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 TS_TOPDIR
="${0%/*}/../.."
18 TS_DESC
="-Q, --filter option"
20 .
"$TS_TOPDIR"/functions.sh
22 .
"$TS_TOPDIR"/ts
/lsfd
/lsfd-functions.bash
26 ts_check_test_command
"$TS_CMD_LSNS"
27 ts_check_test_command
"$TS_CMD_LSFD"
29 ts_check_test_command
"$TS_HELPER_MKFDS"
31 # unshare(2) used in userns factory of test_mkfds reports "Invalid argument".
39 coproc MKFDS
{ "$TS_HELPER_MKFDS" --comm ABC userns
$FD; }
40 if read -u ${MKFDS[0]} PID
; then
41 expr="PID == \"${PID}\" and ASSOC == \"user\""
42 inode
=$
(${TS_CMD_LSFD} -n --raw -o INODE
-Q "${expr}")
43 for opt
in -Q --filter; do
44 pid
=$
(${TS_CMD_LSNS} -n --raw -o PID
"$opt" "NS == $inode && NPROCS == 1")
45 if [[ "$pid" = "$PID" ]]; then
46 echo "$opt: pid == PID"
48 echo "$opt: pid != PID"
50 ${TS_CMD_LSFD} -n --raw -o INODE
-Q "${expr}"
51 echo inode
: "${inode}"
52 ${TS_CMD_LSNS} -n --raw -o PID
-Q "NS == $inode && NPROCS == 1"
57 echo DONE
>&"${MKFDS[1]}"
61 if [ "$?" == "$EPERM" ]; then
62 ts_skip
"unshare(2) is not permitted on this platform"