3 #=======================================================================
7 # Run all tests, update files in log/ of that directory and display the
10 # Author: Øyvind A. Holm <sunny@sunbase.org>
11 # License: GNU General Public License version 2 or later.
12 #=======================================================================
17 if test "$1" = "--version"; then
18 echo $progname $VERSION
22 if test -z "$1" -o "$1" = "-h" -o "$1" = "--help"; then
25 Run all tests, update files in log/ of that directory and display the
28 The exit value is a bitwise OR:
30 Bit 0 set: One or more tests failed
31 Bit 1 set: Bail out detected (one or more test scripts aborted)
36 1: One or more tests failed
37 2: One or more scripts aborted
38 3: Tests failed and scripts aborted
40 Lines starting with "# NOTICE:" are displayed during the run. They don't
41 affect the exit value, so they can for example be used to inform the
42 user that tests have been skipped.
44 Usage: $progname testname [options] [testname [...]]
51 Print version information.
58 echo "Syntax: $0 testname [options] [testname [...]]" >&2
70 while printf "%s" "$1" |
grep -q ^
-; do
76 currlen
=`echo -n $gf | wc -c`
77 [ $currlen -gt $maxlen ] && maxlen
=$currlen
82 printf "%${maxlen}s: " $testname
83 .
/$testname $opt_str 2>&1 |
84 perl
-pe 's/^((not )?ok)( \d+ )- /$1 - /;' >log
/$testname.log
85 not_ok_count
=$
(grep -a "^not ok" log
/$testname.log |
wc -l |
tr -d ' ')
86 if [ $not_ok_count -gt 0 ]; then
87 not_ok_str
=", $not_ok_count not ok"
88 retval
=$
(($retval |
1))
92 ok_count
=$
(grep -a "^ok" log
/$testname.log |
wc -l)
93 printf "%3u ok%s\\n" $ok_count "$not_ok_str"
94 tot_ok
=$
(($tot_ok + $ok_count))
95 tot_not_ok
=$
(($tot_not_ok + $not_ok_count))
96 grep -a -q "^not ok" log
/$testname.log
&& {
98 grep -a "^not ok" log
/$testname.log
101 grep -a "^Bail out" log
/$testname.log
&& retval
=$
(($retval |
2))
103 $tot_bailout + $
(grep -a "^Bail out" log
/$testname.log |
wc -l)
105 grep -a "^# NOTICE:" log
/$testname.log
109 if test $tot_not_ok -gt 0; then
110 tot_not_ok_str
=", $tot_not_ok not ok ($tot_not_ok/$((
111 $tot_ok + $tot_not_ok
114 printf "%${maxlen}s: %u ok%s\n" "total" "$tot_ok" "$tot_not_ok_str"
115 if test $tot_bailout -gt 0; then
116 printf "%${maxlen}s: %u\n" "bailout" "$tot_bailout"