xref: /netbsd-src/external/bsd/unbound/dist/testdata/fwd_ancil.tdir/fwd_ancil.test (revision 06dfa8449cb5e76c0044ec0f3badf7d5180af0f5)
1# #-- fwd_ancil.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. ../common.sh
9
10if test `hostname`"" = "dicht.nlnetlabs.nl"; then
11	echo "In jail, no ::1, skip test"
12	exit 0
13fi
14
15if fgrep "disable interface-automatic" unbound.log; then
16	echo "skip test"
17	exit 0
18fi
19
20get_make
21(cd $PRE; $MAKE streamtcp)
22
23# detect platform support first
24echo "> streamtcp -n -u -f 127.0.0.1 www.example.com. A IN"
25$PRE/streamtcp -n -u -f 127.0.0.1@$UNBOUND_PORT www.example.com. A IN | tee outfile
26sleep 2
27echo "> check answer"
28if ! grep "Please disable interface-automatic" unbound.log; then
29	echo "OK"
30else
31	echo "No platform support for ancillary data"
32	echo "> cat logfiles"
33	cat fwd.log
34	cat unbound.log
35	echo "Not OK - but ignore test"
36	exit 0
37fi
38rm outfile
39
40
41# do the test
42echo "> streamtcp -f 127.0.0.1 www.example.com. A IN"
43$PRE/streamtcp -f 127.0.0.1@$UNBOUND_PORT www.example.com. A IN | tee outfile
44echo "> check answer"
45if grep "10.20.30.40" outfile; then
46	echo "OK"
47else
48	echo "> cat logfiles"
49	cat fwd.log
50	cat unbound.log
51	echo "Not OK"
52	exit 1
53fi
54rm outfile
55
56echo "> streamtcp -f ::1 www.example.com. A IN"
57$PRE/streamtcp -f ::1@$UNBOUND_PORT www.example.com. A IN | tee outfile
58echo "> check answer"
59if grep "10.20.30.40" outfile; then
60	echo "OK"
61else
62	echo "> cat logfiles"
63	cat fwd.log
64	cat unbound.log
65	echo "Not OK"
66	exit 1
67fi
68rm outfile
69
70echo "> streamtcp -u -f ::1 www.example.com. A IN"
71$PRE/streamtcp -u -f ::1@$UNBOUND_PORT www.example.com. A IN | tee outfile
72echo "> check answer"
73if grep "10.20.30.40" outfile; then
74	echo "OK"
75else
76	echo "> cat logfiles"
77	cat fwd.log
78	cat unbound.log
79	echo "Not OK"
80	exit 1
81fi
82rm outfile
83
84echo "> streamtcp -u -f 127.0.0.1 www.example.com. A IN"
85$PRE/streamtcp -u -f 127.0.0.1@$UNBOUND_PORT www.example.com. A IN | tee outfile
86echo "> check answer"
87if grep "10.20.30.40" outfile; then
88	echo "OK"
89else
90	echo "> cat logfiles"
91	cat fwd.log
92	cat unbound.log
93	echo "Not OK"
94	exit 1
95fi
96rm outfile
97
98echo "> cat logfiles"
99cat fwd.log
100cat unbound.log
101exit 0
102