cov-test-determinism.sh 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. #!/bin/sh
  2. # To use this script, build Tor with coverage enabled, and then say:
  3. # ./scripts/test/cov-test-determinism.sh run
  4. #
  5. # Let it run for a long time so it can run the tests over and over. It
  6. # will put their coverage outputs in coverage-raw/coverage-*/.
  7. #
  8. # Then say:
  9. # ./scripts/test/cov-test-determinism.sh check
  10. #
  11. # It will diff the other coverage outputs to the first one, and put their
  12. # diffs in coverage-raw/diff-coverage-*.
  13. run=0
  14. check=0
  15. if test "$1" = run; then
  16. run=1
  17. elif test "$1" = check; then
  18. check=1
  19. else
  20. echo "First use 'run' with this script, then use 'check'."
  21. exit 1
  22. fi
  23. if test "$run" = 1; then
  24. while true; do
  25. make reset-gcov
  26. CD=coverage-raw/coverage-$(date +%s)
  27. make -j5 check
  28. mkdir -p "$CD"
  29. ./scripts/test/coverage "$CD"
  30. done
  31. fi
  32. if test "$check" = 1; then
  33. cd coverage-raw || exit 1
  34. FIRST="$(find . -name "coverage-*" -type d | head -1)"
  35. rm -f A
  36. ln -sf "$FIRST" A
  37. for dir in coverage-*; do
  38. rm -f B
  39. ln -sf "$dir" B
  40. ../scripts/test/cov-diff A B > "diff-$dir"
  41. done
  42. fi