]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTrun.sh
pull in TESTrun from mainline
[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 failureoutput=$(pwd)/tests/failure-outputs.txt
19 mkdir -p tests/NEW
20 mkdir -p tests/DIFF
21 cat /dev/null > ${failureoutput}
22
23 runComplexTests()
24 {
25 for i in ${srcdir}/tests/*.sh
26 do
27 case $i in
28 ${srcdir}/tests/TEST*.sh) continue;;
29 ${srcdir}/tests/\*.sh) continue;;
30 esac
31 echo Running $i
32 (cd tests && sh $i ${srcdir})
33 done
34 passed=`cat ${passedfile}`
35 failed=`cat ${failedfile}`
36 }
37
38 runSimpleTests()
39 {
40 only=$1
41 cat ${srcdir}/tests/TESTLIST | while read name input output options
42 do
43 case $name in
44 \#*) continue;;
45 '') continue;;
46 esac
47 rm -f core
48 [ "$only" != "" -a "$name" != "$only" ] && continue
49 export SRCDIR=${srcdir}
50 # I hate shells with their stupid, useless subshells.
51 passed=`cat ${passedfile}`
52 failed=`cat ${failedfile}`
53 (cd tests # run TESTonce in tests directory
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 COREFILES ]; then
63 if [ -f core ]; then mv core 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 cat ${failureoutput}
94 echo
95 echo
96 exit $failed