2 # Copyright (C) Lumiera.org
3 # 2007 - 2008, Christian Thaeter <ct@pipapo.org>
5 # This program is free software; you can redistribute it and/or
6 # modify it under the terms of the GNU General Public License as
7 # published by the Free Software Foundation; either version 2 of the
8 # License, or (at your option) any later version.
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # TESTMODE=FULL yet unimplemented
20 # run all tests, PLANNED which fail count as error
23 # run only tests which recently failed
26 # stop testing on the first failure
29 NOBUG_LOGREGEX
='^\(\*\*[0-9]*\*\* \)\?[0-9]\{10,\}: \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\|TODO\|PLANNED\|FIXME\|DEPRECATED\|UNIMPLEMENTED\|NOTREACHED\):'
32 srcdir
="$(dirname "$arg0")"
34 ulimit -S -t 5 -v 524288
36 if [ "$VALGRINDFLAGS" = 'DISABLE' ]; then
37 echo "valgrind explicit disabled"
39 if [ "$(which valgrind)" ]; then
41 if [[ -x 'vgsuppression' ]]; then
42 if [[ 'vgsuppression' -nt 'vgsuppression.supp' ]]; then
43 echo 'generating valgrind supression file'
45 if [[ -x ".libs/vgsuppression" ]]; then
46 .
/libtool
--mode=execute valgrind
--leak-check=yes --show-reachable=yes -q --gen-suppressions=all vgsuppression
2>&1 \
47 |
sed '/^\(==\)\|\(\*\*\)[0-9]*\(==\)\|\(\*\*\)/d;' >vgsuppression.supp
49 valgrind
--leak-check=yes --show-reachable=yes -q --gen-suppressions=all .
/vgsuppression
2>&1 \
50 |
sed '/^\(==\)\|\(\*\*\)[0-9]*\(==\)\|\(\*\*\)/d;' >vgsuppression.supp
53 valgrind
="$(which valgrind) --leak-check=yes --show-reachable=no --suppressions=vgsuppression.supp -q $VALGRINDFLAGS"
55 valgrind
="$(which valgrind) --leak-check=yes --show-reachable=no -q $VALGRINDFLAGS"
58 echo "no valgrind found, go without it"
63 echo "================ ${0##*/} ================"
70 # the old testlog if existing will be used to check for previous test states
71 if test -f ,testlog
; then
72 mv ,testlog
,testlog.pre
79 function compare_regex
() # rxfile plainfile
87 IFS
='' read -u 3 -r regex ||
return 0
88 IFS
='' read -u 4 -r line ||
{ echo "no output"; return 1; }
90 if [[ $line =~
$regex ]]; then
91 IFS
='' read -u 4 -r line ||
92 if IFS
='' read -u 3 -r regex
; then
93 echo "premature end in output, expecting: '$regex':$regexno"
101 if [[ $
((++miss
)) -gt 1 ]]; then
102 echo -e "'$line':$lineno\ndoes not match\n'$regex':$regexno"
105 IFS
='' read -u 3 -r regex ||
{ echo "more output than expected: '$line':$lineno"; return 1; }
121 while read -r line
; do
125 if [[ ! "$arg" ]]; then
132 echo "$arg" >>,send_stdin
135 echo "$arg" >>,expect_stdout
138 echo "$arg" >>,expect_stderr
147 echo "UNKOWN TEST COMMAND '$cmd'" 1>&2
152 echo -n "TEST $name: "
153 echo -en "\nTEST $name: $* " >>,testlog
157 if grep "^TEST $name: .* FAILED" ,testlog.pre
>&/dev
/null
; then
159 MSGFAIL
=" (still broken)"
160 elif grep "^TEST $name: .* \\(SKIPPED (ok)\\|OK\\)" ,testlog.pre
>&/dev
/null
; then
161 echo ".. SKIPPED (ok)"
162 echo ".. SKIPPED (ok)" >>,testlog
163 SKIPCNT
=$
(($SKIPCNT + 1))
164 TESTCNT
=$
(($TESTCNT + 1))
177 TESTCNT
=$
(($TESTCNT + 1))
183 if ! test -x $TESTBIN; then
185 echo "test binary '$TESTBIN' not found" >,stderr
190 if test -f ,send_stdin
; then
191 env
$TESTBIN_PREFIX $TESTBIN "$@" <,send_stdin
2>,stderr
>,stdout
193 env
$TESTBIN_PREFIX $TESTBIN "$@" 2>,stderr
>,stdout
197 if test -f ,expect_stdout
; then
198 grep -v "$NOBUG_LOGREGEX" <,stdout
>,tmp
199 if ! compare_regex
,expect_stdout
,tmp
>>,cmptmp
; then
200 echo "unexpected data on stdout" >>,testtmp
201 cat ,cmptmp
>>,testtmp
207 if test -f ,expect_stderr
; then
208 grep -v "$NOBUG_LOGREGEX" <,stderr
>,tmp
210 if ! compare_regex
,expect_stderr
,tmp
>>,cmptmp
; then
211 echo "unexpected data on stderr" >>,testtmp
212 cat ,cmptmp
>>,testtmp
218 if [[ "${expect_return:0:1}" = '!' ]]; then
219 if [[ "${expect_return#\!}" = "$return" ]]; then
220 echo "unexpected return value $return, expected $expect_return" >>,testtmp
224 if [[ "${expect_return}" != "$return" ]]; then
225 echo "unexpected return value $return, expected $expect_return" >>,testtmp
231 if test $fails -eq 0; then
233 echo ".. OK$MSGOK" >>,testlog
235 echo ".. FAILED$MSGFAIL";
236 echo ".. FAILED$MSGFAIL" >>,testlog
237 cat ,testtmp
>>,testlog
239 echo "stderr was:" >>,testlog
240 cat ,stderr
>>,testlog
242 FAILCNT
=$
(($FAILCNT + 1))
253 echo -n "PLANNED $1: "
254 echo -en "\nPLANNED $* " >>,testlog
255 echo ".. SKIPPED (planned)"
256 echo ".. SKIPPED (planned)" >>,testlog
257 SKIPCNT
=$
(($SKIPCNT + 1))
258 TESTCNT
=$
(($TESTCNT + 1))
263 if test \
( ! "${TESTSUITES/*,*/}" \
) -a "$TESTSUITES"; then
264 TESTSUITES
="{$TESTSUITES}"
266 for t
in $
(eval echo "$srcdir/*$TESTSUITES*.tests"); do
268 done |
sort |
uniq |
{
277 if [ $FAILCNT = 0 ]; then
278 echo " ... PASSED $(($TESTCNT - $SKIPCNT)) TESTS, $SKIPCNT SKIPPED"
281 echo " ... SUCCEDED $(($TESTCNT - $FAILCNT - $SKIPCNT)) TESTS"
282 echo " ... FAILED $FAILCNT TESTS"
283 echo " ... SKIPPED $SKIPCNT TESTS"
284 echo " see ',testlog' for details"
294 echo -e "\n#### $1" >>,testlog
296 if [[ -x ".libs/$2" ]]; then
297 TESTBIN_PREFIX
="./libtool --mode=execute $valgrind"
299 TESTBIN_PREFIX
="$valgrind"
304 TESTSUITES
="${TESTSUITES}${1:+${TESTSUITES:+,}$1}"