xref: /netbsd-src/external/bsd/unbound/dist/testdata/root_hints.tdir/root_hints.test (revision 91f7d55fb697b5e0475da4718fa34c3a3ebeac85)
1*91f7d55fSchristos# #-- root_hints.test --#
20cd9f4ecSchristos# source the master var file when it's there
30cd9f4ecSchristos[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
40cd9f4ecSchristos# use .tpkg.var.test for in test variable passing
50cd9f4ecSchristos[ -f .tpkg.var.test ] && source .tpkg.var.test
60cd9f4ecSchristos
70cd9f4ecSchristosPRE="../.."
80cd9f4ecSchristos
90cd9f4ecSchristoseval `grep ^srcdir= $PRE/Makefile`
100cd9f4ecSchristosecho "srcdir="$srcdir
110cd9f4ecSchristos
120cd9f4ecSchristos# obtain list from compiled in settings:
130cd9f4ecSchristosgrep "ROOT-SERVERS.NET." $PRE/$srcdir/iterator/iter_hints.c > curlist
140cd9f4ecSchristosecho "Current list:"
150cd9f4ecSchristoscat curlist
160cd9f4ecSchristos
170cd9f4ecSchristosresult="0"
180cd9f4ecSchristos
190cd9f4ecSchristos# dig all servers and check if same
200cd9f4ecSchristosfor rs in A.ROOT-SERVERS.NET. B.ROOT-SERVERS.NET. C.ROOT-SERVERS.NET. D.ROOT-SERVERS.NET. E.ROOT-SERVERS.NET. F.ROOT-SERVERS.NET. G.ROOT-SERVERS.NET. H.ROOT-SERVERS.NET. I.ROOT-SERVERS.NET. J.ROOT-SERVERS.NET. K.ROOT-SERVERS.NET. L.ROOT-SERVERS.NET. M.ROOT-SERVERS.NET.; do
210cd9f4ecSchristos
220cd9f4ecSchristos	addr4=`dig +short $rs A`
230cd9f4ecSchristos	addr6=`dig +short $rs AAAA`
240cd9f4ecSchristos
250cd9f4ecSchristos	# all IP4 must be present as listed.
260cd9f4ecSchristos	if test -z "$addr4" ; then
270cd9f4ecSchristos		echo "$rs A is removed! It has changed!"
280cd9f4ecSchristos		result="1"
290cd9f4ecSchristos	fi
300cd9f4ecSchristos	if grep $rs curlist | grep "$addr4" >/dev/null; then
310cd9f4ecSchristos		echo "$rs is OK: A $addr4"
320cd9f4ecSchristos	else
330cd9f4ecSchristos		echo "$rs A now $addr4, it has changed!"
340cd9f4ecSchristos		result="1"
350cd9f4ecSchristos	fi
360cd9f4ecSchristos	# if IP6 is "" then it must be "" as well in the compiled hints
370cd9f4ecSchristos	if test -z "$addr6" ; then
380cd9f4ecSchristos		if grep $rs curlist | grep ":" >/dev/null; then
390cd9f4ecSchristos			echo "$rs AAAA now removed, it has changed!"
400cd9f4ecSchristos			result="1"
410cd9f4ecSchristos		else
420cd9f4ecSchristos			echo $rs' is OK: AAAA ""'
430cd9f4ecSchristos		fi
440cd9f4ecSchristos	else
450cd9f4ecSchristos		# root server has an IP6.
460cd9f4ecSchristos		if grep $rs curlist | grep "$addr6" >/dev/null; then
470cd9f4ecSchristos			echo "$rs is OK: AAAA $addr6"
480cd9f4ecSchristos		else
490cd9f4ecSchristos			echo "$rs AAAA now $addr6, it has changed!"
500cd9f4ecSchristos			result="1"
510cd9f4ecSchristos		fi
520cd9f4ecSchristos	fi
530cd9f4ecSchristosdone
540cd9f4ecSchristos
550cd9f4ecSchristosexit $result
56