xref: /netbsd-src/external/bsd/unbound/dist/testdata/dnstap_tls_clientauth.tdir/dnstap_tls_clientauth.pre (revision 91f7d55fb697b5e0475da4718fa34c3a3ebeac85)
1# #-- dnstap_tls_clientauth.pre--#
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
7. ../common.sh
8
9PRE="../.."
10if grep "define USE_DNSTAP 1" $PRE/config.h; then echo test enabled; else skip_test "test skipped"; fi
11
12get_random_port 4
13UNBOUND_PORT=$RND_PORT
14FWD_PORT=$(($RND_PORT + 1))
15CONTROL_PORT=$(($RND_PORT + 2))
16TAP_PORT=$(($RND_PORT + 3))
17echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
18echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
19echo "CONTROL_PORT=$CONTROL_PORT" >> .tpkg.var.test
20echo "TAP_PORT=$TAP_PORT" >> .tpkg.var.test
21
22# start forwarder
23get_ldns_testns
24$LDNS_TESTNS -p $FWD_PORT dnstap_tls_clientauth.testns >fwd.log 2>&1 &
25FWD_PID=$!
26echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
27
28# start the dnstap log server
29# the -vvvv flag prints protocol and connection information from the
30# unbound-dnstap-socket server.
31# the -l flag prints the DNS info in the DNSTAP packet in multiline output.
32# stderr is the '-vvvv' server logs and errors.
33# stdout is the one-line packet logs (or with -l, multiline).
34$PRE/unbound-dnstap-socket -t "127.0.0.1@$TAP_PORT" -x unbound_server.key -y unbound_server.pem -z unbound_server.pem -l -vvvv 2>tap.errlog >tap.log &
35if test $? -ne 0; then
36	echo "could not start unbound-dnstap-socket server"
37	exit 1
38fi
39DNSTAP_SOCKET_PID=$!
40echo "DNSTAP_SOCKET_PID=$DNSTAP_SOCKET_PID" >> .tpkg.var.test
41# wait for the server to go up
42wait_server_up "tap.errlog" "start of service"
43
44# make config file
45sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' -e 's/@CONTROL_PORT\@/'$CONTROL_PORT'/' -e 's/@TAPPORT\@/'$TAP_PORT'/' < dnstap_tls_clientauth.conf > ub.conf
46# start unbound in the background
47$PRE/unbound -d -c ub.conf >unbound.log 2>&1 &
48UNBOUND_PID=$!
49echo "UNBOUND_PID=$UNBOUND_PID" >> .tpkg.var.test
50
51cat .tpkg.var.test
52wait_ldns_testns_up fwd.log
53wait_unbound_up unbound.log
54
55