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