]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTrun.sh
NDOize safeputs() and safeputchar()
[tcpdump] / tests / TESTrun.sh
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 [ "$only" != "" -a "$name" != "$only" ] && continue
35 if ./TESTonce $name $input $output "$options"
36 then
37 passed=`expr $passed + 1`
38 echo $passed >.passed
39 else
40 failed=`expr $failed + 1`
41 echo $failed >.failed
42 fi
43 [ "$only" != "" -a "$name" = "$only" ] && break
44 done
45 # I hate shells with their stupid, useless subshells.
46 passed=`cat .passed`
47 failed=`cat .failed`
48 }
49
50 if [ $# -eq 0 ]
51 then
52 runComplexTests
53 runSimpleTests
54 elif [ $# -eq 1 ]
55 then
56 runSimpleTests $1
57 else
58 echo "Usage: $0 [test_name]"
59 exit 30
60 fi
61
62 # exit with number of failing tests.
63 echo '------------------------------------------------'
64 printf "%4u tests failed\n" $failed
65 printf "%4u tests passed\n" $passed
66 echo
67 echo
68 cat failure-outputs.txt
69 echo
70 echo
71 exit $failed