local.enhance-test-script.patch 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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