chutney-git-bisect.sh 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 [ ! -z "$1" ]; then
  17. CHUTNEY_TRIES="$1"
  18. fi
  19. if [ ! -z "$2" ]; then
  20. cd "$2"
  21. fi
  22. CHUTNEY_TEST_CMD="make test-network-all"
  23. if [ ! -z "$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 [ ! -z "$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