1# #-- tcp_idle_timeout.test --# 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 8# Run up unbound with a 2s idle timeout. Try a normal TCP query, check it works, and then check that a connection with a 4s send delay fails. 9 10 11if uname | grep MINGW >/dev/null; then 12 echo "no job control in shell on windows. end test" 13 exit 0 14fi 15 16PRE="../.." 17. ../common.sh 18get_make 19(cd $PRE; $MAKE streamtcp) 20 21# first test a single TCP query with no delay. 22echo "> query www.example.com." 23$PRE/streamtcp -f 127.0.0.1@$UNBOUND_PORT www.example.com. A IN >outfile 2>&1 24if test "$?" -ne 0; then 25 echo "exit status not OK" 26 echo "> cat logfiles" 27 cat outfile 28 cat fwd.log 29 cat unbound.log 30 echo "Not OK" 31 exit 1 32else 33 echo "exit status OK" 34fi 35echo "> cat logfiles" 36cat outfile 37cat fwd.log 38cat unbound.log 39echo "> check answer" 40if grep "10.20.30.40" outfile; then 41 echo "OK" 42else 43 echo "Not OK" 44 exit 1 45fi 46 47# now test query with delay should fail. 48echo "> query www.example.com." 49$PRE/streamtcp -d 4 -f 127.0.0.1@$UNBOUND_PORT www.example.com. A IN >outfile 2>&1 50if test "$?" -eq 0; then 51 echo "exit status OK" 52 echo "> cat logfiles" 53 cat outfile 54 cat fwd.log 55 cat unbound.log 56 echo "Not OK" 57 exit 1 58else 59 echo "exit status not OK" 60fi 61echo "> cat logfiles" 62cat outfile 63cat fwd.log 64cat unbound.log 65echo "OK" 66 67exit 0 68