Convert functional test suite to TAP

Automake provides a nice test harness that can parse TAP results, so
switch to using that.

Signed-off-by: Patrick McCarty <patrick.mccarty@intel.com>
This commit is contained in:
Patrick McCarty
2016-02-26 15:46:30 -08:00
parent 253dcbbbc0
commit 8c0a87b7c9
4 changed files with 74 additions and 42 deletions
+4
View File
@@ -28,3 +28,7 @@ stamp-h1
bsdiff-*.tar.xz
test/*.diff
test/*.out
test/*.log
test/*.trs
tap-driver.sh
test-suite.log
+5
View File
@@ -104,6 +104,11 @@ install-exec-hook:
TEST_EXTENSIONS = .sh
if ENABLE_TESTS
tap_driver = env AM_TAP_AWK='$(AWK)' $(SHELL) \
$(top_srcdir)/tap-driver.sh
LOG_DRIVER = $(tap_driver)
SH_LOG_DRIVER = $(tap_driver)
TESTS = $(dist_check_SCRIPTS)
dist_check_SCRIPTS = \
test/run.sh
+1
View File
@@ -66,6 +66,7 @@ AS_IF([test "$enable_tests" != "no"], [
AM_CONDITIONAL([ENABLE_TESTS], [test "$enable_tests" != "no"])
AC_CONFIG_FILES([Makefile data/bsdiff.pc])
AC_REQUIRE_AUX_FILE([tap-driver.sh])
AC_OUTPUT
AC_MSG_RESULT([
+64 -42
View File
@@ -1,5 +1,11 @@
#!/bin/bash
# $srcdir variable is set by automake environment
cd $srcdir/test
# number is incremented after running every test
testnum=0
sudo rm -f *.diff *.out
libdir="$(realpath "../.libs")"
@@ -7,51 +13,72 @@ ldpath="LD_LIBRARY_PATH=$libdir"
BSDIFF="sudo $ldpath valgrind -q $libdir/bsdiff"
BSPATCH="sudo $ldpath valgrind -q $libdir/bspatch"
echo -n "5.."
# If exit status is 0, the test succeeded. Else it failed.
check_success() {
res=$?
[ -n "$1" ] && msg="$1" || msg=""
testnum=$(expr $testnum + 1)
if [ $res -ne 0 ]; then
echo "not ok $testnum - $msg"
else
echo "ok $testnum"
fi
}
# If exit status is 255, the test succeeded. Else it failed.
check_failure() {
res=$?
[ -n "$1" ] && msg="$1" || msg=""
testnum=$(expr $testnum + 1)
if [ $res -ne 255 ]; then
echo "not ok $testnum - $msg"
else
echo "ok $testnum"
fi
}
echo "Running test #5 ..."
$BSPATCH data/5.bspatch.original 5.out data/5.bspatch.diff
echo -n "6.."
check_success
echo "Running test #6 ..."
$BSPATCH data/6.bspatch.original 6.out data/6.bspatch.diff
echo -n "7.."
check_success
echo "Running test #7 ..."
$BSPATCH data/7.bspatch.original 7.out data/7.bspatch.diff
echo -n "8.."
check_success
echo "Running test #8 ..."
$BSPATCH data/8.bspatch.original 8.out data/8.bspatch.diff
echo -n "9.."
check_success
echo "Running test #9 ..."
$BSPATCH data/9.bspatch.original 9.out data/9.bspatch.diff
diff data/9.bspatch.modified 9.out
if [ $? -ne 0 ]
then
echo "bspatch 9 output does not match expected!!"
fi
echo -n "10.."
check_success "output does not match expected!!"
echo "Running test #10 ..."
$BSPATCH data/10.bspatch.original 10.out data/10.bspatch.diff
diff data/10.bspatch.modified 10.out
if [ $? -ne 0 ]
then
echo "bspatch 10 output does not match expected!!"
fi
check_success "output does not match expected!!"
#same as 9 but with zeros encoding
echo -n "11.."
echo "Running test #11 ..."
$BSPATCH data/9.bspatch.original 11.out data/11.bspatch.diff
diff data/9.bspatch.modified 11.out
if [ $? -ne 0 ]
then
echo "bspatch 11 output does not match expected!!"
fi
echo -n "12.."
check_success "output does not match expected!!"
echo "Running test #12 ..."
$BSPATCH data/12.bspatch.original 12.out data/12.bspatch.diff
diff data/12.bspatch.modified 12.out
if [ $? -ne 0 ]
then
echo "bspatch 12 output does not match expected!!"
fi
echo -n "13.."
check_success "output does not match expected!!"
echo "Running test #13 ..."
$BSDIFF data/13.bspatch.original data/13.bspatch.modified 13.diff any
$BSPATCH data/13.bspatch.original 13.out 13.diff
diff data/13.bspatch.modified 13.out
if [ $? -ne 0 ]
then
echo "bspatch 13 output does not match expected!!"
fi
check_success "output does not match expected!!"
# Next a very loooong running test, but one which successfully condenses the 2MB
# original file pair into a 26kB bsdiff. The bsdiff computation alone (ie:
@@ -62,26 +89,21 @@ fi
# used in a regression test run at every check-in of code changes to the bsdiff
# implementation.
#
#echo -n "14.."
#echo "Running test #14 ..."
#$BSDIFF data/14.bspatch.original data/14.bspatch.modified 14.diff any
#$BSPATCH data/14.bspatch.original 14.out 14.diff
#diff data/14.bspatch.modified 14.out
#if [ $? -ne 0 ]
#then
# echo "bspatch 14 output does not match expected!!"
#fi
#check_success "output does not match expected!!"
echo -n "15.."
echo "Running test #15 ..."
$BSDIFF data/15.bspatch.original data/15.bspatch.modified 15.diff any
# expected output: "Failed to create delta (-1)"
if [ $? -ne 255 ]
then
echo "bspatch 15 creation has memory management issue!"
fi
check_failure "patch creation has memory management issue!"
echo -n "16.."
echo "Running test #16 ..."
# any valgrind errors may indicate a buffer overflow
$BSPATCH data/16.bspatch.original 16.out data/16.bspatch.diff
check_success
# add final newline
echo ""
# For TAP support, output the plan
echo "1..${testnum}"