Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 97 lines (96 sloc) 3.024 kB
30938c5 @olabini Add initial files
authored
1 #!/bin/bash
2 _XPG=1
3 result=0
4 errcnt=0
5 tstcnt=0;
6 if test "$1" == "--valgrind"; then
7 valgrind=`which valgrind`
8 shift
9 else
10 valgrind=
11 fi
12 diff -u $0 $0 >/dev/null 2>&1 && diff='diff -u' || diff='diff'
13 #diff="${diff} -I '#line [0-9]*'"
14 if uname|grep -q -i 'CYGWIN' && test -x "@WINBUILDDIR@/re2j.exe"; then
15 re2j='@WINBUILDDIR@/re2j.exe'
16 else
17 re2j='@builddir@/re2j'
18 fi
19 if test ! -x "${re2j}"; then
20 echo "Cannot find re2j executable (${re2j})."
21 fi
22 if test -n "${valgrind}"; then
23 valgrind="${valgrind} -q "
24 echo "Using valgrind"
25 fi
26 re2j="${valgrind}${re2j}"
27 echo "Testing: ${re2j}"
28 if ${re2j} -v|grep -q 're2j @PACKAGE_VERSION@ *\r*'; then
29 echo "Version: @PACKAGE_VERSION@"
30 else
31 echo "Warning: test build for @PACKAGE_VERSION@ but testing `${re2j} -v`"
32 fi
33 echo "Diffing: ${diff}"
34 if test $# = 0; then
35 tests=`for i in test lessons; do find @top_srcdir@/$i -name '*.re'; done|sort`
36 else
37 tests="$@"
38 fi;
39 for x in $tests; do
40 tstcnt=$(($tstcnt+1))
41 switches=`basename $x|sed -e 's/^[^.]*\.\(.*\)\.re$/-\1/g' -e 's/^[^-].*//g' -e 's/\([^ ]\)--/\1 --/g'`
42 genname=`echo $switches|sed -e 's,--.*$,,g' -e 's,^.[^o]*$,,g' -e 's,^[^ot]*t.*o.*$,,g' -e 's,^-[^o]*o\(.*\),@builddir@/test/\1,g'`
43 headers=`echo $switches|sed -e 's,--.*$,,g' -e 's,^.[^t]*$,,g' -e 's,^[^ot]*o.*t.*$,,g' -e 's,^-[^t]*t\(.*\),@builddir@/test/\1,g'`
44 switches=`echo $switches|sed -e 's,^-\([^ot-]*[ot]\)\(.*\)$,-\1@builddir@/test/\2,g'`
45 # don't use the -o flag, since it makes it harder to diff.
46 echo $x: $switches
47 outname=@builddir@/test/`basename ${x%.re}.c.temp`
48 outdiff=@builddir@/test/`basename ${x%.re}.c.diff`
49 typname=@builddir@/test/`basename ${x%.re}.h.temp`
50 typdiff=@builddir@/test/`basename ${x%.re}.h.diff`
51 $re2j $switches $x 2>&1 | sed -e "s,$x,`basename $x`,g" -e "s,/\* Generated by re2j .*\*/,/\* Generated by re2j \*/,g" > $outname
52 if test -n "$genname"; then
53 cat $genname | sed -e 's,@builddir@/test/,,g' -e "s,/\* Generated by re2j .*\*/,/\* Generated by re2j \*/,g" > $outname
54 rm $genname
55 fi
56 ok=1
57 if test -n "$headers"; then
58 cat $headers | sed -e 's,@builddir@/test/,,g' -e "s,/\* Generated by re2j .*\*/,/\* Generated by re2j \*/,g" > $typname
59 rm $headers
60 if test ! -f ${x%.re}.h; then
61 echo "Missing: ${x%.re}.h"
62 result=1
63 errcnt=$(($errcnt+1))
64 elif ${diff} ${x%.re}.h $typname > $typdiff; then
65 echo "Passed header test."
66 rm $typname
67 else
68 echo "Failed: ${x%.re}.h ${x%.re}.h.temp differ."
69 result=1
70 errcnt=$(($errcnt+1))
71 ok=0
72 fi
73 fi
74 if test ! -f ${x%.re}.c; then
75 echo "Missing: ${x%.re}.c"
76 result=1
77 errcnt=$(($errcnt+1))
78 elif ${diff} ${x%.re}.c $outname > $outdiff; then
79 if test $ok = 1; then
80 echo "Passed."
81 fi
82 rm $outname
83 else
84 echo "Failed: ${x%.re}.c ${x%.re}.c.temp differ."
85 result=1
86 errcnt=$(($errcnt+1))
87 fi
88 test -f $outdiff -a ! -s $outdiff && rm -f $outdiff
89 test -f $typdiff -a ! -s $typdiff && rm -f $typdiff
90 done
91 if test $result = 0; then
92 echo "All $tstcnt tests passed successfully."
93 else
94 echo "Error: $errcnt out $tstcnt tests failed."
95 fi
96 exit $result
Something went wrong with that request. Please try again.