xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/checkzone/tests.sh (revision f3cfa6f6ce31685c6c4a758bc430e69eb99f50a4)
1# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
2#
3# This Source Code Form is subject to the terms of the Mozilla Public
4# License, v. 2.0. If a copy of the MPL was not distributed with this
5# file, You can obtain one at http://mozilla.org/MPL/2.0/.
6#
7# See the COPYRIGHT file distributed with this work for additional
8# information regarding copyright ownership.
9
10SYSTEMTESTTOP=..
11. $SYSTEMTESTTOP/conf.sh
12
13status=0
14n=1
15
16for db in zones/good*.db
17do
18	echo_i "checking $db ($n)"
19	ret=0
20	case $db in
21	zones/good-gc-msdcs.db)
22		$CHECKZONE -k fail -i local example $db > test.out.$n 2>&1 || ret=1
23		;;
24	zones/good-dns-sd-reverse.db)
25		$CHECKZONE -k fail -i local 0.0.0.0.in-addr.arpa $db > test.out.$n 2>&1 || ret=1
26		;;
27	*)
28		$CHECKZONE -i local example $db > test.out.$n 2>&1 || ret=1
29		;;
30	esac
31	n=`expr $n + 1`
32	if [ $ret != 0 ]; then echo_i "failed"; fi
33	status=`expr $status + $ret`
34done
35
36for db in zones/bad*.db
37do
38	echo_i "checking $db ($n)"
39	ret=0 v=0
40	case $db in
41	zones/bad-dns-sd-reverse.db)
42		$CHECKZONE -k fail -i local 0.0.0.0.in-addr.arpa $db > test.out.$n 2>&1 || v=$?
43		;;
44	*)
45                $CHECKZONE -i local example $db > test.out.$n 2>&1 || v=$?
46		;;
47	esac
48	test $v = 1 || ret=1
49	n=`expr $n + 1`
50	if [ $ret != 0 ]; then echo_i "failed"; fi
51	status=`expr $status + $ret`
52done
53
54echo_i "checking with journal file ($n)"
55ret=0
56$CHECKZONE -D -o test.orig.db test zones/test1.db > /dev/null 2>&1 || ret=1
57$CHECKZONE -D -o test.changed.db test zones/test2.db > /dev/null 2>&1 || ret=1
58$MAKEJOURNAL test test.orig.db test.changed.db test.orig.db.jnl 2>&1 || ret=1
59jlines=`$JOURNALPRINT test.orig.db.jnl | wc -l`
60[ $jlines = 3 ] || ret=1
61$CHECKZONE -D -j -o test.out1.db test test.orig.db > /dev/null 2>&1 || ret=1
62cmp -s test.changed.db test.out1.db || ret=1
63mv -f test.orig.db.jnl test.journal
64$CHECKZONE -D -J test.journal -o test.out2.db test test.orig.db > /dev/null 2>&1 || ret=1
65cmp -s test.changed.db test.out2.db || ret=1
66n=`expr $n + 1`
67if [ $ret != 0 ]; then echo_i "failed"; fi
68status=`expr $status + $ret`
69
70echo_i "checking with spf warnings ($n)"
71ret=0
72$CHECKZONE example zones/spf.db > test.out1.$n 2>&1 || ret=1
73$CHECKZONE -T ignore example zones/spf.db > test.out2.$n 2>&1 || ret=1
74grep "'x.example' found type SPF" test.out1.$n > /dev/null && ret=1
75grep "'y.example' found type SPF" test.out1.$n > /dev/null || ret=1
76grep "'example' found type SPF" test.out1.$n > /dev/null && ret=1
77grep "'x.example' found type SPF" test.out2.$n > /dev/null && ret=1
78grep "'y.example' found type SPF" test.out2.$n > /dev/null && ret=1
79grep "'example' found type SPF" test.out2.$n > /dev/null && ret=1
80n=`expr $n + 1`
81if [ $ret != 0 ]; then echo_i "failed"; fi
82status=`expr $status + $ret`
83
84echo_i "checking with max ttl (text) ($n)"
85ret=0
86$CHECKZONE -l 300 example zones/good1.db > test.out1.$n 2>&1 && ret=1
87$CHECKZONE -l 600 example zones/good1.db > test.out2.$n 2>&1 || ret=1
88n=`expr $n + 1`
89if [ $ret != 0 ]; then echo_i "failed"; fi
90status=`expr $status + $ret`
91
92echo_i "checking with max ttl (raw) ($n)"
93ret=0
94$CHECKZONE -f raw -l 300 example good1.db.raw > test.out1.$n 2>&1 && ret=1
95$CHECKZONE -f raw -l 600 example good1.db.raw > test.out2.$n 2>&1 || ret=1
96n=`expr $n + 1`
97if [ $ret != 0 ]; then echo_i "failed"; fi
98status=`expr $status + $ret`
99
100echo_i "checking with max ttl (map) ($n)"
101ret=0
102$CHECKZONE -f map -l 300 example good1.db.map > test.out1.$n 2>&1 && ret=1
103$CHECKZONE -f map -l 600 example good1.db.map > test.out2.$n 2>&1 || ret=1
104n=`expr $n + 1`
105if [ $ret != 0 ]; then echo_i "failed"; fi
106status=`expr $status + $ret`
107
108echo_i "checking for no 'inherited owner' warning on '\$INCLUDE file' with no new \$ORIGIN ($n)"
109ret=0
110$CHECKZONE example zones/nowarn.inherited.owner.db > test.out1.$n 2>&1 || ret=1
111grep "inherited.owner" test.out1.$n > /dev/null && ret=1
112n=`expr $n + 1`
113if [ $ret != 0 ]; then echo_i "failed"; fi
114status=`expr $status + $ret`
115
116echo_i "checking for 'inherited owner' warning on '\$ORIGIN + \$INCLUDE file' ($n)"
117ret=0
118$CHECKZONE example zones/warn.inherit.origin.db > test.out1.$n 2>&1 || ret=1
119grep "inherited.owner" test.out1.$n > /dev/null || ret=1
120n=`expr $n + 1`
121if [ $ret != 0 ]; then echo_i "failed"; fi
122status=`expr $status + $ret`
123
124echo_i "checking for 'inherited owner' warning on '\$INCLUDE file origin' ($n)"
125ret=0
126$CHECKZONE example zones/warn.inherited.owner.db > test.out1.$n 2>&1 || ret=1
127grep "inherited.owner" test.out1.$n > /dev/null || ret=1
128n=`expr $n + 1`
129if [ $ret != 0 ]; then echo_i "failed"; fi
130status=`expr $status + $ret`
131
132echo_i "checking that raw zone with bad class is handled ($n)"
133ret=0
134$CHECKZONE -f raw example zones/bad-badclass.raw > test.out.$n 2>&1 && ret=1
135grep "failed: bad class" test.out.$n >/dev/null || ret=1
136n=`expr $n + 1`
137if [ $ret != 0 ]; then echo_i "failed"; fi
138status=`expr $status + $ret`
139
140echo_i "checking that expirations that loop using serial arithmetic are handled ($n)"
141ret=0
142q=-q
143test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
144test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
145test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
146test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
147test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
148test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
149test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
150test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
151test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
152test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
153test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
154test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
155test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
156test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
157test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
158test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
159test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
160test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
161test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
162test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
163test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
164test $ret -eq 1 || $CHECKZONE $q dyn.example.net zones/crashzone.db || ret=1
165n=`expr $n + 1`
166if [ $ret != 0 ]; then echo_i "failed"; fi
167status=`expr $status + $ret`
168
169echo_i "checking that nameserver below DNAME is reported even with occulted address record present ($n)"
170ret=0
171$CHECKZONE example.com zones/ns-address-below-dname.db > test.out.$n 2>&1 && ret=1
172grep "is below a DNAME" test.out.$n >/dev/null || ret=1
173n=`expr $n + 1`
174if [ $ret != 0 ]; then echo_i "failed"; fi
175status=`expr $status + $ret`
176
177echo_i "checking that delegating nameserver below DNAME is reported even with occulted address record present ($n)"
178ret=0
179$CHECKZONE example.com zones/delegating-ns-address-below-dname.db > test.out.$n 2>&1 || ret=1
180grep "is below a DNAME" test.out.$n >/dev/null || ret=1
181n=`expr $n + 1`
182if [ $ret != 0 ]; then echo_i "failed"; fi
183status=`expr $status + $ret`
184
185echo_i "exit status: $status"
186[ $status -eq 0 ] || exit 1
187