test-branch 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #! /bin/bash
  2. #
  3. # For testing commits on a branch.
  4. #
  5. # The script loops through all commits in a branch (or between two given commits),
  6. # checks out each, builds INET, and launches a script that runs some simulations.
  7. # The output of the simulations MUST NOT change for commits that are just refactoring,
  8. # fix an unrelated bug, or introduce an unrelated new feature.
  9. #
  10. # The commits that change the output of the simulations are tagged in git, so they
  11. # can be viewed using "gitk --all".
  12. #
  13. # The script run by default is a "print-fingerprints" script that runs a series of
  14. # simulations, and greps the error messages and fingerprint messages from them.
  15. # So, effectively the script checks which commits change the fingerprint. The
  16. # fingerprint change then must be justified by the changes in the commit.
  17. #
  18. # range of commits to test; edit to your needs
  19. ENDREV=topic/etherfixes
  20. STARTREV=integration
  21. # the command to run on each commit
  22. COMMAND=./print-fingerprints
  23. # the label (actually, branch) names added to commits where command output changes
  24. LABEL=fingerprint-change
  25. INET_ROOT=../../..
  26. # get the list of commits
  27. commits=`git rev-list --reverse $STARTREV..$ENDREV || exit 1`
  28. # make clean
  29. (cd .. && make cleanall)
  30. rm -rf work
  31. mkdir work
  32. echo > work/.lastoutput
  33. i=0
  34. for commit in $commits; do
  35. (( i += 1 ))
  36. echo
  37. echo ---------------------------------------------------
  38. echo -n $i ": "
  39. git log -n 1 --pretty=oneline $commit | cat || exit 1
  40. git checkout -q $commit || exit 1
  41. git branch -d "$LABEL-$i" 2>/dev/null
  42. echo "Building..."
  43. (cd $INET_ROOT && make makefiles)
  44. (cd $INET_ROOT && make -j2) > work/build.$i.$commit 2>&1 || continue # skip checks on build error
  45. echo "Collecting fingerprints..."
  46. $COMMAND > work/output.$i.$commit || exit 1
  47. if diff work/output.$i.$commit work/.lastoutput > /dev/null; then
  48. echo "script output unchanged"
  49. else
  50. echo "CHANGE DETECTED! Tagging with '$LABEL-$i'"
  51. git branch -f "$LABEL-$i"
  52. fi
  53. cp work/output.$i.$commit work/.lastoutput
  54. done