From: Wouter Wijngaards Date: Fri, 11 Feb 2011 12:30:42 +0000 (+0000) Subject: use common functionality file. X-Git-Tag: release-1.4.9rc1~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1550bc65f30a165066d586e2034fa001a39e9f66;p=thirdparty%2Funbound.git use common functionality file. git-svn-id: file:///svn/unbound/trunk@2390 be551aaa-1e26-0410-a405-d3ace91eadb9 --- diff --git a/doc/Changelog b/doc/Changelog index c65416f70..666a3d6e1 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,5 +1,6 @@ 11 February 2011: Wouter - iana portlist updated. + - tpkg updated with common.sh for common functionality. 7 February 2011: Wouter - Added regression test for addition of a .net DS to the root, and diff --git a/testcode/do-tests.sh b/testcode/do-tests.sh index 1ffe19c0f..84d2ef566 100755 --- a/testcode/do-tests.sh +++ b/testcode/do-tests.sh @@ -1,8 +1,8 @@ #!/usr/bin/env bash +. testdata/common.sh NEED_SPLINT='00-lint.tpkg' NEED_DOXYGEN='01-doc.tpkg' -NEED_LDNS_TESTNS='fwd_no_edns.tpkg fwd_tcp_tc.tpkg fwd_tcp.tpkg fwd_three_service.tpkg fwd_three.tpkg fwd_ttlexpire.tpkg fwd_udp.tpkg fwd_tcp_tc6.tpkg fwd_compress_c00c.tpkg fwd_ancil.tpkg stat_timer.tpkg 05-asynclook.tpkg stream_tcp.tpkg speed_cache.tpkg fwd_oneport.tpkg fwd_udptmout.tpkg fwd_waitudp.tpkg tcp_sigpipe.tpkg hostsfileosx.tpkg local_nodefault.tpkg fwd_zero.tpkg' NEED_XXD='fwd_compress_c00c.tpkg fwd_zero.tpkg' NEED_NC='fwd_compress_c00c.tpkg fwd_zero.tpkg' NEED_CURL='06-ianaports.tpkg root_anchor.tpkg' @@ -11,8 +11,8 @@ NEED_IPV6='fwd_ancil.tpkg fwd_tcp_tc6.tpkg stub_udp6.tpkg edns_cache.tpkg' NEED_NOMINGW='tcp_sigpipe.tpkg 07-confroot.tpkg 08-host-lib.tpkg fwd_ancil.tpkg' # test if dig and ldns-testns are available. -if test ! -x "`which dig 2>&1`"; then echo No 'dig' in path; exit 1; fi -if test ! -x "`which ldns-testns 2>&1`"; then echo No 'ldns-testns' in path; exit 1; fi +test_tool_avail "dig" +test_tool_avail "ldns-testns" # test for ipv6, uses streamptcp peculiarity. if ./streamtcp -f ::1 2>&1 | grep "not supported" >/dev/null 2>&1; then @@ -33,41 +33,13 @@ sh ../testcode/mini_tpkg.sh clean rm -f .perfstats.txt for test in `ls *.tpkg`; do SKIP=0 - if echo $NEED_SPLINT | grep $test >/dev/null; then - if test ! -x "`which splint`"; then - SKIP=1; - fi - fi - if echo $NEED_DOXYGEN | grep $test >/dev/null; then - if test ! -x "`which doxygen`"; then - SKIP=1; - fi - fi - if echo $NEED_CURL | grep $test >/dev/null; then - if test ! -x "`which curl`"; then - SKIP=1; - fi - fi - if echo $NEED_LDNS_TESTNS | grep $test >/dev/null; then - if test ! -x "`which ldns-testns`"; then - SKIP=1; - fi - fi - if echo $NEED_XXD | grep $test >/dev/null; then - if test ! -x "`which xxd`"; then - SKIP=1; - fi - fi - if echo $NEED_NC | grep $test >/dev/null; then - if test ! -x "`which nc`"; then - SKIP=1; - fi - fi - if echo $NEED_WHOAMI | grep $test >/dev/null; then - if test ! -x "`which whoami`"; then - SKIP=1; - fi - fi + skip_if_in_list $test "$NEED_SPLINT" "splint" + skip_if_in_list $test "$NEED_DOXYGEN" "doxygen" + skip_if_in_list $test "$NEED_CURL" "curl" + skip_if_in_list $test "$NEED_XXD" "xxd" + skip_if_in_list $test "$NEED_NC" "nc" + skip_if_in_list $test "$NEED_WHOAMI" "whoami" + if echo $NEED_IPV6 | grep $test >/dev/null; then if test "$HAVE_IPV6" = no; then SKIP=1; diff --git a/testdata/00-lint.tpkg b/testdata/00-lint.tpkg index 5b636bdb6..89e44966d 100644 Binary files a/testdata/00-lint.tpkg and b/testdata/00-lint.tpkg differ diff --git a/testdata/01-doc.tpkg b/testdata/01-doc.tpkg index 6584f0148..af82a3e41 100644 Binary files a/testdata/01-doc.tpkg and b/testdata/01-doc.tpkg differ diff --git a/testdata/02-unittest.tpkg b/testdata/02-unittest.tpkg index 32cb2c894..4618ae30e 100644 Binary files a/testdata/02-unittest.tpkg and b/testdata/02-unittest.tpkg differ diff --git a/testdata/03-testbound.tpkg b/testdata/03-testbound.tpkg index 30a184564..2f348dcf2 100644 Binary files a/testdata/03-testbound.tpkg and b/testdata/03-testbound.tpkg differ diff --git a/testdata/05-asynclook.tpkg b/testdata/05-asynclook.tpkg index 941a46aae..8143b43f4 100644 Binary files a/testdata/05-asynclook.tpkg and b/testdata/05-asynclook.tpkg differ diff --git a/testdata/06-ianaports.tpkg b/testdata/06-ianaports.tpkg index 135cf1ec6..ef216f7fa 100644 Binary files a/testdata/06-ianaports.tpkg and b/testdata/06-ianaports.tpkg differ diff --git a/testdata/08-host-lib.tpkg b/testdata/08-host-lib.tpkg index b5a6628cf..3c7be0e6c 100644 Binary files a/testdata/08-host-lib.tpkg and b/testdata/08-host-lib.tpkg differ diff --git a/testdata/09-unbound-control.tpkg b/testdata/09-unbound-control.tpkg index c5bc1e165..e45a0525c 100644 Binary files a/testdata/09-unbound-control.tpkg and b/testdata/09-unbound-control.tpkg differ diff --git a/testdata/10-unbound-anchor.tpkg b/testdata/10-unbound-anchor.tpkg index a1527caee..85f63e842 100644 Binary files a/testdata/10-unbound-anchor.tpkg and b/testdata/10-unbound-anchor.tpkg differ diff --git a/testdata/common.sh b/testdata/common.sh new file mode 100644 index 000000000..bec2901ea --- /dev/null +++ b/testdata/common.sh @@ -0,0 +1,232 @@ +# common.sh - an include file for commonly used functions for test code. +# BSD licensed (see LICENSE file). +# +# Version 1 +# 2011-02-11: first version. +# +# include this file from a tpkg script with +# . ../common.sh +# +# overview of functions available: +# error x : print error and exit +# info x : print info +# test_tool_avail x : see if program in path and complain, exit if not. +# get_ldns_testns : set LDNS_TESTNS to executable ldns-testns +# get_make : set MAKE to gmake or make tool. +# get_gcc : get cc or gcc in CC +# set_doxygen_path : set doxygen path +# skip_if_in_list : set SKIP=1 if name in list and tool not available. +# get_random_port x : get RND_PORT a sequence of free random port numbers. +# wait_server_up : wait on logfile to see when server comes up. +# wait_ldns_testns_up : wait for ldns-testns to come up. +# wait_unbound_up : wait for unbound to come up. +# wait_petal_up : wait for petal to come up. +# wait_server_up_or_fail: wait for server to come up or print a failure string +# kill_pid : kill a server, make sure and wait for it to go down. + + +# print error and exit +# $0: name of program +# $1: error to printout. +error () { + echo "$0: error: $1" >&2 + exit 1 +} + +# print info +# $0: name of program +# $1: to printout. +info () { + echo "$0: info: $1" +} + +# test if 'tool' is available in path and complain otherwise. +# $1: tool +test_tool_avail () { + if test ! -x "`which $1 2>&1`"; then + echo No "$1" in path + exit 1 + fi +} + +# get ldns-testns tool in LDNS_TESTNS variable. +get_ldns_testns () { + if test -x "`which ldns-testns 2>&1`"; then + LDNS_TESTNS=ldns-testns + else + LDNS_TESTNS=/home/wouter/bin/ldns-testns + fi +} + +# get make tool in MAKE variable, gmake is used if present. +get_make () { + if test -x "`which gmake 2>&1`"; then + MAKE=gmake + else + MAKE=make + fi +} + +# get cc tool in CC variable, gcc is used if present. +get_gcc () { + if test -x "`which gcc 2>&1`"; then + CC=gcc + else + CC=cc + fi +} + +# set SKIP=1 if the name is in list and tool is not available. +# $1: name of package to check. +# $2: list of packages that need the tool. +# #3: name of the tool required. +skip_if_in_list () { + if echo $2 | grep $1 >/dev/null; then + if test ! -x "`which $3 2>&1`"; then + SKIP=1; + fi + fi +} + +# function to get a number of random port numbers. +# $1: number of random ports. +# RND_PORT is returned as the starting port number +get_random_port () { + local plist + local cont + local collisions + local i + local MAXCOLLISION=1000 + cont=1 + collisions=0 + while test "$cont" = 1; do + #netstat -n -A ip -A ip6 -a | sed -e "s/^.*:\([0-9]*\) .*$/\1/" + RND_PORT=$(( $RANDOM + 5354 )) + # depending on uname try to check for collisions in port numbers + case "`uname`" in + linux|Linux) + plist=`netstat -n -A ip -A ip6 -a | sed -e "s/^.*:\([0-9]*\) .*$/\1/"` + ;; + *) + plist="" + ;; + esac + cont=0 + for (( i=0 ; i < $1 ; i++ )); do + if echo "$plist" | grep '^'`expr $i + $RND_PORT`'$' >/dev/null 2>&1; then + cont=1; + collisions=`expr $collisions + 1` + fi + done + if test $collisions = $MAXCOLLISION; then + error "too many collisions getting random port number" + fi + done +} + +# wait for server to go up, pass +# $1 : logfilename +# $2 : string to watch for. +# exits with failure if it does not come up +wait_server_up () { + local MAX_UP_TRY=120 + local WAIT_THRES=30 + local try + for (( try=0 ; try <= $MAX_UP_TRY ; try++ )) ; do + if test -f $1 && fgrep "$2" $1 >/dev/null; then + #echo "done on try $try" + break; + fi + if test $try -eq $MAX_UP_TRY; then + echo "Server in $1 did not go up!" + cat $1 + exit 1; + fi + if test $try -ge $WAIT_THRES; then + sleep 1 + fi + done +} + +# wait for ldns-testns to come up +# $1 : logfilename that is watched. +wait_ldns_testns_up () { + wait_server_up "$1" "Listening on port" +} + +# wait for unbound to come up +# string 'Start of service' in log. +# $1 : logfilename that is watched. +wait_unbound_up () { + wait_server_up "$1" "start of service" +} + +# wait for petal to come up +# string 'petal start' in log. +# $1 : logfilename that is watched. +wait_petal_up () { + wait_server_up "$1" "petal start" +} + +# wait for server to go up, pass +# $1 : logfile +# $2 : success string +# $3 : failure string +wait_server_up_or_fail () { + local MAX_UP_TRY=120 + local WAIT_THRES=30 + local try + for (( try=0 ; try <= $MAX_UP_TRY ; try++ )) ; do + if test -f $1 && fgrep "$2" $1 >/dev/null; then + echo "done on try $try" + break; + fi + if test -f $1 && fgrep "$3" $1 >/dev/null; then + echo "failed on try $try" + break; + fi + if test $try -eq $MAX_UP_TRY; then + echo "Server in $1 did not go up!" + cat $1 + exit 1; + fi + if test $try -ge $WAIT_THRES; then + sleep 1 + fi + done +} + +# kill a pid, make sure and wait for it to go down. +# $1 : pid to kill +kill_pid () { + local MAX_DOWN_TRY=120 + local WAIT_THRES=30 + local try + kill $1 + for (( try=0 ; try <= $MAX_DOWN_TRY ; try++ )) ; do + if kill -0 $1 >/dev/null 2>&1; then + : + else + #echo "done on try $try" + break; + fi + if test $try -eq $MAX_DOWN_TRY; then + echo "Server in $1 did not go down! Send SIGKILL" + kill -9 $1 >/dev/null 2>&1 + fi + if test $try -ge $WAIT_THRES; then + sleep 1 + fi + # re-send the signal + kill $1 >/dev/null 2>&1 + done + return 0 +} + +# set doxygen path, so that make doc can find doxygen +set_doxygen_path () { + if test -x '/home/wouter/bin/doxygen'; then + export PATH="/home/wouter/bin:$PATH" + fi +} + diff --git a/testdata/edns_cache.tpkg b/testdata/edns_cache.tpkg index c816f2cbd..637564108 100644 Binary files a/testdata/edns_cache.tpkg and b/testdata/edns_cache.tpkg differ diff --git a/testdata/edns_lame.tpkg b/testdata/edns_lame.tpkg index b52e0af46..a11a47508 100644 Binary files a/testdata/edns_lame.tpkg and b/testdata/edns_lame.tpkg differ diff --git a/testdata/fwd_ancil.tpkg b/testdata/fwd_ancil.tpkg index 73989a8bd..09ecfb98e 100644 Binary files a/testdata/fwd_ancil.tpkg and b/testdata/fwd_ancil.tpkg differ diff --git a/testdata/fwd_bogus.tpkg b/testdata/fwd_bogus.tpkg index 0dede419c..e060f5f9c 100644 Binary files a/testdata/fwd_bogus.tpkg and b/testdata/fwd_bogus.tpkg differ diff --git a/testdata/fwd_capsid.tpkg b/testdata/fwd_capsid.tpkg index da16f4316..c468a2edc 100644 Binary files a/testdata/fwd_capsid.tpkg and b/testdata/fwd_capsid.tpkg differ diff --git a/testdata/fwd_capsid_fallback.tpkg b/testdata/fwd_capsid_fallback.tpkg index a110759d1..c6fd4cdf8 100644 Binary files a/testdata/fwd_capsid_fallback.tpkg and b/testdata/fwd_capsid_fallback.tpkg differ diff --git a/testdata/fwd_compress_c00c.tpkg b/testdata/fwd_compress_c00c.tpkg index bb0cebbf4..6b06a8608 100644 Binary files a/testdata/fwd_compress_c00c.tpkg and b/testdata/fwd_compress_c00c.tpkg differ diff --git a/testdata/fwd_edns_bksec.tpkg b/testdata/fwd_edns_bksec.tpkg index 3b03df766..5869ffa9e 100644 Binary files a/testdata/fwd_edns_bksec.tpkg and b/testdata/fwd_edns_bksec.tpkg differ diff --git a/testdata/fwd_edns_probe.tpkg b/testdata/fwd_edns_probe.tpkg index 10608e114..853b4ab00 100644 Binary files a/testdata/fwd_edns_probe.tpkg and b/testdata/fwd_edns_probe.tpkg differ diff --git a/testdata/fwd_no_edns.tpkg b/testdata/fwd_no_edns.tpkg index ac71a71d4..1629cba01 100644 Binary files a/testdata/fwd_no_edns.tpkg and b/testdata/fwd_no_edns.tpkg differ diff --git a/testdata/fwd_oneport.tpkg b/testdata/fwd_oneport.tpkg index eb8888319..d752f852c 100644 Binary files a/testdata/fwd_oneport.tpkg and b/testdata/fwd_oneport.tpkg differ diff --git a/testdata/fwd_tcp.tpkg b/testdata/fwd_tcp.tpkg index ac0a73904..f26a4e60c 100644 Binary files a/testdata/fwd_tcp.tpkg and b/testdata/fwd_tcp.tpkg differ diff --git a/testdata/fwd_tcp_tc.tpkg b/testdata/fwd_tcp_tc.tpkg index ac62bd4f6..a51258eb4 100644 Binary files a/testdata/fwd_tcp_tc.tpkg and b/testdata/fwd_tcp_tc.tpkg differ diff --git a/testdata/fwd_tcp_tc6.tpkg b/testdata/fwd_tcp_tc6.tpkg index 2a98063a4..443482018 100644 Binary files a/testdata/fwd_tcp_tc6.tpkg and b/testdata/fwd_tcp_tc6.tpkg differ diff --git a/testdata/fwd_three.tpkg b/testdata/fwd_three.tpkg index de9864f8d..afb05167f 100644 Binary files a/testdata/fwd_three.tpkg and b/testdata/fwd_three.tpkg differ diff --git a/testdata/fwd_three_service.tpkg b/testdata/fwd_three_service.tpkg index d7e21b3eb..8660e1de9 100644 Binary files a/testdata/fwd_three_service.tpkg and b/testdata/fwd_three_service.tpkg differ diff --git a/testdata/fwd_ttlexpire.tpkg b/testdata/fwd_ttlexpire.tpkg index dd24517be..5b124348e 100644 Binary files a/testdata/fwd_ttlexpire.tpkg and b/testdata/fwd_ttlexpire.tpkg differ diff --git a/testdata/fwd_udp.tpkg b/testdata/fwd_udp.tpkg index a857c9e7d..b515d8317 100644 Binary files a/testdata/fwd_udp.tpkg and b/testdata/fwd_udp.tpkg differ diff --git a/testdata/fwd_udptmout.tpkg b/testdata/fwd_udptmout.tpkg index 197758d45..e3fc74061 100644 Binary files a/testdata/fwd_udptmout.tpkg and b/testdata/fwd_udptmout.tpkg differ diff --git a/testdata/fwd_waitudp.tpkg b/testdata/fwd_waitudp.tpkg index e7d351c64..975da2160 100644 Binary files a/testdata/fwd_waitudp.tpkg and b/testdata/fwd_waitudp.tpkg differ diff --git a/testdata/fwd_zero.tpkg b/testdata/fwd_zero.tpkg index 7ce1c5860..151d69563 100644 Binary files a/testdata/fwd_zero.tpkg and b/testdata/fwd_zero.tpkg differ diff --git a/testdata/hostsfileosx.tpkg b/testdata/hostsfileosx.tpkg index 1e0ead059..05ab7c233 100644 Binary files a/testdata/hostsfileosx.tpkg and b/testdata/hostsfileosx.tpkg differ diff --git a/testdata/local_nodefault.tpkg b/testdata/local_nodefault.tpkg index 7cbef36a8..f23f50dd1 100644 Binary files a/testdata/local_nodefault.tpkg and b/testdata/local_nodefault.tpkg differ diff --git a/testdata/local_norec.tpkg b/testdata/local_norec.tpkg index 383b7d0d1..c2ceb22ea 100644 Binary files a/testdata/local_norec.tpkg and b/testdata/local_norec.tpkg differ diff --git a/testdata/local_nosnoop.tpkg b/testdata/local_nosnoop.tpkg index 2f07f4998..3bb16c265 100644 Binary files a/testdata/local_nosnoop.tpkg and b/testdata/local_nosnoop.tpkg differ diff --git a/testdata/pylib.tpkg b/testdata/pylib.tpkg index 0e2630358..6507f781d 100644 Binary files a/testdata/pylib.tpkg and b/testdata/pylib.tpkg differ diff --git a/testdata/pymod.tpkg b/testdata/pymod.tpkg index afce9a6db..164a82a00 100644 Binary files a/testdata/pymod.tpkg and b/testdata/pymod.tpkg differ diff --git a/testdata/pymod_thread.tpkg b/testdata/pymod_thread.tpkg index 36ac35536..96d5d9b39 100644 Binary files a/testdata/pymod_thread.tpkg and b/testdata/pymod_thread.tpkg differ diff --git a/testdata/remote-threaded.tpkg b/testdata/remote-threaded.tpkg index 8ff01f220..83a52ce8e 100644 Binary files a/testdata/remote-threaded.tpkg and b/testdata/remote-threaded.tpkg differ diff --git a/testdata/speed_cache.tpkg b/testdata/speed_cache.tpkg index 9119e43a0..cdba5e3f9 100644 Binary files a/testdata/speed_cache.tpkg and b/testdata/speed_cache.tpkg differ diff --git a/testdata/speed_local.tpkg b/testdata/speed_local.tpkg index 02d383795..e7d7c5d5e 100644 Binary files a/testdata/speed_local.tpkg and b/testdata/speed_local.tpkg differ diff --git a/testdata/stat_timer.tpkg b/testdata/stat_timer.tpkg index 1b3f0d54b..1f11591a7 100644 Binary files a/testdata/stat_timer.tpkg and b/testdata/stat_timer.tpkg differ diff --git a/testdata/stream_tcp.tpkg b/testdata/stream_tcp.tpkg index c0c147754..37cb249b1 100644 Binary files a/testdata/stream_tcp.tpkg and b/testdata/stream_tcp.tpkg differ diff --git a/testdata/stub_udp.tpkg b/testdata/stub_udp.tpkg index ad6f4de41..2743a6cf1 100644 Binary files a/testdata/stub_udp.tpkg and b/testdata/stub_udp.tpkg differ diff --git a/testdata/stub_udp6.tpkg b/testdata/stub_udp6.tpkg index 6790f38f7..c5e7ffe9d 100644 Binary files a/testdata/stub_udp6.tpkg and b/testdata/stub_udp6.tpkg differ diff --git a/testdata/tcp_sigpipe.tpkg b/testdata/tcp_sigpipe.tpkg index 7673afc23..2f6e3e7a6 100644 Binary files a/testdata/tcp_sigpipe.tpkg and b/testdata/tcp_sigpipe.tpkg differ