chutney-git-bisect.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #!/usr/bin/env bash
  2. # Compile tor and run chutney to find out if the current commit works
  3. #
  4. # Usage:
  5. # # Copy the script, so it doesn't change during bisection
  6. # cp scripts/test/chutney-git-bisect.sh .
  7. # git bisect run \
  8. # ./chutney-git-bisect.sh [tries [build-dir [flavour [skip-flavour]]]]
  9. #
  10. # Runs chutney up to <tries> times (default 3), because some bugs involve race
  11. # conditions.
  12. # Changes to <build-dir> (default no cd) before running tests.
  13. # Runs chutney network <flavour> (default make test-network-all) as the test.
  14. # Skips the test if <skip-flavour> fails (default no skip).
  15. CHUTNEY_TRIES=3
  16. if [ -n "$1" ]; then
  17. CHUTNEY_TRIES="$1"
  18. fi
  19. if [ -n "$2" ]; then
  20. cd "$2" || exit
  21. fi
  22. CHUTNEY_TEST_CMD="make test-network-all"
  23. if [ -n "$3" ]; then
  24. CHUTNEY_TEST_CMD="$CHUTNEY_PATH/tools/test-network.sh --flavour $3"
  25. fi
  26. CHUTNEY_SKIP_ON_FAIL_CMD="true"
  27. if [ -n "$4" ]; then
  28. CHUTNEY_SKIP_ON_FAIL_CMD="$CHUTNEY_PATH/tools/test-network.sh --flavour $4"
  29. fi
  30. CHUTNEY_BUILD_CMD_OR="make src/or/tor src/tools/tor-gencert"
  31. CHUTNEY_BUILD_CMD_APP="make src/app/tor src/tools/tor-gencert"
  32. if ! ( $CHUTNEY_BUILD_CMD_APP || $CHUTNEY_BUILD_CMD_OR ) ; then
  33. echo "building '$CHUTNEY_BUILD_CMD_APP || $CHUTNEY_BUILD_CMD_OR' failed, skip"
  34. exit 125
  35. fi
  36. if ! $CHUTNEY_SKIP_ON_FAIL_CMD ; then
  37. echo "pre-condition '$CHUTNEY_SKIP_ON_FAIL_CMD' failed, skip"
  38. exit 125
  39. fi
  40. i=1
  41. while [ "$i" -le "$CHUTNEY_TRIES" ]; do
  42. echo
  43. echo "Round $i/$CHUTNEY_TRIES:"
  44. echo
  45. if $CHUTNEY_TEST_CMD ; then
  46. echo "test '$CHUTNEY_TEST_CMD' succeeded after $i/$CHUTNEY_TRIES attempts, good"
  47. exit 0
  48. fi
  49. i=$((i+1))
  50. done
  51. i=$((i-1))
  52. echo "test '$CHUTNEY_TEST_CMD' failed $i/$CHUTNEY_TRIES attempts, bad"
  53. exit 1