]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTrun.sh
dns: add some additional error checks.
[tcpdump] / tests / TESTrun.sh
1 #!/bin/sh
2
3 TZ=GMT0; export TZ
4 srcdir=${SRCDIR-..}
5
6 # make it absolute for later use.
7 pwd
8 srcdir=`cd $srcdir && pwd`
9
10 # this should be run from the compiled build directory,
11 # with srcdir= set to wherever the source code is.
12 # not from the tests directory.
13 echo RUNNING from ${srcdir}
14
15 passedfile=`pwd`/tests/.passed
16 failedfile=`pwd`/tests/.failed
17 failureoutput=`pwd`/tests/failure-outputs.txt
18 mkdir -p tests/NEW
19 mkdir -p tests/DIFF
20 cat /dev/null > ${failureoutput}
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 (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 SRCDIR=${srcdir}
49 export SRCDIR
50 # I hate shells with their stupid, useless subshells.
51 passed=`cat ${passedfile}`
52 failed=`cat ${failedfile}`
53 (
54 if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options"
55 then
56 passed=`expr $passed + 1`
57 echo $passed >${passedfile}
58 else
59 failed=`expr $failed + 1`
60 echo $failed >${failedfile}
61 fi
62 if [ -d tests/COREFILES ]; then
63 if [ -f core ]; then mv core tests/COREFILES/$name.core; fi
64 fi)
65 [ "$only" != "" -a "$name" = "$only" ] && break
66 done
67 # I hate shells with their stupid, useless subshells.
68 passed=`cat ${passedfile}`
69 failed=`cat ${failedfile}`
70 }
71
72 passed=0
73 failed=0
74 echo $passed >${passedfile}
75 echo $failed >${failedfile}
76 if [ $# -eq 0 ]
77 then
78 runComplexTests
79 runSimpleTests
80 elif [ $# -eq 1 ]
81 then
82 runSimpleTests $1
83 else
84 echo "Usage: $0 [test_name]"
85 exit 30
86 fi
87
88 # exit with number of failing tests.
89 echo '------------------------------------------------'
90 printf "%4u tests failed\n" $failed
91 printf "%4u tests passed\n" $passed
92 echo
93 if [ -z "$SKIPPASSED" ]; then
94 cat ${failureoutput}
95 fi
96 echo
97 echo
98 exit $failed