| 1 | #!/bin/bash |
| 2 | |
| 3 | TMP=`mktemp bmXXXXXX` |
| 4 | |
| 5 | # Run simple unit tests first. |
| 6 | typeset -i count=0 |
| 7 | echo -n 'Running unit tests:' |
| 8 | for t in test_* |
| 9 | do |
| 10 | if [ -x "$t" ] |
| 11 | then |
| 12 | errmsg=`./exrun "$t" 2>&1` |
| 13 | errno=$? |
| 14 | if [ "$errno" = 0 ] |
| 15 | then |
| 16 | count=count+1 |
| 17 | else |
| 18 | rm -f $TMP |
| 19 | echo " $t FAILED ($errno)" |
| 20 | echo |
| 21 | echo "$errmsg" |
| 22 | exit $? |
| 23 | fi |
| 24 | fi |
| 25 | done |
| 26 | echo " $count tests succeeded" |
| 27 | echo 'All unit tests passed' >> $TMP |
| 28 | |
| 29 | # Assume AUTO_INCREMENT id column in images table will get 1 in |
| 30 | # load_jpeg call below, since we reset the DB before doing it. |
| 31 | export QUERY_STRING=id=1 |
| 32 | |
| 33 | # Now run examples to test high-level behavior. The repeated use of |
| 34 | # resetdb is intentional! It's run after each example that changes |
| 35 | # the database in a way that will cause a subsequent example to fail |
| 36 | # because data it expects isn't present. |
| 37 | echo -n 'Running examples:' |
| 38 | for t in \ |
| 39 | resetdb simple[0-9] store_if for_each multiquery tquery1 \ |
| 40 | resetdb tquery[2-9] \ |
| 41 | resetdb ssqls[0-9] \ |
| 42 | load_jpeg cgi_jpeg |
| 43 | do |
| 44 | if [ -x $t ] |
| 45 | then |
| 46 | if [ "$t" = "resetdb" ] |
| 47 | then |
| 48 | echo |
| 49 | echo -n " " |
| 50 | fi |
| 51 | |
| 52 | echo -n "$t " |
| 53 | echo "---------------- BEGIN $t OUTPUT ----------------" >> $TMP |
| 54 | if ! ./exrun $t -D $* >> $TMP |
| 55 | then |
| 56 | echo |
| 57 | echo 'TESTING ABORTED.' |
| 58 | rm -f $TMP |
| 59 | exit $? |
| 60 | fi |
| 61 | echo "================ END $t OUTPUT ================" >> $TMP |
| 62 | echo >> $TMP |
| 63 | fi |
| 64 | done |
| 65 | echo |
| 66 | |
| 67 | # Test ssqlsxlat -o. Note that it suppresses stdout but keeps stderr |
| 68 | # so warnings about directives and line elements it doesn't understand |
| 69 | # aren't suppressed. We run the first pass's output back through |
| 70 | # ssqlsxlat to deal with comments, whitespace differences, line element |
| 71 | # ordering, boolean value and type canonicalization, and other niggly |
| 72 | # differences we really don't care about. diff -w isn't enough. |
| 73 | for f in {examples,test}/*.ssqls |
| 74 | do |
| 75 | echo -n "Testing ssqlsxlat -i $f -o..." |
| 76 | echo "--- BEGIN ssqlsxlat -i $f -o ERROR OUTPUT ---" >> $TMP |
| 77 | pass1=/tmp/dtest-ssxgv2-pass1-$bnf |
| 78 | pass2=/tmp/dtest-ssxgv2-pass2-$bnf |
| 79 | echo -n "pass 1" |
| 80 | ./exrun ssqlsxlat -i $f -o $pass1 > /dev/null 2>> $TMP |
| 81 | echo -n ", pass 2" |
| 82 | ./exrun ssqlsxlat -i $pass1 -o $pass2 > /dev/null 2>> $TMP |
| 83 | echo -n ", diff" |
| 84 | diff $pass1 $pass2 > /dev/null >> $TMP |
| 85 | echo "==== END ssqlsxlat -i $f -o ERROR OUTPUT ====" >> $TMP |
| 86 | echo |
| 87 | done |
| 88 | |
| 89 | # Check for any changes |
| 90 | BFILE=bmark.txt |
| 91 | if [ -f $BFILE ] |
| 92 | then |
| 93 | if diff -u -w $BFILE $TMP |
| 94 | then |
| 95 | echo |
| 96 | echo 'All tests passed.' |
| 97 | fi |
| 98 | rm -f $TMP |
| 99 | else |
| 100 | mv $TMP $BFILE |
| 101 | chmod -w $BFILE |
| 102 | echo |
| 103 | echo 'BENCHMARK FILE REGENERATED.' |
| 104 | echo |
| 105 | fi |