unbound/testdata/05-asynclook.tdir/05-asynclook.test
wouter 8ba25b126a tests in tdir format.
git-svn-id: https://unbound.nlnetlabs.nl/svn/trunk@4264 be551aaa-1e26-0410-a405-d3ace91eadb9
2017-07-06 13:27:30 +00:00

199 lines
4.5 KiB
Plaintext

# #-- 05-asynclook.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
# 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
}
# detect if there is forking on this system.
HAVE_FORK=yes
if grep "undef HAVE_FORK" $PRE/config.h >/dev/null 2>&1; then
HAVE_FORK=no
fi
if test $HAVE_FORK = yes; then
# test hosts reading (directed at local auth info)
echo '> $PRE/asynclook -H 05-asynclook.hosts virtual.virtual.virtual.local 2>&1 | tee outfile'
$PRE/asynclook -H 05-asynclook.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
fi #HAVE_FORK
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
if test $HAVE_FORK = yes; then
# 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
fi #HAVE_FORK
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
if test $HAVE_FORK = yes; then
# 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
fi #HAVE_FORK
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