1#!/bin/sh 2# 3# test -- run a client self test. 4# 5P="test" 6 7fix=`/bin/pwd` 8fix=`dirname $fix` 9fix=`dirname $fix` 10 11me="../autotest" 12 13# XXX: the exit status that indicates a rerun ... 14rerun=5 15 16function 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. 53case "$1" in 54clean) rm -rf tests/*-tmp tests/*.state ;; 55test) runtests tests/* ;; 56*) runtests "$@" ;; 57esac 58