Debian Codegraph @

debian/checks/09-zflag

raw
1 PORT=$(random_port)
2 PIPES="y" netcat_listen ${NETCAT_DGRAM:+-u} "127.0.0.1" $PORT
3
4 IN="$TEMPDIR/client.in" OUT="$TEMPDIR/client.out" ERR="$TEMPDIR/client.err"
5 mkfifo -- "$IN"
6 $NC -${NETCAT_DGRAM:+u}z "127.0.0.1" $PORT <"$IN" >"$OUT" 2>"$ERR" {LISTEN_IN}>&- {LISTEN_OUT}<&- & CLIENT_PID=$!
7 exec {CONNECT_IN}>"$IN"
8 rm -f -- "$IN"
9
10 ( echo "foobar" >&$CONNECT_IN ) || true # client stdin should be ignored
11
12 exec {LISTEN_IN}>&- {CONNECT_IN}>&-
13 wait $CLIENT_PID
14 ${NETCAT_DGRAM:+kill_and_}wait $PID
15 if read -r _ <&$LISTEN_OUT; then
16 printf "ERROR at line %d: Client didn't ignore its standard input\\n" $LINENO >&2
17 exit 1
18 fi
19
20 test -f "$OUT" -a -f "$ERR"
21 test ! -s "$OUT"
22 sed -ri "/^Connection to 127\\.0\\.0\\.1 $PORT port \\[[^]]+\\] succeeded!$/d" -- "$ERR"
23 test ! -s "$ERR"
24
25
26 #######################################################################
27 # without server
28
29 rv=0
30 $NC -${NETCAT_DGRAM:+u}z "127.0.0.1" $PORT >"$OUT" 2>"$ERR" || rv=$?
31 if [ -z "$NETCAT_DGRAM" ]; then
32 # XXX doesn't work with UDP (need to send IO to report status)
33 test $rv -eq 1
34 fi
35 test ! -s "$OUT"
36 test ! -s "$ERR"
37
38 # vim: set filetype=bash :