123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357 |
- #!/bin/sh
- export ECHO="${ECHO:-echo}"
- myname=$(basename "$0")
- export CHUTNEY_ROUNDS=${CHUTNEY_ROUNDS:-1}
- export CHUTNEY_WARNINGS_IGNORE_EXPECTED=${CHUTNEY_WARNINGS_IGNORE_EXPECTED:-true}
- export CHUTNEY_WARNINGS_SUMMARY=${CHUTNEY_WARNINGS_SUMMARY:-true}
- export CHUTNEY_CONTROLLING_PID=${CHUTNEY_CONTROLLING_PID:-$$}
- export CHUTNEY_ALLOW_FAILURES=${CHUTNEY_ALLOW_FAILURES:-0}
- export CHUTNEY_DNS_CONF=${CHUTNEY_DNS_CONF:-/dev/null}
- UPDATE_YOUR_CHUTNEY="Please update your chutney using 'git pull'."
- until [ -z "$1" ]
- do
- case "$1" in
-
- --chutney-path)
- export CHUTNEY_PATH="$2"
- shift
- ;;
- --tor-path)
-
-
- export TOR_DIR="$2"
- shift
- ;;
- --tor)
-
- export CHUTNEY_TOR="$2"
- shift
- ;;
- --tor-gencert)
-
- export CHUTNEY_TOR_GENCERT="$2"
- shift
- ;;
- --debug)
- export CHUTNEY_DEBUG="yes"
- ;;
- --flavor|--flavour|--network-flavor|--network-flavour)
- export NETWORK_FLAVOUR="$2"
- shift
- ;;
-
-
- --start-time)
- export CHUTNEY_START_TIME="$2"
- shift
- ;;
-
-
- --delay|--sleep|--bootstrap-time|--time|--verify-time)
-
-
- export CHUTNEY_BOOTSTRAP_TIME="$2"
- shift
- ;;
-
-
- --stop-time)
- export CHUTNEY_STOP_TIME="$2"
- shift
- ;;
-
-
- --controlling-pid)
- export CHUTNEY_CONTROLLING_PID="$2"
- shift
- ;;
-
-
- --data|--data-bytes|--data-byte|--bytes|--byte)
- export CHUTNEY_DATA_BYTES="$2"
- shift
- ;;
-
- --connections|--connection|--connection-count|--count)
- export CHUTNEY_CONNECTIONS="$2"
- shift
- ;;
-
- --rounds)
- export CHUTNEY_ROUNDS="$2"
- shift
- ;;
-
-
-
- --hs-multi-client|--hs-multi-clients|--hs-client|--hs-clients)
- export CHUTNEY_HS_MULTI_CLIENT="$2"
- shift
- ;;
-
- --ipv4|--v4|-4|--ip)
- export CHUTNEY_LISTEN_ADDRESS="$2"
- shift
- ;;
-
-
- --ipv6|--v6|-6)
- export CHUTNEY_LISTEN_ADDRESS_V6="$2"
- shift
- ;;
-
-
- --dns-conf)
- export CHUTNEY_DNS_CONF="$2"
- shift
- ;;
-
-
- --offline)
- export CHUTNEY_DNS_CONF="/dev/null"
- ;;
-
- --dns-conf-default)
- export CHUTNEY_DNS_CONF=""
- ;;
-
-
-
- --all-warnings)
- export CHUTNEY_WARNINGS_IGNORE_EXPECTED=false
- export CHUTNEY_WARNINGS_SUMMARY=false
- ;;
-
- --only-warnings)
- export CHUTNEY_WARNINGS_ONLY=true
- ;;
-
- --no-warnings)
- export CHUTNEY_WARNINGS_SKIP=true
- ;;
-
-
- --coverage)
- export USE_COVERAGE_BINARY=true
- ;;
-
- --dry-run)
-
- export NETWORK_DRY_RUN=true
- ;;
-
- --net-dir)
- export CHUTNEY_DATA_DIR="$2"
- shift
- ;;
-
- --allow-failures)
- export CHUTNEY_ALLOW_FAILURES="$2"
- shift
- ;;
-
- --quiet)
- export ECHO=true
- ;;
-
- *)
- $ECHO "$myname: Sorry, I don't know what to do with '$1'."
- $ECHO "$UPDATE_YOUR_CHUTNEY"
-
- if [ "$NETWORK_DRY_RUN" != true ]; then
- exit 1
- fi
- ;;
- esac
- shift
- done
- if [ "$CHUTNEY_WARNINGS_ONLY" != true ]; then
- $ECHO "$myname: using CHUTNEY_DNS_CONF '$CHUTNEY_DNS_CONF'"
- fi
- if [ ! -d "$TOR_DIR" ]; then
- if [ -d "$BUILDDIR/src/tools" ]; then
-
-
- $ECHO "$myname: \$TOR_DIR not set, trying \$BUILDDIR"
- export TOR_DIR="$BUILDDIR"
- elif [ -d "$PWD/src/tools" ]; then
-
-
- $ECHO "$myname: \$TOR_DIR not set, trying \$PWD"
- export TOR_DIR="$PWD"
- elif [ -d "$PWD/../tor" ] && [ -d "$PWD/../tor/src/tools" ]; then
-
-
- $ECHO "$myname: \$TOR_DIR not set, trying \$PWD/../tor"
- export TOR_DIR="$PWD/../tor"
- else
- $ECHO "$myname: no \$TOR_DIR, chutney will use \$CHUTNEY_TOR and \$CHUTNEY_TOR_GENCERT as tor binary paths, or search \$PATH for tor binary names"
- unset TOR_DIR
- fi
- fi
- if [ -d "$TOR_DIR" ]; then
- if [ -d "$TOR_DIR/src/app" ] && [ -d "$TOR_DIR/src/or" ]; then
- $ECHO "$myname: \$TOR_DIR has a Tor 0.3.5 or later build directory, and a Tor 0.3.4 or earlier build directory"
- $ECHO "$myname: Please remove $TOR_DIR/src/app or $TOR_DIR/src/or, or set \$CHUTNEY_TOR"
- exit 1
- elif [ -d "$TOR_DIR/src/app" ]; then
- $ECHO "$myname: \$TOR_DIR is a Tor 0.3.5 or later build directory"
- TOR_APP_DIR="$TOR_DIR/src/app"
- elif [ -d "$TOR_DIR/src/or" ]; then
- $ECHO "$myname: \$TOR_DIR is a Tor 0.3.4 or earlier build directory"
- TOR_APP_DIR="$TOR_DIR/src/or"
- else
- $ECHO "$myname: \$TOR_DIR has no src/app or src/or, looking elsewhere"
- unset TOR_DIR
- fi
- fi
- if [ -d "$PWD/$TOR_DIR" ] && [ -d "$PWD/$TOR_APP_DIR" ] && \
- [ -d "$PWD/$TOR_DIR/src/tools" ]; then
- export TOR_DIR="$PWD/$TOR_DIR"
- export TOR_APP_DIR="$PWD/$TOR_APP_DIR"
- fi
- TOOLS_DIR=$(dirname "$0")
- if [ ! -d "$CHUTNEY_PATH" ] || [ ! -x "$CHUTNEY_PATH/chutney" ] || \
- [ ! -f "$CHUTNEY_PATH/chutney" ]; then
- if [ -x "$PWD/chutney" ] && [ -f "$PWD/chutney" ]; then
- $ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$PWD"
- export CHUTNEY_PATH="$PWD"
- elif [ -d "$TOOLS_DIR/.." ] && \
- [ -x "$TOOLS_DIR)/../chutney" ] && \
- [ -f "$TOOLS_DIR/../chutney" ]; then
- $ECHO "$myname: \$CHUTNEY_PATH not valid, using this script's location"
- export CHUTNEY_PATH="$TOOLS_DIR/.."
- elif [ -d "$TOR_DIR" ] && \
- [ -d "$TOR_DIR/../chutney" ] && \
- [ -x "$TOR_DIR/../chutney/chutney" ] && \
- [ -f "$TOR_DIR/../chutney/chutney" ]; then
- $ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$TOR_DIR/../chutney"
- export CHUTNEY_PATH="$TOR_DIR/../chutney"
- else
-
-
- $ECHO "$myname: missing 'chutney' in \$CHUTNEY_PATH ($CHUTNEY_PATH)"
- $ECHO "$myname: Get chutney: git clone https://git.torproject.org/chutney.git"
- $ECHO "$myname: Set \$CHUTNEY_PATH to a non-standard location: export CHUTNEY_PATH=\`pwd\`/chutney"
- unset CHUTNEY_PATH
- exit 1
- fi
- fi
- if [ -d "$PWD/$CHUTNEY_PATH" ] && [ -x "$PWD/$CHUTNEY_PATH/chutney" ]; then
- export CHUTNEY_PATH="$PWD/$CHUTNEY_PATH"
- fi
- tor_name=tor
- tor_gencert_name=tor-gencert
- if [ "$USE_COVERAGE_BINARY" = true ]; then
- tor_name=tor-cov
- fi
- if [ -d "$TOR_DIR" ]; then
- $ECHO "$myname: Setting \$CHUTNEY_TOR and \$CHUTNEY_TOR_GENCERT based on TOR_DIR: '$TOR_DIR'"
-
- export CHUTNEY_TOR="$TOR_APP_DIR/$tor_name"
- export CHUTNEY_TOR_GENCERT="$TOR_DIR/src/tools/$tor_gencert_name"
- else
- if [ -x "$CHUTNEY_TOR" ]; then
- $ECHO "$myname: Assuming \$CHUTNEY_TOR is a path to a binary"
- elif [ -n "$CHUTNEY_TOR" ]; then
- $ECHO "$myname: Assuming \$CHUTNEY_TOR is a binary name in \$PATH"
- else
- $ECHO "$myname: Setting \$CHUTNEY_TOR to the standard binary name in \$PATH"
- export CHUTNEY_TOR="$tor_name"
- fi
- if [ -x "$CHUTNEY_TOR_GENCERT" ]; then
- $ECHO "$myname: Assuming \$CHUTNEY_TOR_GENCERT is a path to a binary"
- elif [ -n "$CHUTNEY_TOR_GENCERT" ]; then
- $ECHO "$myname: Assuming \$CHUTNEY_TOR_GENCERT is a binary name in \$PATH"
- else
- $ECHO "$myname: Setting \$CHUTNEY_TOR_GENCERT to the standard binary name in \$PATH"
- export CHUTNEY_TOR_GENCERT="$tor_gencert_name"
- fi
- fi
- $ECHO "$myname: Using \$CHUTNEY_TOR: '$CHUTNEY_TOR' and \$CHUTNEY_TOR_GENCERT: '$CHUTNEY_TOR_GENCERT'"
- export NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-"bridges+hs-v2"}
- export CHUTNEY_NETWORK="$CHUTNEY_PATH/networks/$NETWORK_FLAVOUR"
- export WARNING_COMMAND="$CHUTNEY_PATH/tools/warnings.sh"
- if [ "$CHUTNEY_WARNINGS_SKIP" = true ]; then
- export WARNINGS=true
- else
- export WARNINGS="$WARNING_COMMAND"
- fi
- if [ "$NETWORK_DRY_RUN" = true ] || [ "$CHUTNEY_WARNINGS_ONLY" = true ]; then
- if [ "$CHUTNEY_WARNINGS_ONLY" = true ]; then
- "$WARNINGS"
- fi
- $ECHO "Finished dry run"
-
-
- exit 0
- fi
- n_attempts=0
- max_attempts=$((CHUTNEY_ALLOW_FAILURES+1))
- while [ "$n_attempts" -lt "$max_attempts" ]; do
- n_attempts=$((n_attempts+1))
- $ECHO "==== Running tests: attempt $n_attempts/$max_attempts"
- if "$CHUTNEY_PATH/tools/test-network-impl.sh"; then
- $ECHO "==== Chutney succeeded after $n_attempts attempt(s)."
- exit 0
- fi
- done
- $ECHO "Chutney failed $n_attempts times; we may have a problem here."
- exit 1
|