Execute hours.sql from update_things.sql + add \echo header
[gpstools.git] / tests / Genlog
blobbe83ebe4e200b3f94e283dc8b009432b07ac4855
1 #!/bin/bash
3 #=======================================================================
4 # Genlog
5 # File ID: f12ac9d0-28f3-11e5-9579-fefdb24f8e10
7 # Run all tests, update files in log/ and display the results.
9 # License: GNU General Public License version 2 or later.
10 #=======================================================================
12 [ -z "$1" ] && { echo "Syntax: $0 testname [options] [testname [...]]" >&2; exit 1; }
14 mkdir -p log
15 maxlen=0
16 retval=0
17 tot_ok=0
18 tot_not_ok=0
19 opt_str=
21 while printf "%s" "$1" | grep -q ^-; do
22 opt_str="$opt_str $1"
23 shift
24 done
26 for gf in "$@"; do
27 currlen=`echo -n $gf | perl -pe 's/\.t$//' | wc -c`
28 [ $currlen -gt $maxlen ] && maxlen=$currlen
29 done
31 for gf in "$@"; do
32 testname=$gf
33 testname=`echo -n $testname | perl -pe 's/\.t$//'`
34 printf "%${maxlen}s.t: " $testname
35 ./$testname.t $opt_str 2>&1 | ./remove_perltestnumbers >log/$testname.log
36 not_ok_count=$(grep "^not ok -" log/$testname.log | wc -l | tr -d ' ')
37 if [ $not_ok_count -gt 0 ]; then
38 not_ok_str=", $not_ok_count not ok"
39 retval=1
40 else
41 unset not_ok_str
43 ok_count=$(grep "^ok -" log/$testname.log | wc -l)
44 printf "%3u ok%s\\n" $ok_count "$not_ok_str"
45 tot_ok=$(($tot_ok + $ok_count))
46 tot_not_ok=$(($tot_not_ok + $not_ok_count))
47 grep -q "^not ok -" log/$testname.log && {
48 echo
49 grep "^not ok -" log/$testname.log
50 echo
52 done
53 echo
54 printf " %${maxlen}s: %u ok, %u not ok\n" "total" $tot_ok $tot_not_ok
56 exit $retval