]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests/runtests
Merge pull request #4958 from paddg/patch-5
[thirdparty/pdns.git] / regression-tests / runtests
1 #!/usr/bin/env bash
2 PATH=.:$PATH:/usr/sbin
3 MAKE=${MAKE:-make}
4
5 export PDNS=${PDNS:-${PWD}/../pdns/pdns_server}
6 export PDNS2=${PDNS2:-${PWD}/../pdns/pdns_server}
7 export PDNSRECURSOR=${PDNSRECURSOR:-${PWD}/../pdns/recursordist/pdns_recursor}
8 export RECCONTROL=${RECCONTROL:-${PWD}/../pdns/recursordist/rec_control}
9 export SDIG=${SDIG:-${PWD}/../pdns/sdig}
10 export NOTIFY=${NOTIFY:-${PWD}/../pdns/pdns_notify}
11 export NSEC3DIG=${NSEC3DIG:-${PWD}/../pdns/nsec3dig}
12 export SAXFR=${SAXFR:-${PWD}/../pdns/saxfr}
13 export ZONE2SQL=${ZONE2SQL:-${PWD}/../pdns/zone2sql}
14 export ZONE2JSON=${ZONE2JSON:-${PWD}/../pdns/zone2json}
15 export ZONE2LDAP=${ZONE2LDAP:-${PWD}/../pdns/zone2ldap}
16 export PDNSUTIL=${PDNSUTIL:-${PWD}/../pdns/pdnsutil}
17 export PDNSCONTROL=${PDNSCONTROL:-${PWD}/../pdns/pdns_control}
18
19 spectest=$1
20 [ -z $spectest ] && spectest=""
21
22 for prog in $SDIG $SAXFR $NOTIFY $NSEC3DIG; do
23 if `echo $prog | grep -q '../pdns'`; then
24 ${MAKE} -C ../pdns ${prog##*../pdns/} || exit
25 fi
26 done
27
28 export SDIG="timeout 5 $SDIG"
29 export NSEC3DIG="timeout 5 $NSEC3DIG"
30 export SAXFR="timeout 30 $SAXFR"
31 export PDNSCONTROL="timeout 5 $PDNSCONTROL"
32
33 rm -f test-results failed_tests passed_tests skipped_tests ${testsdir}/*/real_result ${testsdir}/*/diff ${testsdir}/*/*.out ${testsdir}/*/start ${testsdir}/*/step.*
34
35 passed=0
36 failed=0
37 skipped=0
38
39 touch passed_tests failed_tests skipped_tests
40
41 for a in $(find $testsdir -type d | grep -v ^.$ | grep -v .svn | grep -v ^confdir | LC_ALL=C sort)
42 do
43 if [ ! -x $a/command ]
44 then
45 continue
46 fi
47 testname=$(basename $a)
48 export testname
49 echo "$testname: "
50 cat $a/description
51
52 echo "$testname: " >> test-results
53 cat $a/description >> test-results
54
55 SKIPIT=0
56 if [ -e $a/skip ]
57 then
58 SKIPIT=1
59 result=" Skipped test $a"
60 else
61 for reason in $skipreasons $context
62 do
63 if [ -e $a/skip.$reason ]
64 then
65 SKIPIT=1
66 result=" Skipped test $a for reason $reason"
67 break
68 fi
69 done
70 fi
71
72 FAIL=0
73 for reason in $skipreasons $context
74 do
75 if [ -e $a/fail.$reason ]
76 then
77 FAIL=1
78 break
79 fi
80 done
81
82 if [ "$spectest" != "" ] && [ "$spectest" != "$testname" ] && [ "$testname" != "00dnssec-grabkeys" ]
83 then
84 SKIPIT=1
85 result=" Skipped test $a because it's not the specified single test"
86 fi
87
88
89 if [ $SKIPIT = 1 ]
90 then
91 echo $testname >> skipped_tests
92 skipped=$[$skipped+1]
93 else
94 $a/command > $a/real_result
95 expected=$a/expected_result
96
97 diffopts="-u"
98 if [ -e $a/expected_result.i ]; then
99 expected=$a/expected_result.i
100 diffopts="${diffopts} -i"
101 fi
102
103 for extracontext in $extracontexts
104 do
105 [ -e "$a/expected_result.$extracontext" ] && expected=$a/expected_result.$extracontext
106 done
107 [ -n "$context" ] && [ -e "$a/expected_result.$context" ] && expected=$a/expected_result.$context
108 diff ${diffopts} $expected $a/real_result > $a/diff 2>&1
109 if [ -s $a/diff ]
110 then
111 if [ $FAIL = 0 ]
112 then
113 result=" Failed test $a"
114 echo $testname >> failed_tests
115 failed=$[$failed+1]
116 else
117 result=" Expected failure for reason $reason, test passed $a"
118 echo $testname >> passed_tests
119 passed=$[$passed+1]
120 fi
121 else
122 if [ $FAIL = 0 ]
123 then
124 result=" Passed test $a"
125 echo $testname >> passed_tests
126 passed=$[$passed+1]
127 else
128 result=" Unexpected pass for reason $reason, test failed $a"
129 echo $testname >> failed_tests
130 failed=$[$failed+1]
131 fi
132 fi
133 fi
134 echo "$result"
135 echo
136 echo "$result" >> test-results
137 echo >> test-results
138 done
139
140 echo -n $passed out of $[$passed+$failed]
141 echo -n " ("
142 res=$((echo scale=2; echo 100*$passed/\($passed+$failed\)) | bc )
143 echo -n "$res%) "
144 echo tests passed, $skipped were skipped