Debian Codegraph @

tests/ts/lsfd/option-inet-udplite

raw
1 #!/usr/bin/env bash
2 #
3 # Copyright (C) 2026 Masatake YAMATO <[email protected]>
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 #
17 TS_TOPDIR="${0%/*}/../.."
18
19 # UDPLITE was retired in Linux 7.1-rc1.
20 # We move UDP-Lite related test parts here from the
21 # option-inet test case. So we can make UDP-Lite related
22 # test parts optional where UDPLITE is not available.
23 TS_DESC="--inet option for UDPLITE"
24
25
26 . "$TS_TOPDIR"/functions.sh
27
28 ts_init "$*"
29 ts_skip_qemu_user
30 ts_skip_docker
31
32 ts_check_test_command "$TS_CMD_LSFD"
33 ts_check_test_command "$TS_HELPER_MKFDS"
34 ts_check_ipv6
35
36 ts_check_prog "mkfifo"
37
38 ts_cd "$TS_OUTDIR"
39
40 . "$TS_SELF/lsfd-functions.bash"
41
42 readonly -a UDP_ARGS=(3 4
43 lite=1
44 server-port=34567
45 client-port=23456
46 server-do-bind=1
47 client-do-bind=1
48 client-do-connect=1)
49
50 lsfd_check_udp_lite 4
51 lsfd_check_udp_lite 6
52
53 FIFO=./test_mkfds-option-inet-udplite.fifo
54 {
55 rm -f "${FIFO}"
56 if ! mkfifo "${FIFO}"; then
57 ts_finalize "failed in creating a fifo"
58 fi
59
60 "$TS_HELPER_MKFDS" -X ro-regular-file 3 file=/etc/passwd > "${FIFO}" &
61 if ! read PID0 < "${FIFO}"; then
62 rm "${FIFO}"
63 ts_finalize "$TS_HELPER_MKFDS ro-regular-file...doesn't report its pid"
64 fi
65
66 "$TS_HELPER_MKFDS" -X udp "${UDP_ARGS[@]}" > "${FIFO}" &
67 if ! read PID1 < "${FIFO}"; then
68 kill -CONT "${PID0}"
69 wait "${PID0}"
70 rm "${FIFO}"
71 ts_finalize "$TS_HELPER_MKFDS udp lite=1...doesn't report its pid"
72 fi
73
74 "$TS_HELPER_MKFDS" -X udp6 "${UDP_ARGS[@]}" > "${FIFO}" &
75 if ! read PID2 < "${FIFO}"; then
76 kill -CONT "${PID0}" "${PID1}"
77 wait "${PID0}" "${PID1}"
78 rm "${FIFO}"
79 ts_finalize "$TS_HELPER_MKFDS udp6 lite=1...doesn't report its pid"
80 fi
81
82 OPT='--inet'
83 echo "# $OPT"
84 ${TS_CMD_LSFD} -n \
85 $OPT \
86 -o ASSOC,TYPE,NAME \
87 -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2)"
88
89 OPT='--inet=4'
90 echo "# $OPT"
91 ${TS_CMD_LSFD} -n \
92 $OPT \
93 -o ASSOC,TYPE,NAME \
94 -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2)"
95
96 OPT='--inet=6'
97 echo "# $OPT"
98 ${TS_CMD_LSFD} -n \
99 $OPT \
100 -o ASSOC,TYPE,NAME \
101 -Q "(PID == $PID0) or (PID == $PID1) or (PID == $PID2)"
102
103 kill -CONT "${PID0}" "${PID1}" "${PID2}"
104 if ! wait "${PID0}" "${PID1}" "${PID2}"; then
105 echo PID0: ${PID0}
106 echo PID1: ${PID1}
107 echo PID2: ${PID2}
108 fi
109
110 rm "${FIFO}"
111 } > "$TS_OUTPUT" 2>&1
112
113 ts_finalize