From 6c76b4e2f87d1bf68fd8908d0ddf3851ad92d644 Mon Sep 17 00:00:00 2001 From: "W.C.A. Wijngaards" Date: Wed, 6 Dec 2023 16:32:06 +0100 Subject: [PATCH] - Fix tests to use new common.sh functions, wait_logfile and kill_from_pidfile. --- doc/Changelog | 2 ++ .../cachedb_no_store.post | 2 +- .../cachedb_no_store.test | 2 +- testdata/padding.tdir/padding.post | 4 +-- testdata/padding.tdir/padding.test | 25 +++---------------- testdata/tcp_reuse.tdir/tcp_reuse.post | 4 +-- testdata/tls_reuse.tdir/tls_reuse.post | 4 +-- 7 files changed, 14 insertions(+), 29 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index d47f4f190..ff674348b 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -3,6 +3,8 @@ - iana portlist update. - Updated IPv4 and IPv6 address for b.root-servers.net in root hints. - Update test script file common.sh. + - Fix tests to use new common.sh functions, wait_logfile and + kill_from_pidfile. 5 December 2023: Wouter - Merge #971: fix 'WARNING: Message has 41 extra bytes at end'. diff --git a/testdata/cachedb_no_store.tdir/cachedb_no_store.post b/testdata/cachedb_no_store.tdir/cachedb_no_store.post index 901f01a87..320dcc3e3 100644 --- a/testdata/cachedb_no_store.tdir/cachedb_no_store.post +++ b/testdata/cachedb_no_store.tdir/cachedb_no_store.post @@ -16,5 +16,5 @@ if test -f fwd4.log; then cat fwd4.log; else echo "no fwd4.log"; fi cat unbound.log if test -f unbound2.log; then cat unbound2.log; else echo "no unbound2.log"; fi kill_pid $FWD_PID -kill_pid `cat unbound.pid` +kill_from_pidfile "unbound.pid" rm -f $CONTROL_PATH/controlpipe.$CONTROL_PID diff --git a/testdata/cachedb_no_store.tdir/cachedb_no_store.test b/testdata/cachedb_no_store.tdir/cachedb_no_store.test index 597b80e1a..47a89656c 100644 --- a/testdata/cachedb_no_store.tdir/cachedb_no_store.test +++ b/testdata/cachedb_no_store.tdir/cachedb_no_store.test @@ -69,7 +69,7 @@ wait_ldns_testns_up fwd3.log # stop unbound to flush the cachedb cache echo "> stop unbound" -kill_pid `cat unbound.pid` +kill_from_pidfile "unbound.pid" echo "" echo "> config unbound with cachedb-no-store: yes" diff --git a/testdata/padding.tdir/padding.post b/testdata/padding.tdir/padding.post index 9121ccf25..eaeefb8c4 100644 --- a/testdata/padding.tdir/padding.post +++ b/testdata/padding.tdir/padding.post @@ -9,13 +9,13 @@ PRE="../.." kill_pid $DNSTAP_SOCKET_PID kill_pid $FWD_PID -kill_pid `cat unbound2.pid` +kill_from_pidfile "unbound2.pid" if test -f unbound2.log; then echo ">>> upstream log" cat unbound2.log fi #kill_pid $UNBOUND_PID -kill_pid `cat unbound.pid` +kill_from_pidfile "unbound.pid" if test -f unbound.log; then echo ">>> unbound log" cat unbound.log diff --git a/testdata/padding.tdir/padding.test b/testdata/padding.tdir/padding.test index 6161a49ae..2a0860851 100644 --- a/testdata/padding.tdir/padding.test +++ b/testdata/padding.tdir/padding.test @@ -25,17 +25,10 @@ else exit 1 fi -echo "> wait for log to happen on timer" -sleep 3 +echo "> wait for log to happen" +wait_logfile tap.log "www.example.com" 45 echo "> check tap.log for dnstap info" # see if it logged the information in tap.log -# wait for a moment for filesystem to catch up. -if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "www.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "www.example.com" tap.log >/dev/null; then :; else sleep 10; fi if grep "www.example.com" tap.log; then echo "yes it is in tap.log"; else echo "information not in tap.log" @@ -67,12 +60,7 @@ fi echo "> check tap.log for dnstap info" # see if it logged the information in tap.log # wait for a moment for filesystem to catch up. -if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 1; fi -if grep "txt.example.com" tap.log >/dev/null; then :; else sleep 10; fi +wait_logfile tap.log "txt.example.com" 45 if grep "txt.example.com" tap.log; then echo "yes it is in tap.log"; else echo "information not in tap.log" @@ -131,12 +119,7 @@ dig @127.0.0.1 -p $UNBOUND_PORT fin.example.com. TXT | tee outfile echo "> check tap.log for dnstap info" # see if it logged the information in tap.log # wait for a moment for filesystem to catch up. -if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi -if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi -if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi -if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi -if grep "fini" tap.log >/dev/null; then :; else sleep 1; fi -if grep "fini" tap.log >/dev/null; then :; else sleep 10; fi +wait_logfile tap.log "fini" 45 if grep "fini" tap.log; then echo "yes it is in tap.log"; else echo "information not in tap.log" diff --git a/testdata/tcp_reuse.tdir/tcp_reuse.post b/testdata/tcp_reuse.tdir/tcp_reuse.post index ca7535471..7536918b7 100644 --- a/testdata/tcp_reuse.tdir/tcp_reuse.post +++ b/testdata/tcp_reuse.tdir/tcp_reuse.post @@ -6,13 +6,13 @@ # # do your teardown here . ../common.sh -kill_pid `cat unbound2.pid` +kill_from_pidfile "unbound2.pid" if test -f unbound2.log; then echo ">>> upstream log" cat unbound2.log fi #kill_pid $UNBOUND_PID -kill_pid `cat unbound.pid` +kill_from_pidfile "unbound.pid" if test -f unbound.log; then echo ">>> unbound log" cat unbound.log diff --git a/testdata/tls_reuse.tdir/tls_reuse.post b/testdata/tls_reuse.tdir/tls_reuse.post index 2eef0da96..6162086e8 100644 --- a/testdata/tls_reuse.tdir/tls_reuse.post +++ b/testdata/tls_reuse.tdir/tls_reuse.post @@ -6,13 +6,13 @@ # # do your teardown here . ../common.sh -kill_pid `cat unbound2.pid` +kill_from_pidfile "unbound2.pid" if test -f unbound2.log; then echo ">>> upstream log" cat unbound2.log fi #kill_pid $UNBOUND_PID -kill_pid `cat unbound.pid` +kill_from_pidfile "unbound.pid" if test -f unbound.log; then echo ">>> unbound log" cat unbound.log -- 2.47.2