apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 1 | #!/bin/sh |
2 | # | ||||
3 | # test -- run a client self test. | ||||
4 | # | ||||
5 | P="test" | ||||
6 | |||||
apw | 18b9d33 | 2006-09-22 22:17:19 +0000 | [diff] [blame] | 7 | fix=`/bin/pwd` |
apw | 55533d2 | 2006-04-27 14:10:47 +0000 | [diff] [blame] | 8 | fix=`dirname $fix` |
9 | fix=`dirname $fix` | ||||
10 | |||||
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 11 | me="../autotest" |
12 | |||||
apw | bc2867d | 2006-04-06 18:21:16 +0000 | [diff] [blame] | 13 | # XXX: the exit status that indicates a rerun ... |
14 | rerun=5 | ||||
15 | |||||
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 16 | function runtests { |
17 | for i in \ | ||||
18 | "$@" | ||||
19 | do | ||||
20 | case "$i" in | ||||
apw | 96cdb7f | 2006-09-23 09:36:05 +0000 | [diff] [blame] | 21 | *-filter|*-out|*-tmp|*.state) continue ;; |
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 22 | esac |
23 | |||||
24 | ##echo "*** $i ...." | ||||
25 | { | ||||
26 | "$me" "$i" | ||||
27 | rc="$?" | ||||
28 | echo "--SELFTEST-- exit $rc" | ||||
apw | bc2867d | 2006-04-06 18:21:16 +0000 | [diff] [blame] | 29 | while [ "$rc" = "$rerun" ]; do |
apw | df57da2 | 2006-04-27 14:11:50 +0000 | [diff] [blame] | 30 | "$me" --continue "$i" |
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 31 | rc="$?" |
32 | echo "--SELFTEST-- exit $rc" | ||||
33 | done | ||||
mbligh | 4055ec0 | 2006-09-23 04:36:33 +0000 | [diff] [blame] | 34 | } 2>&1 | `dirname "$i"`/NNN-filter "$i" | \ |
35 | sed -e "s@$fix@SRC@" -e "s@, line [0-9]*@, line N@" \ | ||||
apw | 55533d2 | 2006-04-27 14:10:47 +0000 | [diff] [blame] | 36 | >"$i-tmp" 2>&1 |
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 37 | |
38 | if [ ! -f "$i-out" ]; then | ||||
39 | echo "$P: WARNING: $i: no results for test" | ||||
40 | cat "$i-tmp" | ||||
41 | |||||
42 | elif ! cmp "$i-out" "$i-tmp"; then | ||||
43 | echo "$P: ERROR: $i: test failed" | ||||
apw | c324091 | 2006-09-22 22:19:05 +0000 | [diff] [blame] | 44 | diff -u "$i-out" "$i-tmp" |
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 45 | |
46 | else | ||||
47 | echo "$P: PASS: $i: test passed" | ||||
48 | fi | ||||
49 | done | ||||
50 | } | ||||
51 | |||||
52 | # Run all of the tests. | ||||
53 | case "$1" in | ||||
apw | df57da2 | 2006-04-27 14:11:50 +0000 | [diff] [blame] | 54 | clean) rm -rf tests/*-tmp tests/*.state ;; |
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 55 | test) runtests tests/* ;; |
mbligh | 4055ec0 | 2006-09-23 04:36:33 +0000 | [diff] [blame] | 56 | *) runtests "$@" ;; |
apw | 6e55162 | 2006-04-04 08:50:53 +0000 | [diff] [blame] | 57 | esac |