From c82d7950ad9a1614a8f3929f53eaed572c9d9e2e Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Wed, 5 Jun 2013 15:48:57 +0200 Subject: Add make target test-network running traffic tests in a Chutney network. This implements ticket #8530. --- src/test/test-network.sh | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100755 src/test/test-network.sh (limited to 'src') diff --git a/src/test/test-network.sh b/src/test/test-network.sh new file mode 100755 index 0000000000..eaecded99c --- /dev/null +++ b/src/test/test-network.sh @@ -0,0 +1,23 @@ +#! /bin/sh + +CHUTNEY_BASEDIR=./chutney # FIXME +TOR_DIR=$(/bin/pwd)/src/or +NETWORK_FLAVOUR=basic +CHUTNEY_NETWORK=networks/$NETWORK_FLAVOUR +myname=$(/usr/bin/basename $0) + +cd $CHUTNEY_BASEDIR || { + echo "$myname: missing chutney dir: $CHUTNEY_BASEDIR" + exit 1 +} +PATH=$TOR_DIR:$PATH # For picking up the right tor binary. +./tools/bootstrap-network.sh $NETWORK_FLAVOUR || exit 2 + +# Sleep some, waiting for the network to bootstrap. +# TODO: Add chutney command 'bootstrap-status' and use that instead. +BOOTSTRAP_TIME=18 +echo -n "$myname: sleeping for $BOOTSTRAP_TIME seconds" +n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do + /bin/sleep 1; n=$(/usr/bin/expr $n - 1); echo -n . +done; echo "" +./chutney verify $CHUTNEY_NETWORK -- cgit v1.2.3-54-g00ecf From b567efcfff72f8ba5bb9ef2612318bc18f2b4880 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Wed, 5 Jun 2013 15:48:57 +0200 Subject: Use CHUTNEY_PATH to find Chutney. --- Makefile.am | 3 ++- src/test/test-network.sh | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/Makefile.am b/Makefile.am index e9976fa657..a736638e4b 100644 --- a/Makefile.am +++ b/Makefile.am @@ -60,7 +60,8 @@ doxygen: test: all ./src/test/test -# Requires a copy of Chutney in ./chutney +# Note that test-network requires a copy of Chutney in $CHUTNEY_PATH. +# Chutney can be cloned from https://git.torproject.org/chutney.git . test-network: all ./src/test/test-network.sh diff --git a/src/test/test-network.sh b/src/test/test-network.sh index eaecded99c..bbf76ede78 100755 --- a/src/test/test-network.sh +++ b/src/test/test-network.sh @@ -1,15 +1,17 @@ #! /bin/sh -CHUTNEY_BASEDIR=./chutney # FIXME +# NOTE: Requires Chutney in $CHUTNEY_PATH. + TOR_DIR=$(/bin/pwd)/src/or NETWORK_FLAVOUR=basic CHUTNEY_NETWORK=networks/$NETWORK_FLAVOUR myname=$(/usr/bin/basename $0) -cd $CHUTNEY_BASEDIR || { - echo "$myname: missing chutney dir: $CHUTNEY_BASEDIR" +[ -d "$CHUTNEY_PATH" ] && [ -x "$CHUTNEY_PATH/chutney" ] || { + echo "$myname: missing 'chutney' in CHUTNEY_PATH ($CHUTNEY_PATH)" exit 1 } +cd "$CHUTNEY_PATH" PATH=$TOR_DIR:$PATH # For picking up the right tor binary. ./tools/bootstrap-network.sh $NETWORK_FLAVOUR || exit 2 -- cgit v1.2.3-54-g00ecf From 538ca4153a1334179856866abf32975caf8daae4 Mon Sep 17 00:00:00 2001 From: Linus Nordberg Date: Wed, 5 Jun 2013 15:48:57 +0200 Subject: Invoke binaries in $PATH rather than by absolute path. That security measure costs more than it gives. So, keep your PATH sane and we can run this script on more than one system. --- src/test/test-network.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/test/test-network.sh b/src/test/test-network.sh index bbf76ede78..9146ae3ce4 100755 --- a/src/test/test-network.sh +++ b/src/test/test-network.sh @@ -2,10 +2,10 @@ # NOTE: Requires Chutney in $CHUTNEY_PATH. -TOR_DIR=$(/bin/pwd)/src/or +TOR_DIR=$(pwd)/src/or NETWORK_FLAVOUR=basic CHUTNEY_NETWORK=networks/$NETWORK_FLAVOUR -myname=$(/usr/bin/basename $0) +myname=$(basename $0) [ -d "$CHUTNEY_PATH" ] && [ -x "$CHUTNEY_PATH/chutney" ] || { echo "$myname: missing 'chutney' in CHUTNEY_PATH ($CHUTNEY_PATH)" @@ -20,6 +20,6 @@ PATH=$TOR_DIR:$PATH # For picking up the right tor binary. BOOTSTRAP_TIME=18 echo -n "$myname: sleeping for $BOOTSTRAP_TIME seconds" n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do - /bin/sleep 1; n=$(/usr/bin/expr $n - 1); echo -n . + sleep 1; n=$(expr $n - 1); echo -n . done; echo "" ./chutney verify $CHUTNEY_NETWORK -- cgit v1.2.3-54-g00ecf