run.sh 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. #!/bin/sh
  2. # basedir is the root of the test directory in the package
  3. basedir="$(dirname "$0")"
  4. [ "$(echo "$basedir" | cut -c1)" = '/' ] || basedir="$PWD/$basedir"
  5. # rootdir is the root of the package
  6. rootdir="$basedir/.."
  7. die()
  8. {
  9. [ -n "$*" ] && echo "$*" >&2
  10. exit 1
  11. }
  12. # $1=interpreter
  13. # $2=test_dir
  14. run_pyunit()
  15. {
  16. local interpreter="$1"
  17. local test_dir="$2"
  18. (
  19. echo
  20. echo "==="
  21. echo "= Running $interpreter, PWMAN_CRYPTOLIB=\"$PWMAN_CRYPTOLIB\", PWMAN_ARGON2LIB=\"$PWMAN_ARGON2LIB\""
  22. echo "==="
  23. export PYTHONPATH="$rootdir/tests:$PYTHONPATH"
  24. cd "$rootdir" || die "Failed to cd to rootdir."
  25. "$interpreter" -m unittest --failfast --buffer --catch --verbose "$test_dir" ||\
  26. die "Test failed"
  27. ) || die
  28. }
  29. # $1=test_dir
  30. run_testdir()
  31. {
  32. local test_dir="$1"
  33. unset PYTHONPATH
  34. unset PYTHONSTARTUP
  35. unset PYTHONY2K
  36. unset PYTHONOPTIMIZE
  37. unset PYTHONDEBUG
  38. export PYTHONDONTWRITEBYTECODE=1
  39. unset PYTHONINSPECT
  40. unset PYTHONIOENCODING
  41. unset PYTHONNOUSERSITE
  42. unset PYTHONUNBUFFERED
  43. unset PYTHONVERBOSE
  44. export PYTHONWARNINGS=once
  45. export PYTHONHASHSEED=random
  46. unset PWMAN_DATABASE
  47. unset PWMAN_RAWGETPASS
  48. unset PWMAN_CRYPTOLIB
  49. unset PWMAN_ARGON2LIB
  50. run_pyunit python3 "$test_dir"
  51. export PWMAN_CRYPTOLIB=cryptodome
  52. export PWMAN_ARGON2LIB=argon2-cffi
  53. run_pyunit python3 "$test_dir"
  54. export PWMAN_CRYPTOLIB=pyaes
  55. export PWMAN_ARGON2LIB=argon2-cffi
  56. run_pyunit python3 "$test_dir"
  57. }
  58. run_tests()
  59. {
  60. run_testdir tests
  61. }
  62. run_tests