]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTrun.sh
the failed/passed count was not kept in the right place
[tcpdump] / tests / TESTrun.sh
1 #!/bin/sh
2
3 TZ=GMT0; export TZ
4 srcdir=${SRCDIR-..}
5
6 echo RUNNING from ${srcdir}
7
8 # make it absolute
9 srcdir=$(cd $srcdir && pwd)
10
11 # this should be run from the compiled build directory,
12 # with srcdir= set to wherever the source code is.
13 # not from the tests directory.
14 echo RUNNING from ${srcdir}
15
16 passedfile=$(pwd)/tests/.passed
17 failedfile=$(pwd)/tests/.failed
18 mkdir -p tests/NEW
19 mkdir -p tests/DIFF
20 cat /dev/null > failure-outputs.txt
21
22 runComplexTests()
23 {
24 for i in ${srcdir}/tests/*.sh
25 do
26 case $i in
27 ${srcdir}/tests/TEST*.sh) continue;;
28 ${srcdir}/tests/\*.sh) continue;;
29 esac
30 echo Running $i
31 (cd tests && sh $i ${srcdir})
32 done
33 passed=`cat ${passedfile}`
34 failed=`cat ${failedfile}`
35 }
36
37 runSimpleTests()
38 {
39 only=$1
40 cat ${srcdir}/tests/TESTLIST | while read name input output options
41 do
42 case $name in
43 \#*) continue;;
44 '') continue;;
45 esac
46 rm -f core
47 [ "$only" != "" -a "$name" != "$only" ] && continue
48 export SRCDIR=${srcdir}
49 # I hate shells with their stupid, useless subshells.
50 passed=`cat ${passedfile}`
51 failed=`cat ${failedfile}`
52 (cd tests # run TESTonce in tests directory
53 if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options"
54 then
55 passed=`expr $passed + 1`
56 echo $passed >${passedfile}
57 else
58 failed=`expr $failed + 1`
59 echo $failed >${failedfile}
60 fi)
61 [ "$only" != "" -a "$name" = "$only" ] && break
62 done
63 # I hate shells with their stupid, useless subshells.
64 passed=`cat ${passedfile}`
65 failed=`cat ${failedfile}`
66 }
67
68 passed=0
69 failed=0
70 echo $passed >${passedfile}
71 echo $failed >${failedfile}
72 if [ $# -eq 0 ]
73 then
74 runComplexTests
75 runSimpleTests
76 elif [ $# -eq 1 ]
77 then
78 runSimpleTests $1
79 else
80 echo "Usage: $0 [test_name]"
81 exit 30
82 fi
83
84 # exit with number of failing tests.
85 echo '------------------------------------------------'
86 printf "%4u tests failed\n" $failed
87 printf "%4u tests passed\n" $passed
88 echo
89 cat tests/failure-outputs.txt
90 echo
91 echo
92 exit $failed