[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [tor/master] Add scripts/test/chutney-git-bisect.sh, for bisecting using chutney



commit 4217dc0558c9fabfab1568b42dc5e101c69ddef7
Author: teor <teor@xxxxxxxxxxxxxx>
Date:   Fri Aug 24 04:03:56 2018 +1000

    Add scripts/test/chutney-git-bisect.sh, for bisecting using chutney
    
    Supports bisection on 0.3.4 and earlier.
    Recommend that users copy the script before bisecting.
    
    Implements ticket 27211.
---
 changes/ticket27211                |  3 ++
 scripts/README                     |  6 ++++
 scripts/test/chutney-git-bisect.sh | 62 ++++++++++++++++++++++++++++++++++++++
 3 files changed, 71 insertions(+)

diff --git a/changes/ticket27211 b/changes/ticket27211
new file mode 100644
index 000000000..c3d661a01
--- /dev/null
+++ b/changes/ticket27211
@@ -0,0 +1,3 @@
+  o Minor features (testing):
+    - Add scripts/test/chutney-git-bisect.sh, for bisecting using chutney.
+      Implements ticket 27211.
diff --git a/scripts/README b/scripts/README
index 02faabe06..9cd6e74ac 100644
--- a/scripts/README
+++ b/scripts/README
@@ -30,6 +30,12 @@ orconfig.h files.
 Testing scripts
 ---------------
 
+test/chutney-git-bisect.sh -- a git bisect run script that bisects using
+chutney. The script builds tor and tor-gencert, then runs chutney. The script
+takes optional arguments for out-of-tree builds, and specific chutney network
+flavours. You should copy this script before using it with git bisect, so that
+it doesn't change (or disappear) during bisection.
+
 test/cov-blame -- Mash up the results of gcov with git blame.  Mainly useful
 to find out who has been writing untested code.
 
diff --git a/scripts/test/chutney-git-bisect.sh b/scripts/test/chutney-git-bisect.sh
new file mode 100755
index 000000000..8a3f2c70c
--- /dev/null
+++ b/scripts/test/chutney-git-bisect.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+
+# Compile tor and run chutney to find out if the current commit works
+#
+# Usage:
+# # Copy the script, so it doesn't change during bisection
+# cp scripts/test/chutney-git-bisect.sh .
+# git bisect run \
+#   ./chutney-git-bisect.sh [tries [build-dir [flavour [skip-flavour]]]]
+#
+# Runs chutney up to <tries> times (default 3), because some bugs involve race
+# conditions.
+# Changes to <build-dir> (default no cd) before running tests.
+# Runs chutney network <flavour> (default make test-network-all) as the test.
+# Skips the test if <skip-flavour> fails (default no skip).
+
+CHUTNEY_TRIES=3
+if [ ! -z "$1" ]; then
+    CHUTNEY_TRIES="$1"
+fi
+
+if [ ! -z "$2" ]; then
+    cd "$2"
+fi
+
+CHUTNEY_TEST_CMD="make test-network-all"
+if [ ! -z "$3" ]; then
+    CHUTNEY_TEST_CMD="$CHUTNEY_PATH/tools/test-network.sh --flavour $3"
+fi
+
+CHUTNEY_SKIP_ON_FAIL_CMD="true"
+if [ ! -z "$4" ]; then
+    CHUTNEY_SKIP_ON_FAIL_CMD="$CHUTNEY_PATH/tools/test-network.sh --flavour $4"
+fi
+
+CHUTNEY_BUILD_CMD_OR="make src/or/tor src/tools/tor-gencert"
+CHUTNEY_BUILD_CMD_APP="make src/app/tor src/tools/tor-gencert"
+if ! ( $CHUTNEY_BUILD_CMD_APP || $CHUTNEY_BUILD_CMD_OR ) ; then
+    echo "building '$CHUTNEY_BUILD_CMD_APP || $CHUTNEY_BUILD_CMD_OR' failed, skip"
+    exit 125
+fi
+
+if ! $CHUTNEY_SKIP_ON_FAIL_CMD ; then
+    echo "pre-condition '$CHUTNEY_SKIP_ON_FAIL_CMD' failed, skip"
+    exit 125
+fi
+
+i=1
+while [ "$i" -le "$CHUTNEY_TRIES" ]; do
+    echo
+    echo "Round $i/$CHUTNEY_TRIES:"
+    echo
+    if $CHUTNEY_TEST_CMD ; then
+        echo "test '$CHUTNEY_TEST_CMD' succeeded after $i/$CHUTNEY_TRIES attempts, good"
+        exit 0
+    fi
+    i=$[$i+1]
+done
+
+i=$[$i-1]
+echo "test '$CHUTNEY_TEST_CMD' failed $i/$CHUTNEY_TRIES attempts, bad"
+exit 1



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits