Browse Source

Enhance test script further to be usable in autopkgtest. Closes: #960324

During build, the executable is taken from the current directory, i.e.
"./bgpdump". During autopkgtest that file may exist but appearnetly does
not in Debian's CI infrastructure. Make this a parameter so the script
can be used in both situations.
Christoph Biedl 4 years ago
parent
commit
dd6cdcb539
2 changed files with 21 additions and 3 deletions
  1. 20 2
      debian/patches/local.enhance-test-script.patch
  2. 1 1
      debian/tests/control

+ 20 - 2
debian/patches/local.enhance-test-script.patch

@@ -8,12 +8,13 @@ Last-Update: 2014-07-22
 
 --- a/test.sh
 +++ b/test.sh
-@@ -2,14 +2,44 @@
+@@ -2,14 +2,45 @@
  
  FAILURES=0
  
 -mkdir -p test_out
 +DIR="${1:-.}"
++BGPDUMP="${2:-./bgpdump}"
 +
 +if [ ! -d "$DIR" ] ; then
 +    echo "Not a directory: $DIR"
@@ -40,7 +41,7 @@ Last-Update: 2014-07-22
 +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
-+    ./bgpdump -vm "$DIR/test_data/$mrt" > "$DIR/test_out/$OUT"
++    "$BGPDUMP" -vm "$DIR/test_data/$mrt" > "$DIR/test_out/$OUT"
 +    if [ -f "$DIR/test_expect/$OUT.gz" ] ; then
 +        EXT=gz
 +        CAT="$ZCAT"
@@ -59,3 +60,20 @@ Last-Update: 2014-07-22
      if [ $? = 0 ]; then
          echo "success"
      else
+@@ -18,14 +49,14 @@
+ done
+ 
+ if [ ! -z "$BGPDUMP_TEST_UATTR" ] ; then
+-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
+     printf "      testing -u %s..." "$mrt"
+     OUT="$mrt.bgp.gz"
+     # The pipe into sed removes the last field added by -u on table dump
+     # and announcement (update files) lines, and allows us to chekc
+     # everything else is the same without adding new test_expect files
+     # to the repository.
+-    ./bgpdump -u -vm test_data/$mrt | sed '/|A\|B|/ s/|[^|]*|$/|/' > test_out/$OUT
++    "$BGPDUMP" -u -vm test_data/$mrt | sed '/|A\|B|/ s/|[^|]*|$/|/' > test_out/$OUT
+     gzip -cd test_expect/$OUT | diff -q test_out/$OUT -
+     if [ $? = 0 ]; then
+         echo "success"

+ 1 - 1
debian/tests/control

@@ -1,5 +1,5 @@
 Test-Command: bgpdump -T
 Depends: @
 
-Test-Command: ./test.sh debian/extra-tests/
+Test-Command: ./test.sh debian/extra-tests/ bgpdump
 Depends: @