1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
|
#!/bin/bash
TMP=`mktemp bmXXXXXX`
# Run simple unit tests first.
typeset -i count=0
echo -n 'Running unit tests:'
for t in test_*
do
if [ -x "$t" ]
then
errmsg=`./exrun "$t" 2>&1`
errno=$?
if [ "$errno" == 0 ]
then
count=count+1
else
rm -f $TMP
echo " $t FAILED ($errno)"
echo
echo "$errmsg"
exit $?
fi
fi
done
echo " $count tests succeeded"
echo 'All unit tests passed' >> $TMP
# Now run examples to test high-level behavior. The repeated use of
# resetdb is intentional! It's run after each example that changes
# the database in a way that will cause a subsequent example to fail
# because data it expects isn't present.
echo -n 'Running examples:'
for t in \
resetdb simple[0-9] store_if for_each multiquery tquery1 \
resetdb tquery[2-9] dbinfo fieldinf \
resetdb ssqls[0-9]
do
if [ -x $t ]
then
if [ "$t" = "resetdb" ]
then
echo
echo -n " "
fi
echo -n "$t "
echo "---------------- BEGIN $t OUTPUT ----------------" >> $TMP
if ! ./exrun $t -D $* >> $TMP
then
echo
echo 'TESTING ABORTED.'
rm -f $TMP
exit $?
fi
echo "================ END $t OUTPUT ================" >> $TMP
echo >> $TMP
fi
done
echo
# Check for any changes
BFILE=bmark.txt
if [ -f $BFILE ]
then
if diff -u -w $BFILE $TMP
then
echo
echo 'All tests passed.'
fi
rm -f $TMP
else
mv $TMP $BFILE
chmod -w $BFILE
echo
echo 'BENCHMARK FILE REGENERATED.'
echo
fi
|