dtlscid.test 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. #!/bin/bash
  2. set -e
  3. # if we can, isolate the network namespace to eliminate port collisions.
  4. if [[ -n "$NETWORK_UNSHARE_HELPER" ]]; then
  5. if [[ -z "$NETWORK_UNSHARE_HELPER_CALLED" ]]; then
  6. export NETWORK_UNSHARE_HELPER_CALLED=yes
  7. exec "$NETWORK_UNSHARE_HELPER" "$0" "$@" || exit $?
  8. fi
  9. elif [ "${AM_BWRAPPED-}" != "yes" ]; then
  10. bwrap_path="$(command -v bwrap)"
  11. if [ -n "$bwrap_path" ]; then
  12. export AM_BWRAPPED=yes
  13. exec "$bwrap_path" --unshare-net --dev-bind / / "$0" "$@"
  14. fi
  15. unset AM_BWRAPPED
  16. fi
  17. cleanup () {
  18. echo "Cleaning up..."
  19. if [ ! -z "$SERVER_PID" ];then
  20. echo "Killing server $SERVER_PID"
  21. kill $SERVER_PID
  22. fi
  23. }
  24. trap cleanup err exit
  25. CCID="AA"
  26. SCID="BB"
  27. HEXCID=$(printf $CCID | od -An -tx1 | tr -d ' \n')
  28. HEXSCID=$(printf $SCID | od -An -tx1 | tr -d ' \n')
  29. WOLFSSL_ROOT=$(pwd)
  30. test_cid () {
  31. echo "Running test_cid"
  32. SERVER_FILE=$(mktemp)
  33. CLIENT_FILE=$(mktemp)
  34. $WOLFSSL_ROOT/examples/server/server -v4 -u --cid $SCID 1> $SERVER_FILE &
  35. SERVER_PID=$!
  36. sleep 0.2
  37. $WOLFSSL_ROOT/examples/client/client -v4 -u --cid $CCID 1> $CLIENT_FILE
  38. wait $SERVER_PID
  39. SERVER_PID=
  40. grep "Sending CID is ${HEXSCID}" $CLIENT_FILE > /dev/null
  41. grep "Sending CID is ${HEXCID}" $SERVER_FILE > /dev/null
  42. echo "test_cid has passed"
  43. }
  44. test_cid