2 # Copyright (C) CinelerraCV
3 # 2007, Christian Thaeter <ct@pipapo.org>
4 # Hermann Vosseler <Ichthyostega@web.de>
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation; either version 2 of the
9 # License, or (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program; if not, write to the Free Software
18 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 # TESTMODE=FULL yet unimplemented
21 # run all tests, PLANNED which fail count as error
24 # run only tests which recently failed
27 # stop testing on the first failure
32 srcdir=$(dirname "$arg0")
34 ulimit -S -t 1 -v 524288
37 # gnu-pth & valgrind don't cooperate nicely
39 #if [ "$VALGRINDFLAGS" = 'DISABLE' ]; then
40 # echo "valgrind explicit disabled"
42 # if [ "$(which valgrind)" ]; then
43 # valgrind="$(which valgrind) --leak-check=yes --show-reachable=yes -q $VALGRINDFLAGS"
46 # echo "no valgrind found, go without it"
51 echo ================ ${0##*/} ================
57 # the old testlog if existing will be used to check for previous test states
58 if test -f ,testlog; then
59 mv ,testlog ,testlog.pre
74 while read -r line; do
81 echo "$arg" >>,send_stdin
84 echo "$arg" >>,expect_stdout
87 echo "$arg" >>,expect_stderr
93 echo "UNKOWN TEST COMMAND '$cmd'" 1>&2
98 echo -n "TEST $name: "
99 echo -en "\nTEST $name: $* " >>,testlog
103 if grep "^TEST $name: .* FAILED" ,testlog.pre >&/dev/null; then
105 MSGFAIL=" (still broken)"
106 elif grep "^TEST $name: .* \\(SKIPPED (ok)\\|OK\\)" ,testlog.pre >&/dev/null; then
107 echo ".. SKIPPED (ok)"
108 echo ".. SKIPPED (ok)" >>,testlog
109 SKIPCNT=$(($SKIPCNT + 1))
110 TESTCNT=$(($TESTCNT + 1))
123 TESTCNT=$(($TESTCNT + 1))
128 if test -f ,send_stdin; then
129 cat ,send_stdin | $valgrind $TESTBIN "$@" 2>,stderr >,stdout
131 $valgrind $TESTBIN "$@" 2>,stderr >,stdout
137 if test -f ,expect_stdout; then
138 if ! cmp ,expect_stdout ,stdout &>/dev/null; then
139 echo "unexpected data on stdout" >>,testtmp
140 grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,stdout >,tmp
141 diff -ua ,expect_stdout ,tmp >>,testtmp
147 if test -f ,expect_stderr; then
148 if ! cmp ,expect_stderr ,stderr &>/dev/null; then
149 echo "unexpected data on stderr" >>,testtmp
150 grep -v ': \(TRACE\|INFO\|NOTICE\|WARNING\|ERR\):' <,stderr >,tmp
151 diff -ua ,expect_stderr ,tmp >>,testtmp
157 if test $expect_return != $return; then
158 echo "unexpected return value $return" >>,testtmp
162 if test $fails -eq 0; then
164 echo ".. OK$MSGOK" >>,testlog
166 echo ".. FAILED$MSGFAIL";
167 echo ".. FAILED$MSGFAIL" >>,testlog
168 cat ,testtmp >>,testlog
170 echo "stderr was:" >>,testlog
171 cat ,stderr >>,testlog
173 FAILCNT=$(($FAILCNT + 1))
184 echo -n "PLANNED $1: "
185 echo -en "\nPLANNED $* " >>,testlog
186 echo ".. SKIPPED (planned)"
187 echo ".. SKIPPED (planned)" >>,testlog
188 SKIPCNT=$(($SKIPCNT + 1))
189 TESTCNT=$(($TESTCNT + 1))
194 if test \( ! "${TESTSUITES/*,*/}" \) -a "$TESTSUITES"; then
195 TESTSUITES="{$TESTSUITES}"
197 for t in $(eval echo $srcdir/*$TESTSUITES*.tests); do
199 done | sort | uniq | {
206 if [ $FAILCNT = 0 ]; then
207 echo " ... PASSED $(($TESTCNT - $SKIPCNT)) TESTS, $SKIPCNT SKIPPED"
210 echo " ... SUCCEDED $(($TESTCNT - $FAILCNT - $SKIPCNT)) TESTS"
211 echo " ... FAILED $FAILCNT TESTS"
212 echo " ... SKIPPED $SKIPCNT TESTS"
213 echo " see ',testlog' for details"
226 TESTSUITES="${TESTSUITES}${1:+${TESTSUITES:+,}$1}"