Remove building with NOCRYPTO option
[minix.git] / external / bsd / bind / dist / bin / tests / system / masterformat / tests.sh
blob60f0e9600831adca1cd1ed033a779aff23255114
1 #!/bin/sh
3 # Copyright (C) 2005, 2007, 2011-2014 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 # Id
19 SYSTEMTESTTOP=..
20 . $SYSTEMTESTTOP/conf.sh
22 ismap () {
23 $PERL -e 'binmode STDIN;
24 read(STDIN, $input, 8);
25 ($style, $version) = unpack("NN", $input);
26 exit 1 if ($style != 3 || $version > 1);' < $1
27 return $?
30 israw () {
31 $PERL -e 'binmode STDIN;
32 read(STDIN, $input, 8);
33 ($style, $version) = unpack("NN", $input);
34 exit 1 if ($style != 2 || $version > 1);' < $1
35 return $?
38 rawversion () {
39 $PERL -e 'binmode STDIN;
40 read(STDIN, $input, 8);
41 if (length($input) < 8) { print "not raw\n"; exit 0; };
42 ($style, $version) = unpack("NN", $input);
43 print ($style == 2 || $style == 3 ? "$version\n" :
44 "not raw or map\n");' < $1
47 sourceserial () {
48 $PERL -e 'binmode STDIN;
49 read(STDIN, $input, 20);
50 if (length($input) < 20) { print "UNSET\n"; exit; };
51 ($format, $version, $dumptime, $flags, $sourceserial) =
52 unpack("NNNNN", $input);
53 if ($format != 2 || $version < 1) { print "UNSET\n"; exit; };
54 if ($flags & 02) {
55 print $sourceserial . "\n";
56 } else {
57 print "UNSET\n";
58 }' < $1
61 stomp () {
62 $PERL -e 'open(my $file, "+<", $ARGV[0]);
63 binmode $file;
64 seek($file, $ARGV[1], 0);
65 for (my $i = 0; $i < $ARGV[2]; $i++) {
66 print $file pack('C', $ARGV[3]);
68 close($file);' $1 $2 $3 $4
71 restart () {
72 sleep 1
73 (cd ..; $PERL start.pl --noclean --restart masterformat ns3)
76 DIGOPTS="+tcp +noauth +noadd +nosea +nostat +noquest +nocomm +nocmd"
78 status=0
80 echo "I:checking that master files in raw format loaded"
81 ret=0
82 set -- 1 2 3
83 for zone in example example-explicit example-compat; do
84 for server in $*; do
85 for name in ns mx a aaaa cname dname txt rrsig nsec \
86 dnskey ds cdnskey cds; do
87 $DIG $DIGOPTS $name.$zone. $name @10.53.0.$server -p 5300
88 echo
89 done > dig.out.$zone.$server
90 done
91 $PERL ../digcomp.pl dig.out.$zone.1 dig.out.$zone.2 || ret=1
92 if [ $zone = "example" ]; then
93 set -- 1 2
94 $PERL ../digcomp.pl dig.out.$zone.1 dig.out.$zone.3 || ret=1
96 done
97 [ $ret -eq 0 ] || echo "I:failed"
98 status=`expr $status + $ret`
100 echo "I:checking raw format versions"
101 ret=0
102 israw ns1/example.db.raw || ret=1
103 israw ns1/example.db.raw1 || ret=1
104 israw ns1/example.db.compat || ret=1
105 ismap ns1/example.db.map || ret=1
106 [ "`rawversion ns1/example.db.raw`" = 1 ] || ret=1
107 [ "`rawversion ns1/example.db.raw1`" = 1 ] || ret=1
108 [ "`rawversion ns1/example.db.compat`" = 0 ] || ret=1
109 [ "`rawversion ns1/example.db.map`" = 1 ] || ret=1
110 [ $ret -eq 0 ] || echo "I:failed"
111 status=`expr $status + $ret`
113 echo "I:checking source serial numbers"
114 ret=0
115 [ "`sourceserial ns1/example.db.raw`" = "UNSET" ] || ret=1
116 [ "`sourceserial ns1/example.db.serial.raw`" = "3333" ] || ret=1
117 [ $ret -eq 0 ] || echo "I:failed"
118 status=`expr $status + $ret`
120 echo "I:waiting for transfers to complete"
121 for i in 0 1 2 3 4 5 6 7 8 9
123 test -f ns2/transfer.db.raw -a -f ns2/transfer.db.txt && break
124 sleep 1
125 done
127 echo "I:checking that slave was saved in raw format by default"
128 ret=0
129 israw ns2/transfer.db.raw || ret=1
130 [ $ret -eq 0 ] || echo "I:failed"
131 status=`expr $status + $ret`
133 echo "I:checking that slave was saved in text format when configured"
134 ret=0
135 israw ns2/transfer.db.txt && ret=1
136 [ $ret -eq 0 ] || echo "I:failed"
137 status=`expr $status + $ret`
139 echo "I:checking that slave formerly in text format is now raw"
140 for i in 0 1 2 3 4 5 6 7 8 9
142 ret=0
143 israw ns2/formerly-text.db > /dev/null 2>&1 || ret=1
144 [ "`rawversion ns2/formerly-text.db`" = 1 ] || ret=1
145 [ $ret -eq 0 ] && break
146 sleep 1
147 done
148 [ $ret -eq 0 ] || echo "I:failed"
149 status=`expr $status + $ret`
151 echo "I:checking that large rdatasets loaded"
152 for i in 0 1 2 3 4 5 6 7 8 9
154 ret=0
155 for a in a b c
157 $DIG +tcp txt ${a}.large @10.53.0.2 -p 5300 > dig.out
158 grep "status: NOERROR" dig.out > /dev/null || ret=1
159 done
160 [ $ret -eq 0 ] && break
161 sleep 1
162 done
164 echo "I:checking format transitions: text->raw->map->text"
165 ret=0
166 ./named-compilezone -D -f text -F text -o baseline.txt example.nil ns1/example.db > /dev/null
167 ./named-compilezone -D -f text -F raw -o raw.1 example.nil baseline.txt > /dev/null
168 ./named-compilezone -D -f raw -F map -o map.1 example.nil raw.1 > /dev/null
169 ./named-compilezone -D -f map -F text -o text.1 example.nil map.1 > /dev/null
170 cmp -s baseline.txt text.1 || ret=0
171 [ $ret -eq 0 ] || echo "I:failed"
172 status=`expr $status + $ret`
174 echo "I:checking format transitions: text->map->raw->text"
175 ret=0
176 ./named-compilezone -D -f text -F map -o map.2 example.nil baseline.txt > /dev/null
177 ./named-compilezone -D -f map -F raw -o raw.2 example.nil map.2 > /dev/null
178 ./named-compilezone -D -f raw -F text -o text.2 example.nil raw.2 > /dev/null
179 cmp -s baseline.txt text.2 || ret=0
180 [ $ret -eq 0 ] || echo "I:failed"
181 status=`expr $status + $ret`
183 echo "I:checking map format loading with journal file rollforward"
184 ret=0
185 $NSUPDATE <<END > /dev/null || status=1
186 server 10.53.0.3 5300
187 ttl 600
188 update add newtext.dynamic IN TXT "added text"
189 update delete aaaa.dynamic
190 send
192 $DIG $DIGOPTS @10.53.0.3 -p 5300 newtext.dynamic txt > dig.out.dynamic.3.1
193 grep "added text" dig.out.dynamic.3.1 > /dev/null 2>&1 || ret=1
194 $DIG $DIGOPTS +comm @10.53.0.3 -p 5300 added.dynamic txt > dig.out.dynamic.3.2
195 grep "NXDOMAIN" dig.out.dynamic.3.2 > /dev/null 2>&1 || ret=1
196 # using "rndc halt" ensures that we don't dump the zone file
197 $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 halt 2>&1 | sed 's/^/I:ns3 /'
198 restart
199 for i in 0 1 2 3 4 5 6 7 8 9; do
200 lret=0
201 $DIG $DIGOPTS @10.53.0.3 -p 5300 newtext.dynamic txt > dig.out.dynamic.3.3
202 grep "added text" dig.out.dynamic.3.3 > /dev/null 2>&1 || lret=1
203 [ $lret -eq 0 ] && break;
204 done
205 [ $lret -eq 1 ] && ret=1
206 $DIG $DIGOPTS +comm @10.53.0.3 -p 5300 added.dynamic txt > dig.out.dynamic.3.4
207 grep "NXDOMAIN" dig.out.dynamic.3.4 > /dev/null 2>&1 || ret=1
208 [ $ret -eq 0 ] || echo "I:failed"
209 status=`expr $status + $ret`
211 echo "I:checking map format file dumps correctly"
212 ret=0
213 $NSUPDATE <<END > /dev/null || status=1
214 server 10.53.0.3 5300
215 ttl 600
216 update add moretext.dynamic IN TXT "more text"
217 send
219 $DIG $DIGOPTS @10.53.0.3 -p 5300 moretext.dynamic txt > dig.out.dynamic.3.5
220 grep "more text" dig.out.dynamic.3.5 > /dev/null 2>&1 || ret=1
221 # using "rndc stop" will cause the zone file to flush before shutdown
222 $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 stop 2>&1 | sed 's/^/I:ns3 /'
223 rm ns3/*.jnl
224 restart
225 for i in 0 1 2 3 4 5 6 7 8 9; do
226 lret=0
227 $DIG $DIGOPTS +comm @10.53.0.3 -p 5300 moretext.dynamic txt > dig.out.dynamic.3.6
228 grep "more text" dig.out.dynamic.3.6 > /dev/null 2>&1 || lret=1
229 [ $lret -eq 0 ] && break;
230 done
231 [ $lret -eq 1 ] && ret=1
232 [ $ret -eq 0 ] || echo "I:failed"
233 status=`expr $status + $ret`
235 # stomp on the file data so it hashes differently.
236 # these are small and subtle changes, so that the resulting file
237 # would appear to be a legitimate map file and would not trigger an
238 # assertion failure if loaded into memory, but should still fail to
239 # load because of a SHA1 hash mismatch.
240 echo "I:checking corrupt map files fail to load (bad node header)"
241 ret=0
242 ./named-compilezone -D -f text -F map -o map.5 example.nil baseline.txt > /dev/null
243 cp map.5 badmap
244 stomp badmap 2754 2 99
245 ./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
246 [ $? = 1 ] || ret=1
247 [ $ret -eq 0 ] || echo "I:failed"
248 status=`expr $status + $ret`
250 echo "I:checking corrupt map files fail to load (bad node data)"
251 ret=0
252 cp map.5 badmap
253 stomp badmap 2897 5 127
254 ./named-compilezone -D -f map -F text -o text.5 example.nil badmap > /dev/null
255 [ $? = 1 ] || ret=1
256 [ $ret -eq 0 ] || echo "I:failed"
257 status=`expr $status + $ret`
259 echo "I:checking map format zone is scheduled for resigning (compilezone)"
260 ret=0
261 $RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus signed > rndc.out 2>&1 || ret=1
262 grep 'next resign' rndc.out > /dev/null 2>&1 || ret=1
263 [ $ret -eq 0 ] || echo "I:failed"
264 status=`expr $status + $ret`
266 echo "I:checking map format zone is scheduled for resigning (signzone)"
267 ret=0
268 $RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 freeze signed > rndc.out 2>&1 || ret=1
269 cd ns1
270 $SIGNER -S -O map -f signed.db.map -o signed signed.db > /dev/null 2>&1
271 cd ..
272 $RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 reload signed > rndc.out 2>&1 || ret=1
273 $RNDC -c ../common/rndc.conf -s 10.53.0.1 -p 9953 zonestatus signed > rndc.out 2>&1 || ret=1
274 grep 'next resign' rndc.out > /dev/null 2>&1 || ret=1
275 [ $ret -eq 0 ] || echo "I:failed"
276 status=`expr $status + $ret`
278 echo "I:exit status: $status"
279 exit $status