1 #!/bin/sh 2 3 mkdir -p NEW 4 mkdir -p DIFF 5 passed=0 6 failed=0 7 cat /dev/null > failure-outputs.txt 8 9 runComplexTests() 10 { 11 for i in *.sh 12 do 13 case $i in TEST*.sh) continue;; esac 14 if sh ./$i 15 then 16 passed=`expr $passed + 1` 17 else 18 failed=`expr $failed + 1` 19 fi 20 done 21 } 22 23 runSimpleTests() 24 { 25 only=$1 26 echo $passed >.passed 27 echo $failed >.failed 28 cat TESTLIST | while read name input output options 29 do 30 case $name in 31 \#*) continue;; 32 '') continue;; 33 esac 34 rm -f core 35 [ "$only" != "" -a "$name" != "$only" ] && continue 36 if ./TESTonce $name $input $output "$options" 37 then 38 passed=`expr $passed + 1` 39 echo $passed >.passed 40 else 41 failed=`expr $failed + 1` 42 echo $failed >.failed 43 fi 44 [ "$only" != "" -a "$name" = "$only" ] && break 45 done 46 # I hate shells with their stupid, useless subshells. 47 passed=`cat .passed` 48 failed=`cat .failed` 49 } 50 51 if [ $# -eq 0 ] 52 then 53 runComplexTests 54 runSimpleTests 55 elif [ $# -eq 1 ] 56 then 57 runSimpleTests $1 58 else 59 echo "Usage: $0 [test_name]" 60 exit 30 61 fi 62 63 # exit with number of failing tests. 64 echo '------------------------------------------------' 65 printf "%4u tests failed\n" $failed 66 printf "%4u tests passed\n" $passed 67 echo 68 echo 69 cat failure-outputs.txt 70 echo 71 echo 72 exit $failed 73