diff --git a/scripts/dtlscid.test b/scripts/dtlscid.test index 95eb1be4a..ff05181e9 100755 --- a/scripts/dtlscid.test +++ b/scripts/dtlscid.test @@ -2,6 +2,21 @@ set -e +# if we can, isolate the network namespace to eliminate port collisions. +if [[ -n "$NETWORK_UNSHARE_HELPER" ]]; then + if [[ -z "$NETWORK_UNSHARE_HELPER_CALLED" ]]; then + export NETWORK_UNSHARE_HELPER_CALLED=yes + exec "$NETWORK_UNSHARE_HELPER" "$0" "$@" || exit $? + fi +elif [ "${AM_BWRAPPED-}" != "yes" ]; then + bwrap_path="$(command -v bwrap)" + if [ -n "$bwrap_path" ]; then + export AM_BWRAPPED=yes + exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@" + fi + unset AM_BWRAPPED +fi + cleanup () { echo "Cleaning up..." if [ ! -z "$SERVER_PID" ];then @@ -17,23 +32,20 @@ SCID="BB" HEXCID=$(printf $CCID | od -An -tx1 | tr -d ' \n') HEXSCID=$(printf $SCID | od -An -tx1 | tr -d ' \n') WOLFSSL_ROOT=$(pwd) -SERVER_PORT=11111 - -(killall lt-server || true) -(killall lt-client || true) test_cid () { - $WOLFSSL_ROOT/examples/server/server -v4 -u --cid $SCID 2>/tmp/serr 1>/tmp/sout & + echo "Running test_cid" + SERVER_FILE=$(mktemp) + CLIENT_FILE=$(mktemp) + $WOLFSSL_ROOT/examples/server/server -v4 -u --cid $SCID 1> $SERVER_FILE & SERVER_PID=$! sleep 0.2 - now=$(date +%s.%N) - $WOLFSSL_ROOT/examples/client/client -v4 -u --cid $CCID 2>/tmp/cerr 1>/tmp/cout - elapsed=$(echo $(date +%s.%N) - $now | bc) - echo "it took ${elapsed} sec(s)" >> /tmp/udp + $WOLFSSL_ROOT/examples/client/client -v4 -u --cid $CCID 1> $CLIENT_FILE wait $SERVER_PID SERVER_PID= - grep "Sending CID is ${HEXSCID}" < /tmp/cout - grep "Sending CID is ${HEXCID}" < /tmp/sout + grep "Sending CID is ${HEXSCID}" $CLIENT_FILE > /dev/null + grep "Sending CID is ${HEXCID}" $SERVER_FILE > /dev/null + echo "test_cid has passed" } test_cid diff --git a/scripts/include.am b/scripts/include.am index acf56980b..97aae0776 100644 --- a/scripts/include.am +++ b/scripts/include.am @@ -119,6 +119,10 @@ EXTRA_DIST += scripts/dtls13.test EXTRA_DIST += scripts/dtlscid.test endif +if BUILD_DTLS_CID +dist_noinst_SCRIPTS+= scripts/dtlscid.test +endif + EXTRA_DIST += scripts/bench/bench_functions.sh EXTRA_DIST += scripts/user_settings_asm.sh