xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/unknown/tests.sh (revision 4ac76180e904e771b9d522c7e57296d371f06499)
1#!/bin/sh
2
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0.  If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14SYSTEMTESTTOP=..
15. $SYSTEMTESTTOP/conf.sh
16
17status=0
18n=0
19
20DIGOPTS="-p ${PORT}"
21
22n=$((n+1))
23echo_i "querying for various representations of an IN A record ($n)"
24for i in 1 2 3 4 5 6 7 8 9 10 11 12
25do
26	ret=0
27	$DIG +short $DIGOPTS @10.53.0.1 a$i.example a in > dig.out.$i.test$n || ret=1
28	echo 10.0.0.1 | $DIFF - dig.out.$i.test$n || ret=1
29	if [ $ret != 0 ]
30	then
31		echo_i "#$i failed"
32	fi
33	status=`expr $status + $ret`
34done
35
36n=$((n+1))
37echo_i "querying for various representations of an IN TXT record ($n)"
38for i in 1 2 3 4 5 6 7
39do
40	ret=0
41	$DIG +short $DIGOPTS @10.53.0.1 txt$i.example txt in > dig.out.$i.test$n || ret=1
42	echo '"hello"' | $DIFF - dig.out.$i.test$n || ret=1
43	if [ $ret != 0 ]
44	then
45		echo_i "#$i failed"
46	fi
47	status=`expr $status + $ret`
48done
49
50n=$((n+1))
51echo_i "querying for various representations of an IN TYPE123 record ($n)"
52for i in 1 2 3
53do
54	ret=0
55	$DIG +short $DIGOPTS @10.53.0.1 unk$i.example type123 in > dig.out.$i.test$n || ret=1
56	echo '\# 1 00' | $DIFF - dig.out.$i.test$n || ret=1
57	if [ $ret != 0 ]
58	then
59		echo_i "#$i failed"
60	fi
61	status=`expr $status + $ret`
62done
63
64n=$((n+1))
65echo_i "querying for NULL record ($n)"
66ret=0
67$DIG +short $DIGOPTS @10.53.0.1 null.example null in > dig.out.test$n || ret=1
68echo '\# 1 00' | $DIFF - dig.out.test$n || ret=1
69[ $ret = 0 ] || echo_i "failed"
70status=`expr $status + $ret`
71
72n=$((n+1))
73echo_i "querying for empty NULL record ($n)"
74ret=0
75$DIG +short $DIGOPTS @10.53.0.1 empty.example null in > dig.out.test$n || ret=1
76echo '\# 0' | $DIFF - dig.out.test$n || ret=1
77[ $ret = 0 ] || echo_i "failed"
78status=`expr $status + $ret`
79
80n=$((n+1))
81echo_i "querying for various representations of a CLASS10 TYPE1 record ($n)"
82for i in 1 2
83do
84	ret=0
85	$DIG +short $DIGOPTS @10.53.0.1 a$i.example a class10 > dig.out.$i.test$n || ret=1
86	echo '\# 4 0A000001' | $DIFF - dig.out.$i.test$n || ret=1
87	if [ $ret != 0 ]
88	then
89		echo_i "#$i failed"
90	fi
91	status=`expr $status + $ret`
92done
93
94n=$((n+1))
95echo_i "querying for various representations of a CLASS10 TXT record ($n)"
96for i in 1 2 3 4
97do
98	ret=0
99	$DIG +short $DIGOPTS @10.53.0.1 txt$i.example txt class10 > dig.out.$i.test$n || ret=1
100	echo '"hello"' | $DIFF - dig.out.$i.test$n || ret=1
101	if [ $ret != 0 ]
102	then
103		echo_i "#$i failed"
104	fi
105	status=`expr $status + $ret`
106done
107
108n=$((n+1))
109echo_i "querying for various representations of a CLASS10 TYPE123 record ($n)"
110for i in 1 2
111do
112	ret=0
113	$DIG +short $DIGOPTS @10.53.0.1 unk$i.example type123 class10 > dig.out.$i.test$n || ret=1
114	echo '\# 1 00' | $DIFF - dig.out.$i.test$n || ret=1
115	if [ $ret != 0 ]
116	then
117		echo_i "#$i failed"
118	fi
119	status=`expr $status + $ret`
120done
121
122n=$((n+1))
123echo_i "querying for SOAs of zone that should have failed to load ($n)"
124for i in 1 2 3 4
125do
126	ret=0
127	$DIG $DIGOPTS @10.53.0.1 broken$i. soa in > dig.out.$i.test$n || ret=1
128	grep "SERVFAIL" dig.out.$i.test$n > /dev/null || ret=1
129	if [ $ret != 0 ]
130	then
131		echo_i "#$i failed"
132	fi
133	status=`expr $status + $ret`
134done
135
136n=$((n+1))
137echo_i "checking large unknown record loading on primary ($n)"
138for try in 0 1 2 3 4 5 6 7 8 9; do
139    ret=0
140    $DIG $DIGOPTS @10.53.0.1 +tcp +short large.example TYPE45234 > dig.out.$i.test$n || { ret=1 ; echo_i "dig failed" ; }
141    $DIFF -s large.out dig.out.$i.test$n > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
142    [ "$ret" -eq 0 ] && break
143    sleep 1
144done
145[ $ret = 0 ] || echo_i "failed"
146status=`expr $status + $ret`
147
148n=$((n+1))
149echo_i "checking large unknown record loading on secondary ($n)"
150for try in 0 1 2 3 4 5 6 7 8 9; do
151    ret=0
152    $DIG $DIGOPTS @10.53.0.2 +tcp +short large.example TYPE45234 > dig.out.$i.test$n || { ret=1 ; echo_i "dig failed" ; }
153    $DIFF -s large.out dig.out.$i.test$n > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
154    [ "$ret" -eq 0 ] && break
155    sleep 1
156done
157[ $ret = 0 ] || echo_i "failed"
158status=`expr $status + $ret`
159
160echo_i "stop and restart secondary"
161stop_server ns2
162start_server --noclean --restart --port ${PORT} ns2
163
164# server may be answering queries before zones are loaded,
165# so retry a few times if this query fails
166n=$((n+1))
167echo_i "checking large unknown record loading on secondary ($n)"
168for try in 0 1 2 3 4 5 6 7 8 9; do
169    ret=0
170    $DIG $DIGOPTS @10.53.0.2 +tcp +short large.example TYPE45234 > dig.out.$i.test$n || { ret=1 ; echo_i "dig failed" ; }
171    $DIFF -s large.out dig.out.$i.test$n > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
172    [ "$ret" -eq 0 ] && break
173    sleep 1
174done
175[ $ret = 0 ] || echo_i "failed"
176status=`expr $status + $ret`
177
178n=$((n+1))
179echo_i "checking large unknown record loading on inline secondary ($n)"
180ret=0
181$DIG $DIGOPTS @10.53.0.3 +tcp +short large.example TYPE45234 > dig.out.test$n || { ret=1 ; echo_i "dig failed" ; }
182$DIFF large.out dig.out.test$n > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
183[ $ret = 0 ] || echo_i "failed"
184status=`expr $status + $ret`
185
186echo_i "stop and restart inline secondary"
187stop_server ns3
188start_server --noclean --restart --port ${PORT} ns3
189
190# server may be answering queries before zones are loaded,
191# so retry a few times if this query fails
192n=$((n+1))
193echo_i "checking large unknown record loading on inline secondary ($n)"
194for try in 0 1 2 3 4 5 6 7 8 9; do
195    ret=0
196    $DIG $DIGOPTS @10.53.0.3 +tcp +short large.example TYPE45234 > dig.out.$i.test$n || { ret=1 ; echo_i "dig failed" ; }
197    $DIFF large.out dig.out.$i.test$n > /dev/null || { ret=1 ; echo_i "$DIFF failed"; }
198    [ "$ret" -eq 0 ] && break
199    sleep 1
200done
201[ $ret = 0 ] || echo_i "failed"
202status=`expr $status + $ret`
203
204n=$((n+1))
205echo_i "check that '"'"\\#"'"' is not treated as the unknown escape sequence ($n)"
206ret=0
207$DIG $DIGOPTS @10.53.0.1 +tcp +short txt8.example txt > dig.out.test$n
208echo '"#" "2" "0145"' | $DIFF - dig.out.test$n || ret=1
209[ $ret = 0 ] || echo_i "failed"
210status=`expr $status + $ret`
211
212n=$((n+1))
213echo_i "check that 'TXT \# text' is not treated as the unknown escape sequence ($n)"
214ret=0
215$DIG $DIGOPTS @10.53.0.1 +tcp +short txt9.example txt > dig.out.test$n
216echo '"#" "text"' | $DIFF - dig.out.test$n || ret=1
217[ $ret = 0 ] || echo_i "failed"
218status=`expr $status + $ret`
219
220n=$((n+1))
221echo_i "check that 'TYPE353 \# cat' produces 'not a valid number' ($n)"
222ret=0
223$CHECKZONE nan.bad zones/nan.bad > check.out 2>&1
224grep "not a valid number" check.out > /dev/null || ret=1
225[ $ret = 0 ] || echo_i "failed"
226status=`expr $status + $ret`
227
228echo_i "exit status: $status"
229[ $status -eq 0 ] || exit 1
230