12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- 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,45 @@
-
- FAILURES=0
-
- -mkdir -p test_out
- +DIR="${1:-.}"
- +BGPDUMP="${2:-./bgpdump}"
- +
- +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
- - /bin/echo -n " testing $mrt..."
- - OUT=$mrt.bgp.gz
- - ./bgpdump -vm test_data/$mrt > test_out/$OUT
- - gzip -cd test_expect/$OUT | diff -q test_out/$OUT -
- +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"
- + 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
- @@ -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"
|