test-network.sh 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. #! /bin/sh
  2. ECHO_N="/bin/echo -n"
  3. use_coverage_binary=false
  4. until [ -z $1 ]
  5. do
  6. case $1 in
  7. --chutney-path)
  8. export CHUTNEY_PATH="$2"
  9. shift
  10. ;;
  11. --tor-path)
  12. export TOR_DIR="$2"
  13. shift
  14. ;;
  15. --flavor|--flavour|--network-flavor|--network-flavour)
  16. export NETWORK_FLAVOUR="$2"
  17. shift
  18. ;;
  19. --delay|--sleep|--bootstrap-time|--time)
  20. export BOOTSTRAP_TIME="$2"
  21. shift
  22. ;;
  23. # Environmental variables used by chutney verify performance tests
  24. # Send this many bytes per client connection (10 KBytes)
  25. --data|--data-bytes|--data-byte|--bytes|--byte)
  26. export CHUTNEY_DATA_BYTES="$2"
  27. shift
  28. ;;
  29. # Make this many connections per client (1)
  30. # Note: If you create 7 or more connections to a hidden service from
  31. # a single client, you'll likely get a verification failure due to
  32. # https://trac.torproject.org/projects/tor/ticket/15937
  33. --connections|--connection|--connection-count|--count)
  34. export CHUTNEY_CONNECTIONS="$2"
  35. shift
  36. ;;
  37. # Make each client connect to each HS (0)
  38. # 0 means a single client connects to each HS
  39. # 1 means every client connects to every HS
  40. --hs-multi-client|--hs-multi-clients|--hs-client|--hs-clients)
  41. export CHUTNEY_HS_MULTI_CLIENT="$2"
  42. shift
  43. ;;
  44. --coverage)
  45. use_coverage_binary=true
  46. ;;
  47. *)
  48. echo "Sorry, I don't know what to do with '$1'."
  49. exit 2
  50. ;;
  51. esac
  52. shift
  53. done
  54. TOR_DIR="${TOR_DIR:-$PWD}"
  55. NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-basic}
  56. CHUTNEY_NETWORK=networks/$NETWORK_FLAVOUR
  57. myname=$(basename $0)
  58. [ -d "$CHUTNEY_PATH" ] && [ -x "$CHUTNEY_PATH/chutney" ] || {
  59. echo "$myname: missing 'chutney' in CHUTNEY_PATH ($CHUTNEY_PATH)"
  60. exit 1
  61. }
  62. cd "$CHUTNEY_PATH"
  63. # For picking up the right tor binaries.
  64. tor_name=tor
  65. tor_gencert_name=tor-gencert
  66. if test "$use_coverage_binary" = true; then
  67. tor_name=tor-cov
  68. fi
  69. export CHUTNEY_TOR="${TOR_DIR}/src/or/${tor_name}"
  70. export CHUTNEY_TOR_GENCERT="${TOR_DIR}/src/tools/${tor_gencert_name}"
  71. ./tools/bootstrap-network.sh $NETWORK_FLAVOUR || exit 2
  72. # Sleep some, waiting for the network to bootstrap.
  73. # TODO: Add chutney command 'bootstrap-status' and use that instead.
  74. BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-25}
  75. $ECHO_N "$myname: sleeping for $BOOTSTRAP_TIME seconds"
  76. n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do
  77. sleep 1; n=$(expr $n - 1); $ECHO_N .
  78. done; echo ""
  79. ./chutney verify $CHUTNEY_NETWORK
  80. VERIFY_EXIT_STATUS=$?
  81. # work around a bug/feature in make -j2 (or more)
  82. # where make hangs if any child processes are still alive
  83. ./chutney stop $CHUTNEY_NETWORK
  84. exit $VERIFY_EXIT_STATUS