55WOLFSSL_ROOT=${WOLFSSL_ROOT:- $(pwd)}
66UDP_PROXY_BIN=${UDP_PROXY_BIN:- " udp_proxy" }
77DTLS_VERSION=${DTLS_VERSION:- " -v4" }
8+ PCAP_FILENAME=${PCAP_FILENAME:- " dtls${DTLS_VERSION} .pcap" }
89# Additionally, you can add the following tests by setting it to '1':
910DO_EXTENDED_SERVER_PERMUTATION_TEST=${DO_EXTENDED_SERVER_PERMUTATION_TEST:- 0}
1011DO_DELAY_TEST=${DO_DELAY_TEST:- 0}
1112
1213# An example use would be: DTLS_VERSION=-v3 scripts/dtls.test
14+ # Note the output also consists of a single PCAP file which has a set of
15+ # three packets (1-byte, strlen()-byte, 1-byte payload) deliniating each test.
1316
1417# set -x # enable debug output
1518
19+ # bwrap execution environment to avoid port conflicts
20+ if [ " ${AM_BWRAPPED-} " != " yes" ]; then
21+ bwrap_path=" $( command -v bwrap) "
22+ if [ -n " $bwrap_path " ]; then
23+ export AM_BWRAPPED=yes
24+ exec " $bwrap_path " --cap-add ALL --unshare-net --dev-bind / / " $0 " " $@ "
25+ fi
26+ fi
27+
1628cleanup () {
1729 echo
1830 echo " Cleaning up..."
@@ -62,7 +74,7 @@ run_test() { # usage: run_test "<testName>" "<udp-proxy args>" "<server args>" "
6274 UDP_PROXY_PID=$(( $! - 1 ))
6375 sleep 0.2
6476 # Wrap this command in a timeout so that a deadlock won't bring down the entire test
65- timeout -s KILL 5m stdbuf -oL -eL $WOLFSSL_ROOT /examples/client/client -u -p$PROXY_PORT $DTLS_VERSION $4 2>&1 | prepend " [client] "
77+ timeout -s KILL 1m stdbuf -oL -eL $WOLFSSL_ROOT /examples/client/client -u -p$PROXY_PORT $DTLS_VERSION $4 2>&1 | prepend " [client] "
6678 if [ $? != 0 ]; then
6779 echo " ***Test failed***"
6880 (( NUM_TESTS_FAILED++ ))
@@ -74,8 +86,8 @@ run_test() { # usage: run_test "<testName>" "<udp-proxy args>" "<server args>" "
7486}
7587
7688test_dropping_packets () {
77- for i in $( seq 3 11) ; do
78- run_test " Dropping ${i} th packet" " -d $i " " -Ta" " "
89+ for i in $( seq 0 11) ; do
90+ run_test " Dropping ${i} th packet" " -f $i " " -Ta" " "
7991 done
8092
8193 # dropping last ack would be client error as wolfssl_read doesn't support WANT_WRITE as returned error
127139}
128140
129141echo " Starting capture"
130- tcpdump -i lo -n port ${SERVER_PORT} -w ./dtls ${DTLS_VERSION} .pcap -U &
142+ tcpdump -i lo -n port ${SERVER_PORT} -w ${PCAP_FILENAME} -U &
131143TCPDUMP_PID=$!
132144sleep 0.5
133145
153165 echo -e " \nThere were $NUM_TESTS_FAILED failures out of $NUM_TESTS_RUN tests\n"
154166fi
155167
168+ echo " The script ran for $SECONDS seconds"
156169exit $NUM_TESTS_FAILED
0 commit comments