Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / system / rpzrecurse / tests.sh
blobbd59fd53577bfb5b1042e9def79a7c729259ba8e
1 #!/bin/sh
3 # Copyright (C) 2015 Internet Systems Consortium, Inc. ("ISC")
5 # Permission to use, copy, modify, and/or distribute this software for any
6 # purpose with or without fee is hereby granted, provided that the above
7 # copyright notice and this permission notice appear in all copies.
9 # THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 # REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 # AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 # INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 # PERFORMANCE OF THIS SOFTWARE.
17 SYSTEMTESTTOP=..
18 . $SYSTEMTESTTOP/conf.sh
20 status=0
21 t=0
23 # $1 = test name (such as 1a, 1b, etc. for which named.$1.conf exists)
24 run_server() {
25 TESTNAME=$1
27 echo "I:stopping resolver"
28 $PERL $SYSTEMTESTTOP/stop.pl . ns2
30 sleep 1
32 echo "I:starting resolver using named.$TESTNAME.conf"
33 cp -f ns2/named.$TESTNAME.conf ns2/named.conf
34 $PERL $SYSTEMTESTTOP/start.pl --noclean --restart . ns2
37 run_query() {
38 TESTNAME=$1
39 LINE=$2
41 NAME=`tail -n +"$LINE" ns2/$TESTNAME.queries | head -n 1`
42 $DIG $DIGOPTS $NAME a @10.53.0.2 -p 5300 -b 127.0.0.1 > dig.out.${t}
43 grep "status: SERVFAIL" dig.out.${t} > /dev/null 2>&1 && return 1
44 return 0
47 # $1 = test name (such as 1a, 1b, etc. for which $1.queries exists)
48 # $2 = line number in query file to test (the name to query is taken from this line)
49 expect_norecurse() {
50 TESTNAME=$1
51 LINE=$2
53 NAME=`tail -n +"$LINE" ns2/$TESTNAME.queries | head -n 1`
54 t=`expr $t + 1`
55 echo "I:testing $NAME doesn't recurse (${t})"
56 run_query $TESTNAME $LINE || {
57 echo "I:test ${t} failed"
58 status=1
62 # $1 = test name (such as 1a, 1b, etc. for which $1.queries exists)
63 # $2 = line number in query file to test (the name to query is taken from this line)
64 expect_recurse() {
65 TESTNAME=$1
66 LINE=$2
68 NAME=`tail -n +"$LINE" ns2/$TESTNAME.queries | head -n 1`
69 t=`expr $t + 1`
70 echo "I:testing $NAME recurses (${t})"
71 run_query $TESTNAME $LINE && {
72 echo "I:test ${t} failed"
73 status=1
77 t=`expr $t + 1`
78 echo "I:testing that l1.l0 exists without RPZ (${t})"
79 $DIG $DIGOPTS l1.l0 ns @10.53.0.2 -p 5300 > dig.out.${t}
80 grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || {
81 echo "I:test ${t} failed"
82 status=1
85 t=`expr $t + 1`
86 echo "I:testing that l2.l1.l0 returns SERVFAIL without RPZ (${t})"
87 $DIG $DIGOPTS l2.l1.l0 ns @10.53.0.2 -p 5300 > dig.out.${t}
88 grep "status: SERVFAIL" dig.out.${t} > /dev/null 2>&1 || {
89 echo "I:test ${t} failed"
90 status=1
93 # Group 1
94 run_server 1a
95 expect_norecurse 1a 1
96 run_server 1b
97 expect_norecurse 1b 1
98 expect_recurse 1b 2
99 run_server 1c
100 expect_norecurse 1c 1
102 # Group 2
103 run_server 2a
104 for n in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
106 expect_norecurse 2a $n
107 done
108 expect_recurse 2a 33
110 # Group 3
111 run_server 3a
112 expect_recurse 3a 1
113 run_server 3b
114 expect_recurse 3b 1
115 run_server 3c
116 expect_recurse 3c 1
117 run_server 3d
118 expect_norecurse 3d 1
119 expect_recurse 3d 2
120 run_server 3e
121 expect_norecurse 3e 1
122 expect_recurse 3e 2
123 run_server 3f
124 expect_norecurse 3f 1
125 expect_recurse 3f 2
127 # Group 4
128 testlist="aa ap bf"
129 values="1 16 32"
130 # Uncomment the following to test every skip value instead of
131 # only a sample of values
133 #testlist="aa ab ac ad ae af ag ah ai aj ak al am an ao ap \
134 # aq ar as at au av aw ax ay az ba bb bc bd be bf"
135 #values="1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
136 # 21 22 23 24 25 26 27 28 29 30 31 32"
137 set -- $values
138 for n in $testlist; do
139 run_server 4$n
140 ni=$1
141 t=`expr $t + 1`
142 echo "I:testing that ${ni} of 33 queries skip recursion (${t})"
144 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \
145 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
147 run_query 4$n $i
148 c=`expr $c + $?`
149 done
150 skipped=`expr 33 - $c`
151 if [ $skipped != $ni ]; then
152 echo "I:test $t failed (actual=$skipped, expected=$ni)"
153 status=1
155 shift
156 done
158 # Group 5
159 run_server 5a
160 expect_norecurse 5a 1
161 expect_norecurse 5a 2
162 expect_recurse 5a 3
163 expect_recurse 5a 4
164 expect_recurse 5a 5
165 expect_recurse 5a 6
167 # Group 6
168 echo "I:check recursive behavior consistency during policy update races"
169 run_server 6a
170 sleep 1
171 t=`expr $t + 1`
172 echo "I:running dig to cache CNAME record (${t})"
173 $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org CNAME > dig.out.${t}
174 sleep 1
175 echo "I:suspending authority server"
176 kill -TSTP `cat ns1/named.pid`
177 echo "I:adding an NSDNAME policy"
178 cp ns2/db.6a.00.policy.local ns2/saved.policy.local
179 cp ns2/db.6b.00.policy.local ns2/db.6a.00.policy.local
180 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /'
181 sleep 1
182 t=`expr $t + 1`
183 echo "I:running dig to follow CNAME (blocks, so runs in the background) (${t})"
184 $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org A > dig.out.${t} &
185 sleep 1
186 echo "I:removing the NSDNAME policy"
187 cp ns2/db.6c.00.policy.local ns2/db.6a.00.policy.local
188 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /'
189 sleep 1
190 echo "I:resuming authority server"
191 kill -CONT `cat ns1/named.pid`
192 for n in 1 2 3 4 5 6 7 8 9; do
193 sleep 1
194 [ -s dig.out.${t} ] || continue
195 grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || {
196 echo "I:test ${t} failed"
197 status=1
199 done
201 echo "I:check recursive behavior consistency during policy removal races"
202 cp ns2/saved.policy.local ns2/db.6a.00.policy.local
203 run_server 6a
204 sleep 1
205 t=`expr $t + 1`
206 echo "I:running dig to cache CNAME record (${t})"
207 $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org CNAME > dig.out.${t}
208 sleep 1
209 echo "I:suspending authority server"
210 kill -TSTP `cat ns1/named.pid`
211 echo "I:adding an NSDNAME policy"
212 cp ns2/db.6b.00.policy.local ns2/db.6a.00.policy.local
213 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /'
214 sleep 1
215 t=`expr $t + 1`
216 echo "I:running dig to follow CNAME (blocks, so runs in the background) (${t})"
217 $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org A > dig.out.${t} &
218 sleep 1
219 echo "I:removing the policy zone"
220 cp ns2/named.default.conf ns2/db.6a.00.policy.local
221 $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /'
222 sleep 1
223 echo "I:resuming authority server"
224 kill -CONT `cat ns1/named.pid`
225 for n in 1 2 3 4 5 6 7 8 9; do
226 sleep 1
227 [ -s dig.out.${t} ] || continue
228 grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || {
229 echo "I:test ${t} failed"
230 status=1
232 done
234 # Check CLIENT-IP behavior
235 t=`expr $t + 1`
236 echo "I:testing CLIENT-IP behavior (${t})"
237 run_server clientip
238 $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.4 > dig.out.${t}
239 grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || {
240 echo "I:test $t failed: query failed"
241 status=1
243 grep "^l2.l1.l0.[[:space:]]*[0-9]*[[:space:]]*IN[[:space:]]*A[[:space:]]*10.53.0.2" dig.out.${t} > /dev/null 2>&1 || {
244 echo "I:test $t failed: didn't get expected answer"
245 status=1
248 exit $status