2017-03-01 01:21:07 +01:00
|
|
|
#! /bin/sh
|
|
|
|
|
|
|
|
# use bash if it is available, as this script doesn't work well in non-bash sh
|
|
|
|
# this will be fixed in #19699
|
|
|
|
# there is no simple, portable way of checking the name of the shell, so we
|
|
|
|
# exec bash even when sh is bash
|
|
|
|
if [ -x /bin/bash -a "$USING_BASH" != true ]; then
|
|
|
|
# only do this once
|
|
|
|
export USING_BASH=true
|
|
|
|
exec /bin/bash "$0" "$@"
|
|
|
|
fi
|
2013-06-05 15:48:57 +02:00
|
|
|
|
2016-07-17 14:15:48 +02:00
|
|
|
# Please do not modify this script, it has been moved to chutney/tools
|
|
|
|
|
2017-03-01 01:21:07 +01:00
|
|
|
export ECHO="${ECHO:-echo}"
|
|
|
|
export ECHO_N="${ECHO_N:-/bin/echo -n}"
|
2016-07-17 14:04:37 +02:00
|
|
|
|
|
|
|
# Output is prefixed with the name of the script
|
|
|
|
myname=$(basename $0)
|
2014-10-01 09:56:53 +02:00
|
|
|
|
2016-07-17 14:15:48 +02:00
|
|
|
# We need to find CHUTNEY_PATH, so that we can call the version of this script
|
|
|
|
# in chutney/tools. And we want to pass any arguments to that script as well.
|
|
|
|
# So we source this script, which processes its arguments to find CHUTNEY_PATH.
|
|
|
|
|
|
|
|
# Avoid recursively sourcing this script, and don't call the chutney version
|
|
|
|
# while recursing, either
|
|
|
|
if [ "$TEST_NETWORK_RECURSING" != true ]; then
|
|
|
|
# Process the arguments into environmental variables with this script
|
|
|
|
# to make sure $CHUTNEY_PATH is set
|
|
|
|
# When we switch to using test-network.sh in chutney/tools, --dry-run
|
|
|
|
# can be removed, because this script will find chutney, then pass all
|
|
|
|
# arguments to chutney's test-network.sh
|
|
|
|
export TEST_NETWORK_RECURSING=true
|
2017-03-01 01:21:07 +01:00
|
|
|
# passing arguments to a sourced script only works in bash
|
|
|
|
# this will be fixed in #19699
|
2016-07-17 14:15:48 +02:00
|
|
|
. "$0" --dry-run "$@"
|
|
|
|
|
|
|
|
# Call the chutney version of this script, if it exists, and we can find it
|
|
|
|
if [ -d "$CHUTNEY_PATH" -a -x "$CHUTNEY_PATH/tools/test-network.sh" ]; then
|
|
|
|
unset NETWORK_DRY_RUN
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: Calling newer chutney script \
|
2016-07-17 14:15:48 +02:00
|
|
|
$CHUTNEY_PATH/tools/test-network.sh"
|
|
|
|
"$CHUTNEY_PATH/tools/test-network.sh" "$@"
|
|
|
|
exit $?
|
|
|
|
else
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: This script has moved to chutney/tools."
|
|
|
|
$ECHO "$myname: Please update your chutney using 'git pull'."
|
2016-07-17 14:15:48 +02:00
|
|
|
# When we switch to using test-network.sh in chutney/tools, we should
|
|
|
|
# exit with a very loud failure here
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: Falling back to the old tor version of the script."
|
2016-07-17 14:15:48 +02:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2015-09-08 14:27:12 +02:00
|
|
|
until [ -z "$1" ]
|
2013-09-29 07:24:14 +02:00
|
|
|
do
|
2015-09-08 14:27:12 +02:00
|
|
|
case "$1" in
|
2013-09-29 07:24:14 +02:00
|
|
|
--chutney-path)
|
|
|
|
export CHUTNEY_PATH="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
--tor-path)
|
|
|
|
export TOR_DIR="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2016-07-17 14:15:48 +02:00
|
|
|
# When we switch to using test-network.sh in chutney/tools, only the
|
|
|
|
# --chutney-path and --tor-path arguments need to be processed by this
|
|
|
|
# script, everything else can be handled by chutney's test-network.sh
|
2015-03-22 09:41:05 +01:00
|
|
|
--flavor|--flavour|--network-flavor|--network-flavour)
|
2013-09-29 07:24:14 +02:00
|
|
|
export NETWORK_FLAVOUR="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2014-10-01 10:05:04 +02:00
|
|
|
--delay|--sleep|--bootstrap-time|--time)
|
|
|
|
export BOOTSTRAP_TIME="$2"
|
|
|
|
shift
|
|
|
|
;;
|
2015-07-06 08:59:15 +02:00
|
|
|
# Environmental variables used by chutney verify performance tests
|
|
|
|
# Send this many bytes per client connection (10 KBytes)
|
|
|
|
--data|--data-bytes|--data-byte|--bytes|--byte)
|
|
|
|
export CHUTNEY_DATA_BYTES="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
# Make this many connections per client (1)
|
|
|
|
# Note: If you create 7 or more connections to a hidden service from
|
2016-07-17 14:37:00 +02:00
|
|
|
# a single Tor 0.2.7 client, you'll likely get a verification failure due
|
|
|
|
# to #15937. This is fixed in 0.2.8.
|
2015-07-06 08:59:15 +02:00
|
|
|
--connections|--connection|--connection-count|--count)
|
|
|
|
export CHUTNEY_CONNECTIONS="$2"
|
|
|
|
shift
|
|
|
|
;;
|
|
|
|
# Make each client connect to each HS (0)
|
|
|
|
# 0 means a single client connects to each HS
|
|
|
|
# 1 means every client connects to every HS
|
|
|
|
--hs-multi-client|--hs-multi-clients|--hs-client|--hs-clients)
|
|
|
|
export CHUTNEY_HS_MULTI_CLIENT="$2"
|
|
|
|
shift
|
2015-08-03 19:23:58 +02:00
|
|
|
;;
|
|
|
|
--coverage)
|
2016-07-17 14:04:37 +02:00
|
|
|
export USE_COVERAGE_BINARY=true
|
2015-08-03 19:23:58 +02:00
|
|
|
;;
|
2016-07-17 14:08:31 +02:00
|
|
|
--dry-run)
|
|
|
|
# process arguments, but don't call any other scripts
|
|
|
|
export NETWORK_DRY_RUN=true
|
|
|
|
;;
|
2017-02-27 15:45:30 +01:00
|
|
|
--quiet)
|
|
|
|
export ECHO=true
|
|
|
|
export ECHO_N=true
|
|
|
|
;;
|
2013-09-29 07:24:14 +02:00
|
|
|
*)
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: Sorry, I don't know what to do with '$1'."
|
|
|
|
$ECHO "$myname: Maybe chutney's test-network.sh understands '$1'."
|
|
|
|
$ECHO "$myname: Please update your chutney using 'git pull', and set \
|
2016-07-17 14:08:31 +02:00
|
|
|
\$CHUTNEY_PATH"
|
|
|
|
# continue processing arguments during a dry run
|
|
|
|
if [ "$NETWORK_DRY_RUN" != true ]; then
|
|
|
|
exit 2
|
|
|
|
fi
|
2013-09-29 07:24:14 +02:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
2013-06-05 15:48:57 +02:00
|
|
|
|
2016-07-17 14:04:37 +02:00
|
|
|
# optional: $TOR_DIR is the tor build directory
|
|
|
|
# it's used to find the location of tor binaries
|
|
|
|
# if it's not set:
|
|
|
|
# - set it ro $BUILDDIR, or
|
|
|
|
# - if $PWD looks like a tor build directory, set it to $PWD, or
|
|
|
|
# - unset $TOR_DIR, and let chutney fall back to finding tor binaries in $PATH
|
|
|
|
if [ ! -d "$TOR_DIR" ]; then
|
|
|
|
if [ -d "$BUILDDIR/src/or" -a -d "$BUILDDIR/src/tools" ]; then
|
|
|
|
# Choose the build directory
|
|
|
|
# But only if it looks like one
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$TOR_DIR not set, trying \$BUILDDIR"
|
2016-07-17 14:04:37 +02:00
|
|
|
export TOR_DIR="$BUILDDIR"
|
|
|
|
elif [ -d "$PWD/src/or" -a -d "$PWD/src/tools" ]; then
|
|
|
|
# Guess the tor directory is the current directory
|
|
|
|
# But only if it looks like one
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$TOR_DIR not set, trying \$PWD"
|
2016-07-17 14:04:37 +02:00
|
|
|
export TOR_DIR="$PWD"
|
|
|
|
else
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: no \$TOR_DIR, chutney will use \$PATH for tor binaries"
|
2016-07-17 14:04:37 +02:00
|
|
|
unset TOR_DIR
|
|
|
|
fi
|
|
|
|
fi
|
2015-09-01 16:52:30 +02:00
|
|
|
|
2016-07-17 14:04:37 +02:00
|
|
|
# mandatory: $CHUTNEY_PATH is the path to the chutney launch script
|
|
|
|
# if it's not set:
|
|
|
|
# - if $PWD looks like a chutney directory, set it to $PWD, or
|
|
|
|
# - set it based on $TOR_DIR, expecting chutney to be next to tor, or
|
|
|
|
# - fail and tell the user how to clone the chutney repository
|
|
|
|
if [ ! -d "$CHUTNEY_PATH" -o ! -x "$CHUTNEY_PATH/chutney" ]; then
|
|
|
|
if [ -x "$PWD/chutney" ]; then
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$PWD"
|
2016-07-17 14:04:37 +02:00
|
|
|
export CHUTNEY_PATH="$PWD"
|
|
|
|
elif [ -d "$TOR_DIR" -a -d "$TOR_DIR/../chutney" -a \
|
|
|
|
-x "$TOR_DIR/../chutney/chutney" ]; then
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: \$CHUTNEY_PATH not valid, trying \$TOR_DIR/../chutney"
|
2016-07-17 14:04:37 +02:00
|
|
|
export CHUTNEY_PATH="$TOR_DIR/../chutney"
|
|
|
|
else
|
|
|
|
# TODO: work out how to package and install chutney,
|
|
|
|
# so users can find it in $PATH
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: missing 'chutney' in \$CHUTNEY_PATH ($CHUTNEY_PATH)"
|
|
|
|
$ECHO "$myname: Get chutney: git clone https://git.torproject.org/\
|
2015-09-01 16:52:30 +02:00
|
|
|
chutney.git"
|
2017-02-27 15:45:30 +01:00
|
|
|
$ECHO "$myname: Set \$CHUTNEY_PATH to a non-standard location: export \
|
2016-07-17 14:04:37 +02:00
|
|
|
CHUTNEY_PATH=\`pwd\`/chutney"
|
|
|
|
unset CHUTNEY_PATH
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
2015-08-03 19:23:58 +02:00
|
|
|
|
2016-07-17 14:15:48 +02:00
|
|
|
# When we switch to using test-network.sh in chutney/tools, this comment and
|
|
|
|
# everything below it can be removed
|
|
|
|
|
2013-09-29 07:24:14 +02:00
|
|
|
# For picking up the right tor binaries.
|
2016-07-17 14:04:37 +02:00
|
|
|
# If these varibles aren't set, chutney looks for tor binaries in $PATH
|
|
|
|
if [ -d "$TOR_DIR" ]; then
|
|
|
|
tor_name=tor
|
|
|
|
tor_gencert_name=tor-gencert
|
|
|
|
if [ "$USE_COVERAGE_BINARY" = true ]; then
|
|
|
|
tor_name=tor-cov
|
|
|
|
fi
|
|
|
|
export CHUTNEY_TOR="${TOR_DIR}/src/or/${tor_name}"
|
|
|
|
export CHUTNEY_TOR_GENCERT="${TOR_DIR}/src/tools/${tor_gencert_name}"
|
2015-08-03 19:23:58 +02:00
|
|
|
fi
|
|
|
|
|
2016-07-17 14:04:37 +02:00
|
|
|
# Set the variables for the chutney network flavour
|
|
|
|
export NETWORK_FLAVOUR=${NETWORK_FLAVOUR:-"bridges+hs"}
|
|
|
|
export CHUTNEY_NETWORK=networks/$NETWORK_FLAVOUR
|
|
|
|
|
2016-07-17 14:08:31 +02:00
|
|
|
# And finish up if we're doing a dry run
|
2016-07-17 14:15:48 +02:00
|
|
|
if [ "$NETWORK_DRY_RUN" = true ]; then
|
|
|
|
# we can't exit here, it breaks argument processing
|
2017-02-27 06:11:22 +01:00
|
|
|
# this only works in bash: return semantics are shell-specific
|
2017-03-01 01:21:07 +01:00
|
|
|
# this will be fixed in #19699
|
2017-02-27 06:11:22 +01:00
|
|
|
return 2>/dev/null || exit
|
2016-07-17 14:08:31 +02:00
|
|
|
fi
|
|
|
|
|
2016-07-17 14:04:37 +02:00
|
|
|
cd "$CHUTNEY_PATH"
|
2017-02-27 16:02:32 +01:00
|
|
|
./tools/bootstrap-network.sh $NETWORK_FLAVOUR || exit 3
|
2013-06-05 15:48:57 +02:00
|
|
|
|
|
|
|
# Sleep some, waiting for the network to bootstrap.
|
|
|
|
# TODO: Add chutney command 'bootstrap-status' and use that instead.
|
2015-09-09 19:23:32 +02:00
|
|
|
BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-35}
|
2014-10-01 09:56:53 +02:00
|
|
|
$ECHO_N "$myname: sleeping for $BOOTSTRAP_TIME seconds"
|
2013-06-05 15:48:57 +02:00
|
|
|
n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do
|
2014-10-01 09:56:53 +02:00
|
|
|
sleep 1; n=$(expr $n - 1); $ECHO_N .
|
2017-02-27 15:45:30 +01:00
|
|
|
done; $ECHO ""
|
2013-06-05 15:48:57 +02:00
|
|
|
./chutney verify $CHUTNEY_NETWORK
|
2014-10-05 00:59:27 +02:00
|
|
|
VERIFY_EXIT_STATUS=$?
|
2014-10-04 05:18:56 +02:00
|
|
|
# work around a bug/feature in make -j2 (or more)
|
|
|
|
# where make hangs if any child processes are still alive
|
|
|
|
./chutney stop $CHUTNEY_NETWORK
|
2014-10-05 00:59:27 +02:00
|
|
|
exit $VERIFY_EXIT_STATUS
|