Browse Source

Enhance the test script for alternate directories and compressions

Christoph Biedl 4 years ago
parent
commit
2a988ebd1a
3 changed files with 61 additions and 17 deletions
  1. 60 0
      debian/patches/enhance-test-script.patch
  2. 0 16
      debian/patches/fix-test.patch
  3. 1 1
      debian/patches/series

+ 60 - 0
debian/patches/enhance-test-script.patch

@@ -0,0 +1,60 @@
+Description: Enhance the test script
+Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
+Forwarded: No
+Last-Update: 2014-07-22
+
+     Handle alternate paths for the test data, handle alternate
+     compressions.
+
+--- a/test.sh
++++ b/test.sh
+@@ -2,14 +2,44 @@
+ 
+ FAILURES=0
+ 
+-mkdir -p test_out
++DIR="${1:-.}"
++
++if [ ! -d "$DIR" ] ; then
++    echo "Not a directory: $DIR"
++    exit 2
++fi
++
++if [ -x "$(which gzcat)" ] ; then
++    ZCAT=gzcat
++elif [ -x "$(which zcat)" ] ; then
++    ZCAT=zcat
++else
++    echo "Have neither zcat or gzcat"
++    exit 2
++fi
++
++mkdir -p "$DIR/test_out"
+ 
+ echo "Running Regression Tests..."
+-for mrt in `ls test_data`; do
++for mrt in $(find "$DIR/test_data/" -maxdepth 1 -type f -printf '%f\n' | grep -E '\.(gz|bz2|xz)' | sort) ; do
+     echo -n "      testing $mrt..."
+-    OUT=$mrt.bgp.gz
+-    ./bgpdump -vm test_data/$mrt > test_out/$OUT
+-    gzcat test_expect/$OUT | diff -q test_out/$OUT -
++    OUT=$mrt.bgp
++    ./bgpdump -vm "$DIR/test_data/$mrt" > "$DIR/test_out/$OUT"
++    if [ -f "$DIR/test_expect/$OUT.gz" ] ; then
++        EXT=gz
++        CAT="$ZCAT"
++    elif [ -f "$DIR/test_expect/$OUT.bz2" ] ; then
++        EXT=bz2
++        CAT='bzcat'
++    elif [ -f "$DIR/test_expect/$OUT.xz" ] ; then
++        EXT=xz
++        CAT='xzcat'
++    else
++        echo "Have no expect data"
++        exit 2
++    fi
++
++    "$CAT" "$DIR/test_expect/$OUT.$EXT" | diff -q "$DIR/test_out/$OUT" -
+     if [ $? == 0 ]; then
+         echo "success"
+     else

+ 0 - 16
debian/patches/fix-test.patch

@@ -1,16 +0,0 @@
-Description: Fix the test run, Debian has zcat, not gzcat
-Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
-Bug: https://bitbucket.org/ripencc/bgpdump/issues/34/
-Last-Update: 2016-07-18
-
---- a/test.sh
-+++ b/test.sh
-@@ -9,7 +9,7 @@
-     echo -n "      testing $mrt..."
-     OUT=$mrt.bgp.gz
-     ./bgpdump -vm test_data/$mrt > test_out/$OUT
--    gzcat test_expect/$OUT | diff -q test_out/$OUT -
-+    zcat test_expect/$OUT | diff -q test_out/$OUT -
-     if [ $? == 0 ]; then
-         echo "success"
-     else

+ 1 - 1
debian/patches/series

@@ -20,4 +20,4 @@ increase-max-prefixes.patch
 more-bgp-states.patch
 
 # big test (see README.Debian)
-fix-test.patch
+enhance-test-script.patch