cov-test-determinism.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. # same seed as in travis.yml
  25. TOR_TEST_RNG_SEED="636f766572616765"
  26. export TOR_TEST_RNG_SEED
  27. while true; do
  28. make reset-gcov
  29. CD=coverage-raw/coverage-$(date +%s)
  30. make -j5 check
  31. mkdir -p "$CD"
  32. ./scripts/test/coverage "$CD"
  33. done
  34. fi
  35. if test "$check" = 1; then
  36. cd coverage-raw || exit 1
  37. FIRST="$(find . -name "coverage-*" -type d | head -1)"
  38. rm -f A
  39. ln -sf "$FIRST" A
  40. for dir in coverage-*; do
  41. rm -f B
  42. ln -sf "$dir" B
  43. ../scripts/test/cov-diff A B > "diff-$dir"
  44. done
  45. fi