enhance-test-script.patch 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. Description: Enhance the test script
  2. Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
  3. Forwarded: No
  4. Last-Update: 2014-07-22
  5. Handle alternate paths for the test data, handle alternate
  6. compressions.
  7. --- a/test.sh
  8. +++ b/test.sh
  9. @@ -2,14 +2,44 @@
  10. FAILURES=0
  11. -mkdir -p test_out
  12. +DIR="${1:-.}"
  13. +
  14. +if [ ! -d "$DIR" ] ; then
  15. + echo "Not a directory: $DIR"
  16. + exit 2
  17. +fi
  18. +
  19. +if [ -x "$(which gzcat)" ] ; then
  20. + ZCAT=gzcat
  21. +elif [ -x "$(which zcat)" ] ; then
  22. + ZCAT=zcat
  23. +else
  24. + echo "Have neither zcat or gzcat"
  25. + exit 2
  26. +fi
  27. +
  28. +mkdir -p "$DIR/test_out"
  29. echo "Running Regression Tests..."
  30. -for mrt in `ls test_data`; do
  31. +for mrt in $(find "$DIR/test_data/" -maxdepth 1 -type f -printf '%f\n' | grep -E '\.(gz|bz2|xz)' | sort) ; do
  32. echo -n " testing $mrt..."
  33. - OUT=$mrt.bgp.gz
  34. - ./bgpdump -vm test_data/$mrt > test_out/$OUT
  35. - gzcat test_expect/$OUT | diff -q test_out/$OUT -
  36. + OUT=$mrt.bgp
  37. + ./bgpdump -vm "$DIR/test_data/$mrt" > "$DIR/test_out/$OUT"
  38. + if [ -f "$DIR/test_expect/$OUT.gz" ] ; then
  39. + EXT=gz
  40. + CAT="$ZCAT"
  41. + elif [ -f "$DIR/test_expect/$OUT.bz2" ] ; then
  42. + EXT=bz2
  43. + CAT='bzcat'
  44. + elif [ -f "$DIR/test_expect/$OUT.xz" ] ; then
  45. + EXT=xz
  46. + CAT='xzcat'
  47. + else
  48. + echo "Have no expect data"
  49. + exit 2
  50. + fi
  51. +
  52. + "$CAT" "$DIR/test_expect/$OUT.$EXT" | diff -q "$DIR/test_out/$OUT" -
  53. if [ $? == 0 ]; then
  54. echo "success"
  55. else
  56. --- a/Makefile.am
  57. +++ b/Makefile.am
  58. @@ -11,4 +11,5 @@
  59. rm -f test_out/*.bgp.gz
  60. test: check-clean bgpdump
  61. + ./test.sh debian/tests/
  62. @[ -d test_data ] && ./test.sh || echo "Skipping upstream tests as they are huge (see README.Debian)"