From 6b118e1e1e17888beb2d61525c326ddd6bfd7933 Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Tue, 8 Sep 2015 22:27:12 +1000 Subject: [PATCH 1/4] Make test-network.sh more robust against arguments containing spaces --- src/test/test-network.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/test-network.sh b/src/test/test-network.sh index b5d7f7c42d..451a40afd0 100755 --- a/src/test/test-network.sh +++ b/src/test/test-network.sh @@ -3,9 +3,9 @@ ECHO_N="/bin/echo -n" use_coverage_binary=false -until [ -z $1 ] +until [ -z "$1" ] do - case $1 in + case "$1" in --chutney-path) export CHUTNEY_PATH="$2" shift From 5feae32f46b3f0cc3da93ece80163c1a994c83b9 Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Tue, 8 Sep 2015 22:27:59 +1000 Subject: [PATCH 2/4] Add "make test-network-all" to verify multiple test networks make test-network-all is Makefile target which verifies a series of test networks generated using test-network.sh and chutney. It runs IPv6 and mixed version test networks if the prerequisites are available. Each test network reports PASS, FAIL, or SKIP. Closes ticket 16953. Patch by "teor". Also adds "--hs-multi-client 1" option to TEST_NETWORK_FLAGS. This resolves #17012. Larger networks, such as bridges+hs, may fail until #16952 is merged. --- Makefile.am | 38 ++++++++++++++++++++++++++++++++++++-- src/test/include.am | 7 +++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index b5e71aad1e..68695ede0a 100644 --- a/Makefile.am +++ b/Makefile.am @@ -36,13 +36,16 @@ EXTRA_DIST+= \ if COVERAGE_ENABLED TEST_CFLAGS=-fno-inline -fprofile-arcs -ftest-coverage TEST_CPPFLAGS=-DTOR_UNIT_TESTS -DTOR_COVERAGE -TEST_NETWORK_FLAGS="--coverage" +TEST_NETWORK_FLAGS=--coverage --hs-multi-client 1 else TEST_CFLAGS= TEST_CPPFLAGS=-DTOR_UNIT_TESTS -TEST_NETWORK_FLAGS= +TEST_NETWORK_FLAGS=--hs-multi-client 1 endif +TEST_NETWORK_ALL_LOG_DIR=$(top_builddir)/test_network_log +TEST_NETWORK_ALL_DRIVER_FLAGS=--color-tests yes + #install-data-local: # $(INSTALL) -m 755 -d $(LOCALSTATEDIR)/lib/tor @@ -88,6 +91,36 @@ need-chutney-path: test-network: need-chutney-path all $(top_srcdir)/src/test/test-network.sh $(TEST_NETWORK_FLAGS) +# Run all available tests using automake's test-driver +# only run IPv6 tests if we can ping6 ::1 (localhost) +# some IPv6 tests will fail without an IPv6 DNS server (see #16971 and #17011) +# only run mixed tests if we have a tor-stable binary +# see #17015 for autodetection of different tor versions +test-network-all: need-chutney-path all test-driver + mkdir -p $(TEST_NETWORK_ALL_LOG_DIR) + @flavors="$(TEST_CHUTNEY_FLAVORS)"; \ + if ping6 -q -o ::1 >/dev/null 2>&1; then \ + echo "ping6 ::1 succeeded, running IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \ + flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \ + else \ + echo "ping6 ::1 failed, skipping IPv6 flavors: $(TEST_CHUTNEY_FLAVORS_IPV6)."; \ + skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_IPV6)"; \ + fi; \ + if command -v tor-stable >/dev/null 2>&1; then \ + echo "tor-stable found, running mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \ + flavors="$$flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \ + else \ + echo "tor-stable not found, skipping mixed flavors: $(TEST_CHUTNEY_FLAVORS_MIXED)."; \ + skip_flavors="$$skip_flavors $(TEST_CHUTNEY_FLAVORS_MIXED)"; \ + fi; \ + for f in $$skip_flavors; do \ + echo "SKIP: $$f"; \ + done; \ + for f in $$flavors; do \ + ./test-driver --test-name $$f --log-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.log --trs-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs $(TEST_NETWORK_ALL_DRIVER_FLAGS) $(top_srcdir)/src/test/test-network.sh --flavor $$f $(TEST_NETWORK_FLAGS); \ + done + @echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)." + need-stem-path: @if test ! -d "$$STEM_SOURCE_DIR"; then \ echo '$$STEM_SOURCE_DIR was not set.'; echo; \ @@ -173,3 +206,4 @@ mostlyclean-local: rm -f $(top_builddir)/src/*/*.gc{da,no} $(top_builddir)/src/*/*/*.gc{da,no} rm -rf $(HTML_COVER_DIR) rm -rf $(top_builddir)/doc/doxygen + rm -rf $(TEST_NETWORK_ALL_LOG_DIR) diff --git a/src/test/include.am b/src/test/include.am index ef2fd4fb8e..f7c0204832 100644 --- a/src/test/include.am +++ b/src/test/include.am @@ -8,6 +8,13 @@ endif TESTS += src/test/test src/test/test-slow src/test/test-memwipe \ src/test/test_workqueue src/test/test_keygen.sh $(TESTSCRIPTS) +# These flavors are run using automake's test-driver and test-network.sh +TEST_CHUTNEY_FLAVORS = basic-min bridges-min hs-min bridges+hs +# only run if we can ping6 ::1 (localhost) +TEST_CHUTNEY_FLAVORS_IPV6 = bridges+ipv6-min ipv6-exit-min +# only run if we can find a stable (or simply another) version of tor +TEST_CHUTNEY_FLAVORS_MIXED = mixed + ### This is a lovely feature, but it requires automake >= 1.12, and Tor ### doesn't require that yet. Below is a kludge to work around. ### From 60c6debda86e2ff6255f588d6b8e4e204a821bda Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Wed, 9 Sep 2015 03:06:01 +1000 Subject: [PATCH 3/4] make test-network-all exit 1 if any test network fails --- Makefile.am | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.am b/Makefile.am index 68695ede0a..c226113cc8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -118,8 +118,9 @@ test-network-all: need-chutney-path all test-driver done; \ for f in $$flavors; do \ ./test-driver --test-name $$f --log-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.log --trs-file $(TEST_NETWORK_ALL_LOG_DIR)/$$f.trs $(TEST_NETWORK_ALL_DRIVER_FLAGS) $(top_srcdir)/src/test/test-network.sh --flavor $$f $(TEST_NETWORK_FLAGS); \ - done - @echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)." + done; \ + echo "Log and result files are available in $(TEST_NETWORK_ALL_LOG_DIR)."; \ + ! grep -q FAIL test_network_log/*.trs need-stem-path: @if test ! -d "$$STEM_SOURCE_DIR"; then \ From 036966e3ec02d48ff3f69403430cb6d019ac5bcf Mon Sep 17 00:00:00 2001 From: "teor (Tim Wilson-Brown)" Date: Wed, 9 Sep 2015 04:21:07 +1000 Subject: [PATCH 4/4] Increase default boostrap time in test-network.sh Increase default boostrap time in test-network.sh to 30 seconds, for larger networks like bridges+ipv6+hs. This avoids the failure-hiding issues inherent in the retry approach in #16952. --- src/test/test-network.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/test-network.sh b/src/test/test-network.sh index 451a40afd0..576fbed03b 100755 --- a/src/test/test-network.sh +++ b/src/test/test-network.sh @@ -86,7 +86,7 @@ export CHUTNEY_TOR_GENCERT="${TOR_DIR}/src/tools/${tor_gencert_name}" # Sleep some, waiting for the network to bootstrap. # TODO: Add chutney command 'bootstrap-status' and use that instead. -BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-25} +BOOTSTRAP_TIME=${BOOTSTRAP_TIME:-30} $ECHO_N "$myname: sleeping for $BOOTSTRAP_TIME seconds" n=$BOOTSTRAP_TIME; while [ $n -gt 0 ]; do sleep 1; n=$(expr $n - 1); $ECHO_N .