Debian Codegraph @

tests/inet

raw symbols SCIP
1 #!/bin/bash
2
3 set -e
4
5 if [ -z "$(command -v python3)" ]; then
6 echo 'No python3 available, skipping this test'
7 exit
8 fi
9
10 test_random_port="$(( (RANDOM % 10000) + 13131 ))"
11
12 : "${TEST_SLEEPTIME:=0.1}"
13 : "${TEST_ADDRESS:=127.0.0.1}"
14 : "${TEST_PORT:=$test_random_port}"
15
16 SOCKET_ACTIVATE=${SOCKET_ACTIVATE:-socket-activate}
17
18 "$SOCKET_ACTIVATE" "--tcp:label=i-mellon:$TEST_ADDRESS/$TEST_PORT" "--udp:label=i-friend:$TEST_ADDRESS/$TEST_PORT" -- python3 "${PWD}/tests/test_python.py" &
19 jobpid="$(jobs -p)"
20 sleep "$TEST_SLEEPTIME"
21 if ! kill -0 "$jobpid"; then
22 echo "The $SOCKET_ACTIVATE program exited before the first test" 1>&2
23 exit 1
24 fi
25
26 nc -4 -W1 "$TEST_ADDRESS" "$TEST_PORT" | diff -u - <(echo 'mellon')
27 sleep "$TEST_SLEEPTIME"
28 if kill -0 "$jobpid" 2>/dev/null; then
29 echo "The $SOCKET_ACTIVATE program did not exit after the first test" 1>&2
30 exit 1
31 fi
32
33 "$SOCKET_ACTIVATE" "--tcp:label=i-mellon:$TEST_ADDRESS/$TEST_PORT" "--udp:label=i-friend:$TEST_ADDRESS/$TEST_PORT" -- python3 "${PWD}/tests/test_python.py" &
34 jobpid="$(jobs -p)"
35 sleep "$TEST_SLEEPTIME"
36 if ! kill -0 "$jobpid"; then
37 echo "The $SOCKET_ACTIVATE program exited before the second test" 1>&2
38 exit 1
39 fi
40
41 # UDP needs a trigger
42 echo | nc -4 -W1 -u "$TEST_ADDRESS" "$TEST_PORT" | diff -u - <(echo 'friend')
43 sleep "$TEST_SLEEPTIME"
44 if kill -0 "$jobpid" 2>/dev/null; then
45 echo "The $SOCKET_ACTIVATE program did not exit after the second test" 1>&2
46 exit 1
47 fi