xref: /netbsd-src/external/bsd/unbound/dist/testdata/pylib.tdir/pylib.pre (revision 7d62b00eb9ad855ffcd7da46b41e23feb5476fac)
1# #-- pylib.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
7PRE="../.."
8. ../common.sh
9# if no python; exit
10if grep "define WITH_PYUNBOUND 1" $PRE/config.h; then
11	echo "have pyunbound"
12else
13	echo "no pyunbound"
14	exit 0
15fi
16
17# Copy the required libraries
18cp $PRE/libunbound/python/unbound.py .
19cp $PRE/.libs/_unbound* .
20cp $PRE/.libs/libunbound* .
21
22get_random_port 2
23UNBOUND_PORT=$RND_PORT
24FWD_PORT=$(($RND_PORT + 1))
25echo "UNBOUND_PORT=$UNBOUND_PORT" >> .tpkg.var.test
26echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
27
28# start forwarder
29get_ldns_testns
30$LDNS_TESTNS -p $FWD_PORT pylib.testns >fwd.log 2>&1 &
31FWD_PID=$!
32echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
33
34# modify config file
35sed -e 's/@PORT\@/'$UNBOUND_PORT'/' -e 's/@TOPORT\@/'$FWD_PORT'/' < pylib.lookup.conf > ub.lookup.conf
36
37cat .tpkg.var.test
38wait_ldns_testns_up fwd.log
39
40