xref: /netbsd-src/external/mpl/bind/dist/bin/tests/system/nslookup/tests.sh (revision 154bfe8e089c1a0a4e9ed8414f08d3da90949162)
1#!/bin/sh
2#
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# This Source Code Form is subject to the terms of the Mozilla Public
6# License, v. 2.0. If a copy of the MPL was not distributed with this
7# file, You can obtain one at http://mozilla.org/MPL/2.0/.
8#
9# See the COPYRIGHT file distributed with this work for additional
10# information regarding copyright ownership.
11
12SYSTEMTESTTOP=..
13. $SYSTEMTESTTOP/conf.sh
14
15status=0
16n=0
17
18n=`expr $n + 1`
19echo_i "Check that domain names that are too big when applying a search list entry are handled cleanly ($n)"
20ret=0
21l=012345678901234567890123456789012345678901234567890123456789012
22t=0123456789012345678901234567890123456789012345678901234567890
23d=$l.$l.$l.$t
24$NSLOOKUP -port=${PORT} -domain=$d -type=soa example 10.53.0.1 > nslookup.out${n} || ret=1
25grep "origin = ns1.example" nslookup.out${n} > /dev/null || ret=1
26if [ $ret != 0 ]; then echo_i "failed"; fi
27status=`expr $status + $ret`
28
29n=`expr $n + 1`
30echo_i "Check A only lookup"
31ret=0
32$NSLOOKUP -port=${PORT} a-only.example.net 10.53.0.1 > nslookup.out${n} || ret=1
33lines=`grep "Server:" nslookup.out${n} | wc -l`
34test $lines = 1 || ret=1
35lines=`grep a-only.example.net nslookup.out${n} | wc -l`
36test $lines = 1 || ret=1
37grep "1.2.3.4" nslookup.out${n} > /dev/null || ret=1
38if [ $ret != 0 ]; then echo_i "failed"; fi
39status=`expr $status + $ret`
40
41n=`expr $n + 1`
42echo_i "Check AAAA only lookup"
43ret=0
44$NSLOOKUP -port=${PORT} aaaa-only.example.net 10.53.0.1 > nslookup.out${n} || ret=1
45lines=`grep "Server:" nslookup.out${n} | wc -l`
46test $lines = 1 || ret=1
47lines=`grep aaaa-only.example.net nslookup.out${n} | wc -l`
48test $lines = 1 || ret=1
49grep "2001::ffff" nslookup.out${n} > /dev/null || ret=1
50if [ $ret != 0 ]; then echo_i "failed"; fi
51status=`expr $status + $ret`
52
53n=`expr $n + 1`
54echo_i "Check dual A + AAAA lookup"
55ret=0
56$NSLOOKUP -port=${PORT} dual.example.net 10.53.0.1 > nslookup.out${n} || ret=1
57lines=`grep "Server:" nslookup.out${n} | wc -l`
58test $lines = 1 || ret=1
59lines=`grep dual.example.net nslookup.out${n} | wc -l`
60test $lines = 2 || ret=1
61grep "1.2.3.4" nslookup.out${n} > /dev/null || ret=1
62grep "2001::ffff" nslookup.out${n} > /dev/null || ret=1
63if [ $ret != 0 ]; then echo_i "failed"; fi
64status=`expr $status + $ret`
65
66n=`expr $n + 1`
67echo_i "Check CNAME to A only lookup"
68ret=0
69$NSLOOKUP -port=${PORT} cname-a-only.example.net 10.53.0.1 > nslookup.out${n} || ret=1
70lines=`grep "Server:" nslookup.out${n} | wc -l`
71test $lines = 1 || ret=1
72lines=`grep "canonical name" nslookup.out${n} | wc -l`
73test $lines = 1 || ret=1
74lines=`grep a-only.example.net nslookup.out${n} | grep -v "canonical name" | wc -l`
75test $lines = 1 || ret=1
76grep "1.2.3.4" nslookup.out${n} > /dev/null || ret=1
77if [ $ret != 0 ]; then echo_i "failed"; fi
78status=`expr $status + $ret`
79
80n=`expr $n + 1`
81echo_i "Check CNAME to AAAA only lookup"
82ret=0
83$NSLOOKUP -port=${PORT} cname-aaaa-only.example.net 10.53.0.1 > nslookup.out${n} || ret=1
84lines=`grep "Server:" nslookup.out${n} | wc -l`
85test $lines = 1 || ret=1
86lines=`grep "canonical name" nslookup.out${n} | wc -l`
87test $lines = 1 || ret=1
88lines=`grep aaaa-only.example.net nslookup.out${n} | grep -v "canonical name" |wc -l`
89test $lines = 1 || ret=1
90grep "2001::ffff" nslookup.out${n} > /dev/null || ret=1
91if [ $ret != 0 ]; then echo_i "failed"; fi
92status=`expr $status + $ret`
93
94n=`expr $n + 1`
95echo_i "Check CNAME to dual A + AAAA lookup"
96ret=0
97$NSLOOKUP -port=${PORT} cname-dual.example.net 10.53.0.1 > nslookup.out${n} || ret=1
98lines=`grep "Server:" nslookup.out${n} | wc -l`
99test $lines = 1 || ret=1
100lines=`grep "canonical name" nslookup.out${n} | wc -l`
101test $lines = 1 || ret=1
102lines=`grep dual.example.net nslookup.out${n} | grep -v "canonical name" | wc -l`
103test $lines = 2 || ret=1
104grep "1.2.3.4" nslookup.out${n} > /dev/null || ret=1
105grep "2001::ffff" nslookup.out${n} > /dev/null || ret=1
106if [ $ret != 0 ]; then echo_i "failed"; fi
107status=`expr $status + $ret`
108
109echo_i "exit status: $status"
110[ $status -eq 0 ] || exit 1
111