diff options
Diffstat (limited to 'testdata/05-asynclook.tdir/05-asynclook.test')
-rw-r--r-- | testdata/05-asynclook.tdir/05-asynclook.test | 198 |
1 files changed, 198 insertions, 0 deletions
diff --git a/testdata/05-asynclook.tdir/05-asynclook.test b/testdata/05-asynclook.tdir/05-asynclook.test new file mode 100644 index 0000000000000..28a054d1aba31 --- /dev/null +++ b/testdata/05-asynclook.tdir/05-asynclook.test @@ -0,0 +1,198 @@ +# #-- 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 |