]> git.ipfire.org Git - thirdparty/pdns.git/blob - regression-tests/runtests
Merge pull request #5616 from rgacogne/nmt-cleanup-from-weakforced
[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 cat $a/description
53
54 echo "$testname: " >> test-results
55 cat $a/description >> test-results
56
57 SKIPIT=0
58 if [ -e $a/skip ]
59 then
60 SKIPIT=1
61 result=" Skipped test $a"
62 else
63 for reason in $skipreasons $context
64 do
65 if [ -e $a/skip.$reason ]
66 then
67 SKIPIT=1
68 result=" Skipped test $a for reason $reason"
69 break
70 fi
71 done
72 fi
73
74 FAIL=0
75 for reason in $skipreasons $context
76 do
77 if [ -e $a/fail.$reason ]
78 then
79 FAIL=1
80 break
81 fi
82 done
83
84 if [ "$spectest" != "" ] && [ "$spectest" != "$testname" ] && [ "$testname" != "00dnssec-grabkeys" ]
85 then
86 SKIPIT=1
87 result=" Skipped test $a because it's not the specified single test"
88 fi
89
90
91 if [ $SKIPIT = 1 ]
92 then
93 echo $testname >> skipped_tests
94 skipped=$[$skipped+1]
95 else
96 $a/command > $a/real_result
97 expected=$a/expected_result
98
99 diffopts="-u"
100 if [ -e $a/expected_result.i ]; then
101 expected=$a/expected_result.i
102 diffopts="${diffopts} -i"
103 fi
104
105 for extracontext in $extracontexts
106 do
107 [ -e "$a/expected_result.$extracontext" ] && expected=$a/expected_result.$extracontext
108 done
109 [ -n "$context" ] && [ -e "$a/expected_result.$context" ] && expected=$a/expected_result.$context
110 diff ${diffopts} $expected $a/real_result > $a/diff 2>&1
111 if [ -s $a/diff ]
112 then
113 if [ $FAIL = 0 ]
114 then
115 result=" Failed test $a"
116 echo $testname >> failed_tests
117 failed=$[$failed+1]
118 else
119 result=" Expected failure for reason $reason, test passed $a"
120 echo $testname >> passed_tests
121 passed=$[$passed+1]
122 fi
123 else
124 if [ $FAIL = 0 ]
125 then
126 result=" Passed test $a"
127 echo $testname >> passed_tests
128 passed=$[$passed+1]
129 else
130 result=" Unexpected pass for reason $reason, test failed $a"
131 echo $testname >> failed_tests
132 failed=$[$failed+1]
133 fi
134 fi
135 fi
136 echo "$result"
137 echo
138 echo "$result" >> test-results
139 echo >> test-results
140 done
141
142 echo -n $passed out of $[$passed+$failed]
143 echo -n " ("
144 res=$((echo scale=2; echo 100*$passed/\($passed+$failed\)) | bc )
145 echo -n "$res%) "
146 echo tests passed, $skipped were skipped