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