unit-tests.sh 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. #!/bin/sh
  2. # Exit on errors
  3. set -e
  4. # Verbose mode
  5. set -v
  6. # Output is prefixed with the name of the script
  7. myname=$(basename "$0")
  8. echo "$myname: finding chutney directory"
  9. TEST_DIR=$(dirname "$0")
  10. CHUTNEY_DIR=$(dirname "$TEST_DIR")
  11. echo "$myname: changing to chutney directory"
  12. cd "$CHUTNEY_DIR"
  13. echo "$myname: running Debug.py tests"
  14. LOG_FILE=$(mktemp)
  15. export LOG_FILE
  16. test -n "$LOG_FILE"
  17. unset CHUTNEY_DEBUG
  18. export CHUTNEY_DEBUG
  19. lib/chutney/Debug.py | tee "$LOG_FILE"
  20. LOG_FILE_LINES=$(wc -l < "$LOG_FILE")
  21. test "$LOG_FILE_LINES" -eq 1
  22. LOG_FILE=$(mktemp)
  23. export LOG_FILE
  24. test -n "$LOG_FILE"
  25. export CHUTNEY_DEBUG=1
  26. lib/chutney/Debug.py | tee "$LOG_FILE"
  27. LOG_FILE_LINES=$(wc -l < "$LOG_FILE")
  28. test "$LOG_FILE_LINES" -eq 2
  29. unset CHUTNEY_DEBUG
  30. export CHUTNEY_DEBUG
  31. echo "$myname: running Templating.py tests"
  32. LOG_FILE=$(mktemp)
  33. export LOG_FILE
  34. test -n "$LOG_FILE"
  35. lib/chutney/Templating.py torrc_templates/common.i | tee "$LOG_FILE"
  36. grep -q owning_controller_process "$LOG_FILE"
  37. grep -q connlimit "$LOG_FILE"
  38. grep -q controlport "$LOG_FILE"
  39. grep -q nick "$LOG_FILE"
  40. grep -q authorities "$LOG_FILE"
  41. grep -q dir "$LOG_FILE"
  42. echo "$myname: running Traffic.py tests"
  43. LOG_FILE=$(mktemp)
  44. export LOG_FILE
  45. test -n "$LOG_FILE"
  46. # Choose an arbitrary port
  47. PYTHONPATH=$PYTHONPATH:lib lib/chutney/Traffic.py 9999 | tee "$LOG_FILE"
  48. # Traffic.py produces output with a single newline. But we don't want to get
  49. # too picky about the details: allow an extra line and a few extra chars.
  50. LOG_FILE_LINES=$(wc -l < "$LOG_FILE")
  51. test "$LOG_FILE_LINES" -le 2
  52. LOG_FILE_CHARS=$(wc -c < "$LOG_FILE")
  53. test "$LOG_FILE_CHARS" -le 4
  54. # We don't test TorNet.py: it's integration tested with tor using the
  55. # chutney/chutney script