]>
Commit | Line | Data |
---|---|---|
d827da23 MY |
1 | #!/bin/bash |
2 | # | |
3 | # Copyright (C) 2021 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 | # | |
17 | TS_TOPDIR="${0%/*}/../.." | |
18 | TS_DESC="AF_UNIX socket pair created with socketpair(2)" | |
19 | ||
7155e836 | 20 | . "$TS_TOPDIR"/functions.sh |
d827da23 MY |
21 | ts_init "$*" |
22 | ||
b176a691 | 23 | . "$TS_SELF/lsfd-functions.bash" |
d827da23 MY |
24 | ts_check_test_command "$TS_CMD_LSFD" |
25 | ||
26 | ts_check_test_command "$TS_HELPER_MKFDS" | |
27 | ||
225154fe MY |
28 | ts_check_prog "sed" |
29 | ||
d827da23 MY |
30 | ts_cd "$TS_OUTDIR" |
31 | ||
b176a691 MY |
32 | lsfd_check_sockdiag "unix" |
33 | ||
d827da23 MY |
34 | PID= |
35 | FD0=3 | |
36 | FD1=4 | |
37 | EXPR= | |
38 | ||
98d1485d | 39 | ts_init_subtest "DGRAM" |
d827da23 | 40 | { |
a60ac11f | 41 | coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=DGRAM; } |
d827da23 MY |
42 | if read -u ${MKFDS[0]} PID; then |
43 | EXPR='(PID == '"${PID}"') and ((FD == '"$FD0"') or (FD == '"$FD1"'))' | |
e193602a | 44 | ${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-DGRAM/UNIX/' |
9be2c8b2 | 45 | echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]} |
d827da23 | 46 | |
0fec4965 | 47 | echo DONE >&"${MKFDS[1]}" |
d827da23 | 48 | fi |
98d1485d MY |
49 | } > "$TS_OUTPUT" 2>&1 |
50 | ||
51 | wait ${MKFDS_PID} | |
52 | ts_finalize_subtest | |
53 | ||
54 | ts_init_subtest "STREAM" | |
55 | { | |
56 | coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM; } | |
57 | if read -u ${MKFDS[0]} PID; then | |
58 | EXPR='(PID == '"${PID}"') and ((FD == '"$FD0"') or (FD == '"$FD1"'))' | |
59 | ${TS_CMD_LSFD} -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME -Q "${EXPR}" | sed -e 's/UNIX-STREAM/UNIX/' | |
60 | echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.PROTONAME': ${PIPESTATUS[0]} | |
61 | ||
62 | echo DONE >&"${MKFDS[1]}" | |
63 | fi | |
64 | } > "$TS_OUTPUT" 2>&1 | |
65 | ||
66 | wait ${MKFDS_PID} | |
67 | ts_finalize_subtest | |
d827da23 | 68 | |
b3563457 MY |
69 | mkfds_socketpair_stream_endpoint() |
70 | { | |
71 | ts_init_subtest "STREAM-ENDPOINT" | |
72 | if [ "$QEMU_USER" == "1" ]; then | |
73 | ts_skip_subtest "running under qemu-user emulation" | |
74 | return | |
75 | fi | |
76 | { | |
77 | coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM; } | |
78 | if read -u ${MKFDS[0]} PID; then | |
79 | EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')' | |
80 | ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS -Q "${EXPR}" | sed -e "s/${PID}/1/g" | |
81 | echo 'ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS': ${PIPESTATUS[0]} | |
82 | ||
83 | echo DONE >&"${MKFDS[1]}" | |
84 | fi | |
85 | } > "$TS_OUTPUT" 2>&1 | |
86 | ||
87 | wait ${MKFDS_PID} | |
88 | ts_finalize_subtest | |
89 | } | |
90 | ||
750ad7ce MY |
91 | mkfds_socketpair_stream_shutdown_state() |
92 | { | |
93 | ts_init_subtest "STREAM-SHUTDOWN-STATE" | |
94 | if [ "$QEMU_USER" == "1" ]; then | |
95 | ts_skip_subtest "running under qemu-user emulation" | |
96 | return | |
97 | fi | |
98 | { | |
99 | coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM halfclose=1; } | |
100 | if read -u ${MKFDS[0]} PID; then | |
101 | EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')' | |
102 | ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,SOCK.SHUTDOWN -Q "${EXPR}" | |
103 | echo 'ASSOC,MODE,STTYPE,SOURCE,SOCK.SHUTDOWN': ${PIPESTATUS[0]} | |
104 | ||
105 | echo DONE >&"${MKFDS[1]}" | |
106 | fi | |
107 | } > "$TS_OUTPUT" 2>&1 | |
108 | ||
109 | wait ${MKFDS_PID} | |
110 | ts_finalize_subtest | |
111 | } | |
112 | ||
b0dbcec0 MY |
113 | mkfds_socketpair_stream_endpoint_halfclose() |
114 | { | |
115 | ts_init_subtest "STREAM-ENDPOINT-halfclose" | |
116 | if [ "$QEMU_USER" == "1" ]; then | |
117 | ts_skip_subtest "running under qemu-user emulation" | |
118 | return | |
119 | fi | |
120 | { | |
121 | coproc MKFDS { "$TS_HELPER_MKFDS" socketpair $FD0 $FD1 socktype=STREAM halfclose=1; } | |
122 | if read -u ${MKFDS[0]} PID; then | |
123 | EXPR='(FD == '"$FD0"') or (FD == '"$FD1"')' | |
124 | ${TS_CMD_LSFD} -p "${PID}" -n -o ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS -Q "${EXPR}" | sed -e "s/${PID}/1/g" | |
125 | echo 'ASSOC,MODE,STTYPE,SOURCE,ENDPOINTS': ${PIPESTATUS[0]} | |
126 | ||
127 | echo DONE >&"${MKFDS[1]}" | |
128 | fi | |
129 | } > "$TS_OUTPUT" 2>&1 | |
130 | ||
131 | wait ${MKFDS_PID} | |
132 | ts_finalize_subtest | |
133 | } | |
134 | ||
b3563457 | 135 | mkfds_socketpair_stream_endpoint |
750ad7ce | 136 | mkfds_socketpair_stream_shutdown_state |
b0dbcec0 | 137 | mkfds_socketpair_stream_endpoint_halfclose |
b3563457 | 138 | |
d827da23 | 139 | ts_finalize |