xref: /minix3/external/bsd/bind/dist/bin/tests/system/rrsetorder/tests.sh (revision 00b67f09dd46474d133c95011a48590a8e8f94c7)
1#!/bin/sh
2#
3# Copyright (C) 2006-2008, 2011, 2012, 2014  Internet Systems Consortium, Inc. ("ISC")
4#
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.
8#
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.
16
17SYSTEMTESTTOP=..
18. $SYSTEMTESTTOP/conf.sh
19
20status=0
21
22if grep "^#define DNS_RDATASET_FIXED" $TOP/config.h > /dev/null 2>&1 ; then
23        test_fixed=true
24else
25        echo "I: Order 'fixed' disabled at compile time"
26        test_fixed=false
27fi
28
29#
30#
31#
32if $test_fixed; then
33    echo "I: Checking order fixed (master)"
34    ret=0
35    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
36    do
37    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
38	    -p 5300 @10.53.0.1 fixed.example > dig.out.fixed || ret=1
39    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
40    done
41    if [ $ret != 0 ]; then echo "I:failed"; fi
42    status=`expr $status + $ret`
43else
44    echo "I: Checking order fixed behaves as cyclic when disabled (master)"
45    ret=0
46    matches=0
47    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
48    do
49        j=`expr $i % 4`
50        $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
51                -p 5300 @10.53.0.1 fixed.example > dig.out.fixed  || ret=1
52        if [ $i -le 4 ]; then
53            cp dig.out.fixed dig.out.$j
54        else
55            cmp -s dig.out.fixed dig.out.$j && matches=`expr $matches + 1`
56        fi
57    done
58    cmp -s dig.out.0 dig.out.1 && ret=1
59    cmp -s dig.out.0 dig.out.2 && ret=1
60    cmp -s dig.out.0 dig.out.3 && ret=1
61    cmp -s dig.out.1 dig.out.2 && ret=1
62    cmp -s dig.out.1 dig.out.3 && ret=1
63    cmp -s dig.out.2 dig.out.3 && ret=1
64    if [ $matches -ne 16 ]; then ret=1; fi
65    if [ $ret != 0 ]; then echo "I:failed"; fi
66    status=`expr $status + $ret`
67fi
68
69#
70#
71#
72echo "I: Checking order cyclic (master + additional)"
73ret=0
74matches=0
75for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
76do
77    j=`expr $i % 4`
78    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
79	    -p 5300 @10.53.0.1 cyclic.example > dig.out.cyclic || ret=1
80    if [ $i -le 4 ]; then
81        cp dig.out.cyclic dig.out.$j
82    else
83        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
84    fi
85done
86cmp -s dig.out.0 dig.out.1 && ret=1
87cmp -s dig.out.0 dig.out.2 && ret=1
88cmp -s dig.out.0 dig.out.3 && ret=1
89cmp -s dig.out.1 dig.out.2 && ret=1
90cmp -s dig.out.1 dig.out.3 && ret=1
91cmp -s dig.out.2 dig.out.3 && ret=1
92if [ $matches -ne 16 ]; then ret=1; fi
93if [ $ret != 0 ]; then echo "I:failed"; fi
94status=`expr $status + $ret`
95
96#
97#
98#
99echo "I: Checking order cyclic (master)"
100ret=0
101matches=0
102for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
103do
104    j=`expr $i % 4`
105    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
106	    -p 5300 @10.53.0.1 cyclic2.example > dig.out.cyclic2 || ret=1
107    if [ $i -le 4 ]; then
108        cp dig.out.cyclic2 dig.out.$j
109    else
110        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
111    fi
112done
113cmp -s dig.out.0 dig.out.1 && ret=1
114cmp -s dig.out.0 dig.out.2 && ret=1
115cmp -s dig.out.0 dig.out.3 && ret=1
116cmp -s dig.out.1 dig.out.2 && ret=1
117cmp -s dig.out.1 dig.out.3 && ret=1
118cmp -s dig.out.2 dig.out.3 && ret=1
119if [ $matches -ne 16 ]; then ret=1; fi
120if [ $ret != 0 ]; then echo "I:failed"; fi
121status=`expr $status + $ret`
122echo "I: Checking order random (master)"
123ret=0
124for i 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
125do
126	eval match$i=0
127done
128for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
129do
130$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
131	-p 5300 @10.53.0.1 random.example > dig.out.random || ret=1
132	match=0
133	for j 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
134	do
135		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
136		if [ $match -eq 1 ]; then break; fi
137	done
138	if [ $match -eq 0 ]; then ret=1; fi
139done
140match=0
141for i 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
142do
143	eval "match=\`expr \$match + \$match$i\`"
144done
145echo "I: Random selection return $match of 24 possible orders in 36 samples"
146if [ $match -lt 8 ]; then echo ret=1; fi
147if [ $ret != 0 ]; then echo "I:failed"; fi
148status=`expr $status + $ret`
149
150#
151#
152#
153if $test_fixed; then
154    echo "I: Checking order fixed (slave)"
155    ret=0
156    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
157    do
158    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
159	    -p 5300 @10.53.0.2 fixed.example > dig.out.fixed || ret=1
160    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
161    done
162    if [ $ret != 0 ]; then echo "I:failed"; fi
163    status=`expr $status + $ret`
164fi
165
166#
167#
168#
169echo "I: Checking order cyclic (slave + additional)"
170ret=0
171matches=0
172for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
173do
174    j=`expr $i % 4`
175    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
176	    -p 5300 @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1
177    if [ $i -le 4 ]; then
178        cp dig.out.cyclic dig.out.$j
179    else
180        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
181    fi
182done
183cmp -s dig.out.0 dig.out.1 && ret=1
184cmp -s dig.out.0 dig.out.2 && ret=1
185cmp -s dig.out.0 dig.out.3 && ret=1
186cmp -s dig.out.1 dig.out.2 && ret=1
187cmp -s dig.out.1 dig.out.3 && ret=1
188cmp -s dig.out.2 dig.out.3 && ret=1
189if [ $matches -ne 16 ]; then ret=1; fi
190if [ $ret != 0 ]; then echo "I:failed"; fi
191status=`expr $status + $ret`
192
193#
194#
195#
196echo "I: Checking order cyclic (slave)"
197ret=0
198matches=0
199for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
200do
201    j=`expr $i % 4`
202    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
203	    -p 5300 @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1
204    if [ $i -le 4 ]; then
205        cp dig.out.cyclic2 dig.out.$j
206    else
207        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
208    fi
209done
210cmp -s dig.out.0 dig.out.1 && ret=1
211cmp -s dig.out.0 dig.out.2 && ret=1
212cmp -s dig.out.0 dig.out.3 && ret=1
213cmp -s dig.out.1 dig.out.2 && ret=1
214cmp -s dig.out.1 dig.out.3 && ret=1
215cmp -s dig.out.2 dig.out.3 && ret=1
216if [ $matches -ne 16 ]; then ret=1; fi
217if [ $ret != 0 ]; then echo "I:failed"; fi
218status=`expr $status + $ret`
219
220echo "I: Checking order random (slave)"
221ret=0
222for i 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
223do
224	eval match$i=0
225done
226for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
227do
228$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
229	-p 5300 @10.53.0.2 random.example > dig.out.random || ret=1
230	match=0
231	for j 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
232	do
233		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
234		if [ $match -eq 1 ]; then break; fi
235	done
236	if [ $match -eq 0 ]; then ret=1; fi
237done
238match=0
239for i 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
240do
241eval "match=\`expr \$match + \$match$i\`"
242done
243echo "I: Random selection return $match of 24 possible orders in 36 samples"
244if [ $match -lt 8 ]; then echo ret=1; fi
245if [ $ret != 0 ]; then echo "I:failed"; fi
246status=`expr $status + $ret`
247
248echo "I: Shutting down slave"
249
250(cd ..; $SHELL stop.sh rrsetorder ns2 )
251
252echo "I: Checking for slave's on disk copy of zone"
253
254if [ ! -f ns2/root.bk ]
255then
256	echo "I:failed";
257	status=`expr $status + 1`
258fi
259
260echo "I: Re-starting slave"
261
262(cd ..; $SHELL start.sh --noclean rrsetorder ns2 )
263
264#
265#
266#
267if $test_fixed; then
268    echo "I: Checking order fixed (slave loaded from disk)"
269    ret=0
270    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
271    do
272    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
273	    -p 5300 @10.53.0.2 fixed.example > dig.out.fixed || ret=1
274    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
275    done
276    if [ $ret != 0 ]; then echo "I:failed"; fi
277    status=`expr $status + $ret`
278fi
279
280#
281#
282#
283echo "I: Checking order cyclic (slave + additional, loaded from disk)"
284ret=0
285matches=0
286for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
287do
288    j=`expr $i % 4`
289    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
290	    -p 5300 @10.53.0.2 cyclic.example > dig.out.cyclic || ret=1
291    if [ $i -le 4 ]; then
292        cp dig.out.cyclic dig.out.$j
293    else
294        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
295    fi
296done
297cmp -s dig.out.0 dig.out.1 && ret=1
298cmp -s dig.out.0 dig.out.2 && ret=1
299cmp -s dig.out.0 dig.out.3 && ret=1
300cmp -s dig.out.1 dig.out.2 && ret=1
301cmp -s dig.out.1 dig.out.3 && ret=1
302cmp -s dig.out.2 dig.out.3 && ret=1
303if [ $matches -ne 16 ]; then ret=1; fi
304if [ $ret != 0 ]; then echo "I:failed"; fi
305status=`expr $status + $ret`
306
307#
308#
309#
310echo "I: Checking order cyclic (slave loaded from disk)"
311ret=0
312matches=0
313for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
314do
315    j=`expr $i % 4`
316    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
317	    -p 5300 @10.53.0.2 cyclic2.example > dig.out.cyclic2 || ret=1
318    if [ $i -le 4 ]; then
319        cp dig.out.cyclic2 dig.out.$j
320    else
321        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
322    fi
323done
324cmp -s dig.out.0 dig.out.1 && ret=1
325cmp -s dig.out.0 dig.out.2 && ret=1
326cmp -s dig.out.0 dig.out.3 && ret=1
327cmp -s dig.out.1 dig.out.2 && ret=1
328cmp -s dig.out.1 dig.out.3 && ret=1
329cmp -s dig.out.2 dig.out.3 && ret=1
330if [ $matches -ne 16 ]; then ret=1; fi
331if [ $ret != 0 ]; then echo "I:failed"; fi
332status=`expr $status + $ret`
333
334echo "I: Checking order random (slave loaded from disk)"
335ret=0
336for i 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
337do
338	eval match$i=0
339done
340for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
341do
342$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
343	-p 5300 @10.53.0.2 random.example > dig.out.random || ret=1
344	match=0
345	for j 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
346	do
347		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
348		if [ $match -eq 1 ]; then break; fi
349	done
350	if [ $match -eq 0 ]; then ret=1; fi
351done
352match=0
353for i 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
354do
355eval "match=\`expr \$match + \$match$i\`"
356done
357echo "I: Random selection return $match of 24 possible orders in 36 samples"
358if [ $match -lt 8 ]; then echo ret=1; fi
359if [ $ret != 0 ]; then echo "I:failed"; fi
360status=`expr $status + $ret`
361
362#
363#
364#
365if $test_fixed; then
366    echo "I: Checking order fixed (cache)"
367    ret=0
368    for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
369    do
370    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
371	    -p 5300 @10.53.0.3 fixed.example > dig.out.fixed || ret=1
372    cmp -s dig.out.fixed dig.out.fixed.good || ret=1
373    done
374    if [ $ret != 0 ]; then echo "I:failed"; fi
375    status=`expr $status + $ret`
376fi
377
378#
379#
380#
381echo "I: Checking order cyclic (cache + additional)"
382ret=0
383# prime acache
384$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
385	    -p 5300 @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1
386matches=0
387for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
388do
389    j=`expr $i % 4`
390    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
391	    -p 5300 @10.53.0.3 cyclic.example > dig.out.cyclic || ret=1
392    if [ $i -le 4 ]; then
393        cp dig.out.cyclic dig.out.$j
394    else
395        cmp -s dig.out.cyclic dig.out.$j && matches=`expr $matches + 1`
396    fi
397done
398cmp -s dig.out.0 dig.out.1 && ret=1
399cmp -s dig.out.0 dig.out.2 && ret=1
400cmp -s dig.out.0 dig.out.3 && ret=1
401cmp -s dig.out.1 dig.out.2 && ret=1
402cmp -s dig.out.1 dig.out.3 && ret=1
403cmp -s dig.out.2 dig.out.3 && ret=1
404if [ $matches -ne 16 ]; then ret=1; fi
405if [ $ret != 0 ]; then echo "I:failed"; fi
406status=`expr $status + $ret`
407
408#
409#
410#
411echo "I: Checking order cyclic (cache)"
412ret=0
413# prime acache
414$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
415	    -p 5300 @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1
416matches=0
417for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
418do
419    j=`expr $i % 4`
420    $DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
421	    -p 5300 @10.53.0.3 cyclic2.example > dig.out.cyclic2 || ret=1
422    if [ $i -le 4 ]; then
423        cp dig.out.cyclic2 dig.out.$j
424    else
425        cmp -s dig.out.cyclic2 dig.out.$j && matches=`expr $matches + 1`
426    fi
427done
428cmp -s dig.out.0 dig.out.1 && ret=1
429cmp -s dig.out.0 dig.out.2 && ret=1
430cmp -s dig.out.0 dig.out.3 && ret=1
431cmp -s dig.out.1 dig.out.2 && ret=1
432cmp -s dig.out.1 dig.out.3 && ret=1
433cmp -s dig.out.2 dig.out.3 && ret=1
434if [ $matches -ne 16 ]; then ret=1; fi
435if [ $ret != 0 ]; then echo "I:failed"; fi
436status=`expr $status + $ret`
437
438echo "I: Checking order random (cache)"
439ret=0
440for i 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
441do
442	eval match$i=0
443done
444for i in a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 9
445do
446$DIG +nosea +nocomm +nocmd +noquest +noadd +noauth +nocomm +nostat +short \
447	-p 5300 @10.53.0.3 random.example > dig.out.random || ret=1
448	match=0
449	for j 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
450	do
451		eval "cmp -s dig.out.random dig.out.random.good$j && match$j=1 match=1"
452		if [ $match -eq 1 ]; then break; fi
453	done
454	if [ $match -eq 0 ]; then ret=1; fi
455done
456match=0
457for i 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
458do
459eval "match=\`expr \$match + \$match$i\`"
460done
461echo "I: Random selection return $match of 24 possible orders in 36 samples"
462if [ $match -lt 8 ]; then echo ret=1; fi
463if [ $ret != 0 ]; then echo "I:failed"; fi
464
465status=`expr $status + $ret`
466echo "I:exit status: $status"
467exit $status
468