test_harness.sh (n2n-3.0) | : | test_harness.sh (n2n-3.1.1) | ||
---|---|---|---|---|
#!/bin/sh | #!/bin/sh | |||
# | # | |||
# This expects to find the tests in the tools dir and the expected results | # Run with the name of a test list file. | |||
# in the tests dir. | # | |||
# This expects to find the tests in the tools dir or scripts dir and the | ||||
# expected results in the tests dir. | ||||
# boilerplate so we can support whaky cmake dirs | ||||
[ -z "$TOPDIR" ] && TOPDIR="." | ||||
[ -z "$BINDIR" ] && BINDIR="." | ||||
export TOPDIR | ||||
export BINDIR | ||||
TESTS=" | if [ -z "$1" ]; then | |||
tests-compress | echo need test list filename | |||
tests-elliptic | exit 1 | |||
tests-hashing | fi | |||
tests-transform | TESTLIST="$1" | |||
tests-wire | LISTDIR=$(dirname "$TESTLIST") | |||
" | ||||
TOOLSDIR=tools | ||||
TESTDATA=tests | ||||
# Allow both dirs be overidden | ||||
[ -n "$1" ] && TOOLSDIR="$1" | ||||
[ -n "$2" ] && TESTDATA="$2" | ||||
# Confirm we have all the tools and data | TESTS=$(sed -e "s/#.*//" "$TESTLIST") | |||
# Actually run the tests | ||||
for i in $TESTS; do | for i in $TESTS; do | |||
if [ ! -e "$TOOLSDIR/$i" ]; then | # Look in several places for the test program | |||
echo "Could not find test $TOOLSDIR/$i" | if [ -e "$BINDIR/$i" ]; then | |||
TEST="$BINDIR/$i" | ||||
elif [ -e "$BINDIR/tools/$i" ]; then | ||||
TEST="$BINDIR/tools/$i" | ||||
elif [ -e "$LISTDIR/../scripts/$i" ]; then | ||||
TEST="$LISTDIR/../scripts/$i" | ||||
else | ||||
echo "Could not find test $i" | ||||
exit 1 | exit 1 | |||
fi | fi | |||
if [ ! -e "$TESTDATA/$i.expected" ]; then | ||||
echo "Could not find testdata $TESTDATA/$i.expected" | if [ ! -e "$LISTDIR/$i.expected" ]; then | |||
echo "Could not find testdata $LISTDIR/$i.expected" | ||||
exit 1 | exit 1 | |||
fi | fi | |||
done | ||||
# Actually run the tests | echo "$TEST >$LISTDIR/$i.out" | |||
set -e | set -e | |||
for i in $TESTS; do | "$TEST" >"$LISTDIR/$i.out" | |||
echo "$TOOLSDIR/$i >$TESTDATA/$i.out" | cmp "$LISTDIR/$i.expected" "$LISTDIR/$i.out" | |||
"$TOOLSDIR/$i" >"$TESTDATA/$i.out" | set +e | |||
cmp "$TESTDATA/$i.expected" "$TESTDATA/$i.out" | ||||
done | done | |||
End of changes. 7 change blocks. | ||||
28 lines changed or deleted | 36 lines changed or added |