Skip to content

Commit fd9c78d

Browse files
Merge pull request #6721 from bandi13/udp_proxy-fixes
Udp proxy fixes
2 parents 205cdb1 + c4f91cd commit fd9c78d

1 file changed

Lines changed: 17 additions & 4 deletions

File tree

scripts/dtls.test

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,26 @@
55
WOLFSSL_ROOT=${WOLFSSL_ROOT:-$(pwd)}
66
UDP_PROXY_BIN=${UDP_PROXY_BIN:-"udp_proxy"}
77
DTLS_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':
910
DO_EXTENDED_SERVER_PERMUTATION_TEST=${DO_EXTENDED_SERVER_PERMUTATION_TEST:-0}
1011
DO_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+
1628
cleanup () {
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

7688
test_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
@@ -127,7 +139,7 @@ EOF
127139
}
128140

129141
echo "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 &
131143
TCPDUMP_PID=$!
132144
sleep 0.5
133145

@@ -153,4 +165,5 @@ else
153165
echo -e "\nThere were $NUM_TESTS_FAILED failures out of $NUM_TESTS_RUN tests\n"
154166
fi
155167

168+
echo "The script ran for $SECONDS seconds"
156169
exit $NUM_TESTS_FAILED

0 commit comments

Comments
 (0)