summaryrefslogtreecommitdiff
path: root/testdata/08-host-lib.tdir
diff options
context:
space:
mode:
Diffstat (limited to 'testdata/08-host-lib.tdir')
-rw-r--r--testdata/08-host-lib.tdir/08-host-lib.dsc16
-rw-r--r--testdata/08-host-lib.tdir/08-host-lib.hosts12
-rw-r--r--testdata/08-host-lib.tdir/08-host-lib.post10
-rw-r--r--testdata/08-host-lib.tdir/08-host-lib.pre19
-rw-r--r--testdata/08-host-lib.tdir/08-host-lib.test194
-rw-r--r--testdata/08-host-lib.tdir/08-host-lib.testns35
6 files changed, 286 insertions, 0 deletions
diff --git a/testdata/08-host-lib.tdir/08-host-lib.dsc b/testdata/08-host-lib.tdir/08-host-lib.dsc
new file mode 100644
index 000000000000..c7c18b41bcaf
--- /dev/null
+++ b/testdata/08-host-lib.tdir/08-host-lib.dsc
@@ -0,0 +1,16 @@
+BaseName: 08-host-lib
+Version: 1.0
+Description: Test async lookup using libunbound
+CreationDate: Fri May 16 13:21:58 CEST 2008
+Maintainer: dr. W.C.A. Wijngaards
+Category:
+Component:
+CmdDepends:
+Depends:
+Help:
+Pre: 08-host-lib.pre
+Post: 08-host-lib.post
+Test: 08-host-lib.test
+AuxFiles:
+Passed:
+Failure:
diff --git a/testdata/08-host-lib.tdir/08-host-lib.hosts b/testdata/08-host-lib.tdir/08-host-lib.hosts
new file mode 100644
index 000000000000..fa5e5482e72f
--- /dev/null
+++ b/testdata/08-host-lib.tdir/08-host-lib.hosts
@@ -0,0 +1,12 @@
+# Host Database
+#
+# This file should contain the addresses and aliases for local hosts that
+# share this file. Replace 'my.domain' below with the domainname of your
+# machine.
+#
+::1 localhost localhost.my.domain
+127.0.0.1 localhost localhost.my.domain
+# Imaginary network.
+10.0.0.2 myname.my.domain myname
+10.0.0.3 myfriend.my.domain myfriend
+10.20.30.40 virtual.virtual.virtual.local
diff --git a/testdata/08-host-lib.tdir/08-host-lib.post b/testdata/08-host-lib.tdir/08-host-lib.post
new file mode 100644
index 000000000000..26b046ada5d2
--- /dev/null
+++ b/testdata/08-host-lib.tdir/08-host-lib.post
@@ -0,0 +1,10 @@
+# #-- 08-host-lib.post --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# source the test var file when it's there
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+#
+# do your teardown here
+
+. ../common.sh
+kill_pid $FWD_PID
diff --git a/testdata/08-host-lib.tdir/08-host-lib.pre b/testdata/08-host-lib.tdir/08-host-lib.pre
new file mode 100644
index 000000000000..84817891ff93
--- /dev/null
+++ b/testdata/08-host-lib.tdir/08-host-lib.pre
@@ -0,0 +1,19 @@
+# #-- 08-host-lib.pre--#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+. ../common.sh
+get_random_port 2
+FWD_PORT=$(($RND_PORT + 1))
+echo "FWD_PORT=$FWD_PORT" >> .tpkg.var.test
+
+# start forwarder
+get_ldns_testns
+$LDNS_TESTNS -p $FWD_PORT 08-host-lib.testns >fwd.log 2>&1 &
+FWD_PID=$!
+echo "FWD_PID=$FWD_PID" >> .tpkg.var.test
+
+cat .tpkg.var.test
+wait_ldns_testns_up fwd.log
diff --git a/testdata/08-host-lib.tdir/08-host-lib.test b/testdata/08-host-lib.tdir/08-host-lib.test
new file mode 100644
index 000000000000..8de897776209
--- /dev/null
+++ b/testdata/08-host-lib.tdir/08-host-lib.test
@@ -0,0 +1,194 @@
+# #-- 08-host-lib.test --#
+# source the master var file when it's there
+[ -f ../.tpkg.var.master ] && source ../.tpkg.var.master
+# use .tpkg.var.test for in test variable passing
+[ -f .tpkg.var.test ] && source .tpkg.var.test
+
+PRE="../.."
+. ../common.sh
+
+if grep FORK $PRE/config.h | grep "define" >/dev/null 2>&1; then
+ # nothing
+ :
+else
+ echo "forking is not available; test skipped."
+ exit 0
+fi
+
+# test if fwder is up
+echo "> dig @127.0.0.1 -p $FWD_PORT www.example.com | tee outfile"
+dig @127.0.0.1 -p $FWD_PORT www.example.com | tee outfile
+if grep "10.20.30.40" outfile; then
+ echo "fwder is up"
+else
+ cat fwd.log
+ echo "fwder not up"
+ exit 1
+fi
+rm outfile
+
+# create asynclook
+get_make
+echo "> (cd $PRE ; $MAKE asynclook)"
+(cd $PRE ; $MAKE asynclook)
+if test ! -x $PRE/asynclook; then
+ echo "cannot build asynclook test program"
+ exit 1
+fi
+(cd $PRE ; $MAKE lock-verify)
+
+# check the locks.
+function locktest() {
+ if test -x $PRE/lock-verify -a -f ublocktrace.0; then
+ $PRE/lock-verify ublocktrace.*
+ if test $? -ne 0; then
+ echo "lock-verify error"
+ exit 1
+ fi
+ fi
+}
+
+# test hosts reading (directed at local auth info)
+echo '> $PRE/asynclook -H 08-host-lib.hosts virtual.virtual.virtual.local 2>&1 | tee outfile'
+$PRE/asynclook -H 08-host-lib.hosts virtual.virtual.virtual.local 2>&1 | tee outfile
+if grep "virtual.virtual.virtual.local: 10.20.30.40" outfile; then
+ echo "OK"
+else
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+# test async lookups (directed at testns)
+echo '> $PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com 2>&1 | tee outfile'
+$PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com 2>&1 | tee outfile
+if grep "www.example.com: 10.20.30.40" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+echo '> $PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
+$PRE/asynclook -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
+if grep "www.example.com: 10.20.30.40" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+if grep "www2.example.com: 10.20.30.42" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+echo '> $PRE/asynclook -t -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
+$PRE/asynclook -t -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
+if grep "www.example.com: 10.20.30.40" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+if grep "www2.example.com: 10.20.30.42" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+# test cancellation
+echo '> $PRE/asynclook -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
+$PRE/asynclook -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
+if grep "www.example.com: cancelled" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+if grep "www2.example.com: cancelled" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+echo '> $PRE/asynclook -t -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
+$PRE/asynclook -t -c -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
+if grep "www.example.com: cancelled" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+if grep "www2.example.com: cancelled" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+# test blocking mode
+echo '> $PRE/asynclook -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
+$PRE/asynclook -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
+if grep "www.example.com: 10.20.30.40" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+if grep "www2.example.com: 10.20.30.42" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+echo '> $PRE/asynclook -t -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile'
+$PRE/asynclook -t -b -f "127.0.0.1@"$FWD_PORT www.example.com www2.example.com 2>&1 | tee outfile
+if grep "www.example.com: 10.20.30.40" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+if grep "www2.example.com: 10.20.30.42" outfile; then
+ echo "OK"
+else
+ cat fwd.log
+ echo "Not OK"
+ exit 1
+fi
+locktest
+rm outfile
+
+echo "> cat logfiles"
+cat fwd.log
+exit 0
diff --git a/testdata/08-host-lib.tdir/08-host-lib.testns b/testdata/08-host-lib.tdir/08-host-lib.testns
new file mode 100644
index 000000000000..6245ae164172
--- /dev/null
+++ b/testdata/08-host-lib.tdir/08-host-lib.testns
@@ -0,0 +1,35 @@
+; nameserver test file
+$ORIGIN example.com.
+$TTL 3600
+
+; for priming query
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id
+SECTION QUESTION
+@ IN NS
+SECTION ANSWER
+@ IN NS 127.0.0.1
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id
+SECTION QUESTION
+www IN A
+SECTION ANSWER
+www IN A 10.20.30.40
+ENTRY_END
+
+ENTRY_BEGIN
+MATCH opcode qtype qname
+REPLY QR AA NOERROR
+ADJUST copy_id
+SECTION QUESTION
+www2 IN A
+SECTION ANSWER
+www2 IN A 10.20.30.42
+ENTRY_END
+