xref: /netbsd-src/external/bsd/unbound/dist/testdata/fwd_bogus.tdir/fwd_bogus.test (revision cef8759bd76c1b621f8eab8faa6f208faabc2e15)
1# #-- fwd_bogus.test --#
2# source the master var file when it's there
3[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
4# use .tpkg.var.test for in test variable passing
5[ -f .tpkg.var.test ] && source .tpkg.var.test
6
7PRE="../.."
8
9# do the test
10echo "> dig www.example.com."
11dig @localhost -p $UNBOUND_PORT www.example.com. | tee outfile
12echo "> cat logfiles"
13cat fwd.log
14cat unbound.log
15echo "> check answer"
16# servfail.
17if grep "SERVFAIL" outfile; then
18	echo "OK"
19else
20	echo "Not OK"
21	exit 1
22fi
23
24# now check the cache.
25$PRE/unbound-control -c ub.conf dump_cache > cachedump
26if test $? -ne 0; then
27	echo "unbound-control failed"
28	cat cachedump
29	exit 1
30else
31	echo "unbound-control ok"
32fi
33
34# bad cache entry looks like this
35# msg www.example.com. IN A 32896 1 1252576696 1 1 0 0
36cat cachedump
37
38ttl=`grep "msg www.example.com" cachedump | awk '{print $7}'`
39echo TTL $ttl
40# must be smaller than bogus ttl of 60.
41if test $ttl -gt 61; then
42	echo "failed: TTL too big!"
43	exit 1
44else
45	echo "TTL OK"
46fi
47
48exit 0
49