]> The Tcpdump Group git mirrors - tcpdump/blob - tests/TESTrun.sh
make check needs to work in build directories
[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 mkdir -p tests/NEW
17 mkdir -p tests/DIFF
18 cat /dev/null > failure-outputs.txt
19
20 runComplexTests()
21 {
22 for i in ${srcdir}/tests/*.sh
23 do
24 case $i in
25 ${srcdir}/tests/TEST*.sh) continue;;
26 ${srcdir}/tests/\*.sh) continue;;
27 esac
28 echo Running $i
29 (cd tests && sh $i ${srcdir})
30 done
31 passed=`cat .passed`
32 failed=`cat .failed`
33 }
34
35 runSimpleTests()
36 {
37 only=$1
38 cat ${srcdir}/tests/TESTLIST | while read name input output options
39 do
40 case $name in
41 \#*) continue;;
42 '') continue;;
43 esac
44 rm -f core
45 [ "$only" != "" -a "$name" != "$only" ] && continue
46 export SRCDIR=${srcdir}
47 (cd tests # run TESTonce in tests directory
48 if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options"
49 then
50 passed=`expr $passed + 1`
51 echo $passed >.passed
52 else
53 failed=`expr $failed + 1`
54 echo $failed >.failed
55 fi)
56 [ "$only" != "" -a "$name" = "$only" ] && break
57 done
58 # I hate shells with their stupid, useless subshells.
59 passed=`cat .passed`
60 failed=`cat .failed`
61 }
62
63 passed=0
64 failed=0
65 echo $passed >.passed
66 echo $failed >.failed
67 if [ $# -eq 0 ]
68 then
69 runComplexTests
70 runSimpleTests
71 elif [ $# -eq 1 ]
72 then
73 runSimpleTests $1
74 else
75 echo "Usage: $0 [test_name]"
76 exit 30
77 fi
78
79 # exit with number of failing tests.
80 echo '------------------------------------------------'
81 printf "%4u tests failed\n" $failed
82 printf "%4u tests passed\n" $passed
83 echo
84 cat failure-outputs.txt
85 echo
86 echo
87 exit $failed