2
0

bisect 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!/bin/sh
  2. ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
  3. ##### Author: Travis Cross <tc@traviscross.com>
  4. log1 () { printf '%s' "$1">&2; }
  5. log () { printf '%s\n' "$1">&2; }
  6. err () { log "$1"; exit 1; }
  7. usage () {
  8. log "usage: $0"
  9. }
  10. while getopts "h" o; do
  11. case "$o" in
  12. h) usage; exit 0; ;;
  13. esac
  14. done
  15. shift $(($OPTIND-1))
  16. runscript=$(mktemp /tmp/bisectrunXXXXXXXX)
  17. touch $runscript
  18. chmod +x $runscript
  19. cat > $runscript <<'EOF'
  20. #!/bin/sh
  21. ##### -*- mode:shell-script; indent-tabs-mode:nil; sh-basic-offset:2 -*-
  22. ##### Author: Travis Cross <tc@traviscross.com>
  23. build_fs () (
  24. set -e
  25. unset CC CXX CPPFLAGS CFLAGS CXXFLAGS LDFLAGS V VERBOSE
  26. export V=1 VERBOSE=1
  27. git clean -fdx
  28. git reset --hard HEAD
  29. { git describe HEAD \
  30. && ./bootstrap.sh -j \
  31. && ./configure -C --enable-fhs \
  32. && make -j; } 2>&1 | tee build.log
  33. )
  34. good () { exit 0; }
  35. bad () { exit 1; }
  36. skip () { exit 125; }
  37. printf "Building FS...\n"
  38. if ! build_fs; then
  39. printf "FS didn't build correctly, skipping this revision...\n"
  40. skip
  41. fi
  42. printf "OK, now 'make install' if needed and test for the issue...\n"
  43. printf "When done, type 'exit'\n"
  44. bash
  45. tested=""
  46. while test -z "$tested"; do
  47. printf "Were you able to test the issue at this revision? [y/n]: "
  48. read tested
  49. done
  50. if test "$tested" != "y"; then
  51. printf "OK, we're skipping this revision then...\n"
  52. skip
  53. fi
  54. reproduced=""
  55. while test -z "$reproduced"; do
  56. printf "Did the issue reproduce at this revision? [y/n]: "
  57. read reproduced
  58. done
  59. if test "$reproduced" = "y"; then
  60. printf "OK, marking this as a bad revision...\n"
  61. bad
  62. else
  63. printf "OK, marking this as a good revision...\n"
  64. good
  65. fi
  66. EOF
  67. run_bisect () {
  68. goods=""
  69. bad=""
  70. paths=""
  71. while test -z "$bad"; do
  72. printf "Enter git hash of earliest known bad revision: "
  73. read bad_
  74. [ -z "$bad_" ] || bad="$bad_"
  75. done
  76. good_=""
  77. while test -z "$goods" || ! test -z "$good_"; do
  78. printf "Enter git hash of latest known good revisions ('.' to end): "
  79. read good_
  80. [ "$good_" = "." ] && good_=""
  81. [ -z "$good_" ] || goods="$good_ "
  82. done
  83. path_="_"
  84. while ! test -z "$path_"; do
  85. printf "(optional) Enter source path related to issue ('.' to end): "
  86. read path_
  87. [ "$path_" = "." ] && path_=""
  88. [ -z "$path_" ] || paths="$path_ "
  89. done
  90. printf "Starting git bisect...\n"
  91. git bisect start $bad $goods -- $paths
  92. git bisect run $runscript
  93. rm -f $runscript
  94. git bisect reset
  95. }
  96. bisectlog=/tmp/$(date -u +%Y%m%dT%H%M%SZ)-bisect_log.txt
  97. run_bisect | tee $bisectlog
  98. printf "\n\nNow please upload $bisectlog to JIRA.\n"