1
0

enhance-test-script.patch 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. - /bin/echo -n " testing $mrt..."
  32. - OUT=$mrt.bgp.gz
  33. - ./bgpdump -vm test_data/$mrt > test_out/$OUT
  34. - gzip -cd test_expect/$OUT | diff -q test_out/$OUT -
  35. +for mrt in $(find "$DIR/test_data/" -maxdepth 1 -type f -printf '%f\n' | grep -E '\.(gz|bz2|xz)' | sort) ; do
  36. + echo -n " testing $mrt..."
  37. + OUT=$mrt.bgp
  38. + ./bgpdump -vm "$DIR/test_data/$mrt" > "$DIR/test_out/$OUT"
  39. + if [ -f "$DIR/test_expect/$OUT.gz" ] ; then
  40. + EXT=gz
  41. + CAT="$ZCAT"
  42. + elif [ -f "$DIR/test_expect/$OUT.bz2" ] ; then
  43. + EXT=bz2
  44. + CAT='bzcat'
  45. + elif [ -f "$DIR/test_expect/$OUT.xz" ] ; then
  46. + EXT=xz
  47. + CAT='xzcat'
  48. + else
  49. + echo "Have no expect data"
  50. + exit 2
  51. + fi
  52. +
  53. + "$CAT" "$DIR/test_expect/$OUT.$EXT" | diff -q "$DIR/test_out/$OUT" -
  54. if [ $? = 0 ]; then
  55. echo "success"
  56. else
  57. --- a/Makefile.am
  58. +++ b/Makefile.am
  59. @@ -11,4 +11,5 @@
  60. rm -f test_out/*.bgp.gz
  61. test: check-clean bgpdump
  62. + ./test.sh debian/tests/
  63. @[ -d test_data ] && ./test.sh || echo "Skipping upstream tests as they are huge (see README.Debian)"