-
Notifications
You must be signed in to change notification settings - Fork 0
/
dtest
executable file
·116 lines (109 loc) · 2.76 KB
/
dtest
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/bin/bash
BASE="$(dirname "$0")"
BUILD=`pwd`
TMP=`mktemp bmXXXXXX`
# Run simple unit tests first.
typeset -i total=0
typeset -i success=0
echo -n 'Running unit tests:'
for t in "$BUILD/test/"test_*
do
if [ -x "$t" ] # ignore .cpp files
then
total=total+1
errmsg=$("$BASE/exrun" "$t" 2>&1)
errno=$?
if [ "$errno" = 0 ]
then
success=success+1
else
rm -f $TMP
echo " $t FAILED ($errno)"
echo
echo "$errmsg"
exit $?
fi
fi
done
echo " $success/$total tests succeeded"
echo 'All unit tests passed' >> $TMP
# Assume AUTO_INCREMENT id column in images table will get 1 in
# load_jpeg call below, since we reset the DB before doing it.
export QUERY_STRING=id=1
# 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.
EX="$BUILD/examples"
echo -n 'Running examples:'
for ex in \
$EX/resetdb $EX/simple[0-9] $EX/store_if $EX/for_each $EX/multiquery $EX/tquery1 \
$EX/resetdb $EX/tquery[2-9] \
$EX/resetdb $EX/ssqls[0-9] \
$EX/load_jpeg $EX/cgi_jpeg
do
eb=`basename $ex`
if [ -x $ex ]
then
if [ "$eb" = "resetdb" ]
then
echo
echo -n " "
fi
echo -n "$eb "
echo "---------------- BEGIN $eb OUTPUT ----------------" >> $TMP
if ! $BASE/exrun $ex -D $* >> $TMP
then
echo
echo 'TESTING ABORTED.'
rm -f $TMP
exit $?
fi
echo "================ END $eb OUTPUT ================" >> $TMP
echo >> $TMP
fi
done
echo
# Test ssqlsxlat -o. Note that it suppresses stdout but keeps stderr
# so warnings about directives and line elements it doesn't understand
# aren't suppressed. We run the first pass's output back through
# ssqlsxlat to deal with comments, whitespace differences, line element
# ordering, boolean value and type canonicalization, and other niggly
# differences we really don't care about. diff -w isn't enough.
for f in $BASE/{examples,test}/*.ssqls
do
bnf=`basename $f`
echo -n "Testing ssqlsxlat -i $f -o..."
echo "--- BEGIN ssqlsxlat -i $bnf -o ERROR OUTPUT ---" >> $TMP
pass1=/tmp/dtest-ssxgv2-pass1-$bnf
pass2=/tmp/dtest-ssxgv2-pass2-$bnf
echo -n "pass 1"
$BASE/exrun $BUILD/src/ssx/ssqlsxlat -i $f -o $pass1 > "$pass1".err 2>> $TMP
echo -n ", pass 2"
$BASE/exrun $BUILD/src/ssx/ssqlsxlat -i $pass1 -o $pass2 > "$pass2".err 2>> $TMP
echo -n ", diff"
diff $pass1 $pass2 > /dev/null >> $TMP
echo "==== END ssqlsxlat -i $bnf -o ERROR OUTPUT ====" >> $TMP
echo
done
# Check for any changes
BFILE=$BASE/bmark.txt
if [ -f $BFILE ]
then
if diff -u -w $BFILE $TMP
then
echo
echo 'All tests passed.'
ec=0
else
ec=1
fi
rm -f $TMP
exit $ec
else
mv $TMP $BFILE
chmod -w $BFILE
echo
echo 'BENCHMARK FILE REGENERATED.'
echo
fi