]> git.ipfire.org Git - thirdparty/util-linux.git/blame - tests/ts/lsfd/mkfds-netns
tests: (refactor (test_mkfds, lsfd)) use TS_EXIT_NOTSUPP instead of EXIT_ENOSYS
[thirdparty/util-linux.git] / tests / ts / lsfd / mkfds-netns
CommitLineData
c5eb81b3
MY
1#!/bin/bash
2#
3# Copyright (C) 2022 Masatake YAMATO <yamato@redhat.com>
4#
5# This file is part of util-linux.
6#
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.
11#
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.
16#
17TS_TOPDIR="${0%/*}/../.."
18TS_DESC="netns associated with a fd"
19
20. "$TS_TOPDIR"/functions.sh
21ts_init "$*"
22ts_skip_nonroot
d53284bb 23ts_skip_docker
c5eb81b3 24
7b061401 25. "$TS_SELF/lsfd-functions.bash"
c5eb81b3
MY
26ts_check_test_command "$TS_CMD_LSFD"
27ts_check_test_command "$TS_HELPER_MKFDS"
28
29ts_cd "$TS_OUTDIR"
30
31PID=
32FD=3
33NAME_FD=
34NAME_NS=
35INO_FD=
36INO_NS=
37{
38 coproc MKFDS { "$TS_HELPER_MKFDS" netns "$FD"; }
39 if read -r -u "${MKFDS[0]}" PID; then
40 "${TS_CMD_LSFD}" -n -oNS.TYPE -p "${PID}" -Q "(FD == $FD)"
41 NAME_FD=$("${TS_CMD_LSFD}" -n -oNS.NAME -p "${PID}" -Q "(FD == $FD)")
42 NAME_NS=$("${TS_CMD_LSFD}" -n -oNS.NAME -p "${PID}" -Q '(ASSOC == "net")')
43 INO_FD=$( "${TS_CMD_LSFD}" -n -oINODE -p "${PID}" -Q "(FD == $FD)")
44 INO_NS=$( "${TS_CMD_LSFD}" -n -oINODE -p "${PID}" -Q '(ASSOC == "net")')
45
55a9ad3e
MY
46 if [[ "$NAME_FD" = "$NAME_NS" ]]; then
47 echo "NAME_FD" == "NAME_NS": $?
48 else
49 echo "NAME_FD: $NAME_FD" == "NAME_NS: $NAME_NS": $?
50 fi
c5eb81b3 51
55a9ad3e
MY
52 if [[ "$NAME_FD" = "net:[$INO_FD]" ]]; then
53 echo "NAME_FD" == "net:[INO_FD]": $?
54 else
55 echo "NAME_FD: $NAME_FD" == "net:[INO_FD: $INO_FD]": $?
56 fi
c5eb81b3 57
55a9ad3e
MY
58 if [[ "$NAME_FD" = "net:[$INO_NS]" ]]; then
59 echo "NAME_FD" == "net:[INO_NS]": $?
60 else
61 echo "NAME_FD: $NAME_FD" == "net:[INO_NS: $INO_NS]": $?
62 fi
c5eb81b3 63
0fec4965 64 echo DONE >&"${MKFDS[1]}"
c5eb81b3
MY
65 fi
66 wait "${MKFDS_PID}"
67} > "$TS_OUTPUT" 2>&1
73a0eecf 68if [ "$?" == "$TS_EXIT_NOTSUPP" ]; then
7b061401
MY
69 ts_skip "ioctl(fd, SIOCGSKNS) is not available"
70fi
c5eb81b3
MY
71
72ts_finalize