1 #!/bin/sh 2 # 3 # test -- run a client self test. 4 # 5 P="test" 6 7 fix=`/bin/pwd` 8 fix=`dirname $fix` 9 fix=`dirname $fix` 10 11 me="../autotest" 12 13 # XXX: the exit status that indicates a rerun ... 14 rerun=5 15 16 function runtests { 17 for i in \ 18 "$@" 19 do 20 case "$i" in 21 *-filter|*-out|*-tmp|*.state) continue ;; 22 esac 23 24 ##echo "*** $i ...." 25 { 26 "$me" "$i" 27 rc="$?" 28 echo "--SELFTEST-- exit $rc" 29 while [ "$rc" = "$rerun" ]; do 30 "$me" --continue "$i" 31 rc="$?" 32 echo "--SELFTEST-- exit $rc" 33 done 34 } 2>&1 | `dirname "$i"`/NNN-filter "$i" | \ 35 sed -e "s@$fix@SRC@" -e "s@, line [0-9]*@, line N@" \ 36 >"$i-tmp" 2>&1 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" 44 diff -u "$i-out" "$i-tmp" 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 54 clean) rm -rf tests/*-tmp tests/*.state ;; 55 test) runtests tests/* ;; 56 *) runtests "$@" ;; 57 esac 58