]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests/runtests
dnsdist doc typo fix
[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 unset _JAVA_OPTIONS
20
21 spectest=$1
22 [ -z $spectest ] && spectest=""
23
24 for prog in $SDIG $SAXFR $NOTIFY $NSEC3DIG; do
25 if `echo $prog | grep -q '\.\./pdns'`; then
26 ${MAKE} -C ../pdns ${prog##*../pdns/} || exit
27 fi
28 done
29
30 export SDIG="timeout 5 $SDIG"
31 export NSEC3DIG="timeout 5 $NSEC3DIG"
32 export SAXFR="timeout 30 $SAXFR"
33 export PDNSCONTROL="timeout 5 $PDNSCONTROL"
34
35 rm -f test-results failed_tests passed_tests skipped_tests ${testsdir}/*/real_result ${testsdir}/*/diff ${testsdir}/*/*.out ${testsdir}/*/start ${testsdir}/*/step.*
36
37 passed=0
38 failed=0
39 skipped=0
40
41 touch passed_tests failed_tests skipped_tests
42
43 for a in $(find $testsdir -type d | grep -v ^.$ | grep -v .svn | grep -v ^confdir | LC_ALL=C sort)
44 do
45 if [ ! -x $a/command ]
46 then
47 continue
48 fi
49 testname=$(basename $a)
50 export testname
51 echo "$testname: "
52 if [ "${PDNS_DEBUG}" = "YES" ]; then
53 cat $a/description
54 fi
55
56 echo "$testname: " >> test-results
57 cat $a/description >> test-results
58
59 SKIPIT=0
60 if [ -e $a/skip ]
61 then
62 SKIPIT=1
63 result=" Skipped test $a"
64 else
65 for reason in $skipreasons $context
66 do
67 if [ -e $a/skip.$reason ]
68 then
69 SKIPIT=1
70 result=" Skipped test $a for reason $reason"
71 break
72 fi
73 done
74 fi
75
76 FAIL=0
77 for reason in $skipreasons $context
78 do
79 if [ -e $a/fail.$reason ]
80 then
81 FAIL=1
82 break
83 fi
84 done
85
86 if [ "$spectest" != "" ] && [ "$spectest" != "$testname" ] && [ "$testname" != "00dnssec-grabkeys" ]
87 then
88 SKIPIT=1
89 result=" Skipped test $a because it's not the specified single test"
90 fi
91
92
93 if [ $SKIPIT = 1 ]
94 then
95 echo $testname >> skipped_tests
96 skipped=$[$skipped+1]
97 else
98 $a/command > $a/real_result
99 expected=$a/expected_result
100
101 diffopts="-u"
102 if [ -e $a/expected_result.i ]; then
103 expected=$a/expected_result.i
104 diffopts="${diffopts} -i"
105 fi
106
107 for extracontext in $extracontexts
108 do
109 [ -e "$a/expected_result.$extracontext" ] && expected=$a/expected_result.$extracontext
110 done
111 [ -n "$context" ] && [ -e "$a/expected_result.$context" ] && expected=$a/expected_result.$context
112 diff ${diffopts} $expected $a/real_result > $a/diff 2>&1
113 if [ -s $a/diff ]
114 then
115 if [ $FAIL = 0 ]
116 then
117 result=" Failed test $a"
118 echo $testname >> failed_tests
119 failed=$[$failed+1]
120 if [ "$FIX_TESTS" == "YES" ]
121 then
122 mv -f $a/real_result $expected
123 result="$result (fixed)"
124 fi
125 else
126 result=" Expected failure for reason $reason, test passed $a"
127 echo $testname >> passed_tests
128 passed=$[$passed+1]
129 fi
130 else
131 if [ $FAIL = 0 ]
132 then
133 result=" Passed test $a"
134 echo $testname >> passed_tests
135 passed=$[$passed+1]
136 else
137 result=" Unexpected pass for reason $reason, test failed $a"
138 echo $testname >> failed_tests
139 failed=$[$failed+1]
140 fi
141 fi
142 fi
143 echo "$result"
144 echo
145 echo "$result" >> test-results
146 echo >> test-results
147 done
148
149 echo -n $passed out of $[$passed+$failed]
150 echo -n " ("
151 res=$((echo scale=2; echo 100*$passed/\($passed+$failed\)) | bc )
152 echo -n "$res%) "
153 echo tests passed, $skipped were skipped