mirror of
https://github.com/NLnetLabs/unbound.git
synced 2025-12-20 23:00:56 -05:00
use common functionality file.
git-svn-id: file:///svn/unbound/trunk@2390 be551aaa-1e26-0410-a405-d3ace91eadb9
This commit is contained in:
parent
4011c3861b
commit
1550bc65f3
48 changed files with 243 additions and 38 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
BIN
testdata/00-lint.tpkg
vendored
BIN
testdata/00-lint.tpkg
vendored
Binary file not shown.
BIN
testdata/01-doc.tpkg
vendored
BIN
testdata/01-doc.tpkg
vendored
Binary file not shown.
BIN
testdata/02-unittest.tpkg
vendored
BIN
testdata/02-unittest.tpkg
vendored
Binary file not shown.
BIN
testdata/03-testbound.tpkg
vendored
BIN
testdata/03-testbound.tpkg
vendored
Binary file not shown.
BIN
testdata/05-asynclook.tpkg
vendored
BIN
testdata/05-asynclook.tpkg
vendored
Binary file not shown.
BIN
testdata/06-ianaports.tpkg
vendored
BIN
testdata/06-ianaports.tpkg
vendored
Binary file not shown.
BIN
testdata/08-host-lib.tpkg
vendored
BIN
testdata/08-host-lib.tpkg
vendored
Binary file not shown.
BIN
testdata/09-unbound-control.tpkg
vendored
BIN
testdata/09-unbound-control.tpkg
vendored
Binary file not shown.
BIN
testdata/10-unbound-anchor.tpkg
vendored
BIN
testdata/10-unbound-anchor.tpkg
vendored
Binary file not shown.
232
testdata/common.sh
vendored
Normal file
232
testdata/common.sh
vendored
Normal file
|
|
@ -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 <logfilename> <string to watch>
|
||||
# $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 <logfilename> <string to watch> <badstr>
|
||||
# $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
|
||||
}
|
||||
|
||||
BIN
testdata/edns_cache.tpkg
vendored
BIN
testdata/edns_cache.tpkg
vendored
Binary file not shown.
BIN
testdata/edns_lame.tpkg
vendored
BIN
testdata/edns_lame.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_ancil.tpkg
vendored
BIN
testdata/fwd_ancil.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_bogus.tpkg
vendored
BIN
testdata/fwd_bogus.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_capsid.tpkg
vendored
BIN
testdata/fwd_capsid.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_capsid_fallback.tpkg
vendored
BIN
testdata/fwd_capsid_fallback.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_compress_c00c.tpkg
vendored
BIN
testdata/fwd_compress_c00c.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_edns_bksec.tpkg
vendored
BIN
testdata/fwd_edns_bksec.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_edns_probe.tpkg
vendored
BIN
testdata/fwd_edns_probe.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_no_edns.tpkg
vendored
BIN
testdata/fwd_no_edns.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_oneport.tpkg
vendored
BIN
testdata/fwd_oneport.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_tcp.tpkg
vendored
BIN
testdata/fwd_tcp.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_tcp_tc.tpkg
vendored
BIN
testdata/fwd_tcp_tc.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_tcp_tc6.tpkg
vendored
BIN
testdata/fwd_tcp_tc6.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_three.tpkg
vendored
BIN
testdata/fwd_three.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_three_service.tpkg
vendored
BIN
testdata/fwd_three_service.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_ttlexpire.tpkg
vendored
BIN
testdata/fwd_ttlexpire.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_udp.tpkg
vendored
BIN
testdata/fwd_udp.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_udptmout.tpkg
vendored
BIN
testdata/fwd_udptmout.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_waitudp.tpkg
vendored
BIN
testdata/fwd_waitudp.tpkg
vendored
Binary file not shown.
BIN
testdata/fwd_zero.tpkg
vendored
BIN
testdata/fwd_zero.tpkg
vendored
Binary file not shown.
BIN
testdata/hostsfileosx.tpkg
vendored
BIN
testdata/hostsfileosx.tpkg
vendored
Binary file not shown.
BIN
testdata/local_nodefault.tpkg
vendored
BIN
testdata/local_nodefault.tpkg
vendored
Binary file not shown.
BIN
testdata/local_norec.tpkg
vendored
BIN
testdata/local_norec.tpkg
vendored
Binary file not shown.
BIN
testdata/local_nosnoop.tpkg
vendored
BIN
testdata/local_nosnoop.tpkg
vendored
Binary file not shown.
BIN
testdata/pylib.tpkg
vendored
BIN
testdata/pylib.tpkg
vendored
Binary file not shown.
BIN
testdata/pymod.tpkg
vendored
BIN
testdata/pymod.tpkg
vendored
Binary file not shown.
BIN
testdata/pymod_thread.tpkg
vendored
BIN
testdata/pymod_thread.tpkg
vendored
Binary file not shown.
BIN
testdata/remote-threaded.tpkg
vendored
BIN
testdata/remote-threaded.tpkg
vendored
Binary file not shown.
BIN
testdata/speed_cache.tpkg
vendored
BIN
testdata/speed_cache.tpkg
vendored
Binary file not shown.
BIN
testdata/speed_local.tpkg
vendored
BIN
testdata/speed_local.tpkg
vendored
Binary file not shown.
BIN
testdata/stat_timer.tpkg
vendored
BIN
testdata/stat_timer.tpkg
vendored
Binary file not shown.
BIN
testdata/stream_tcp.tpkg
vendored
BIN
testdata/stream_tcp.tpkg
vendored
Binary file not shown.
BIN
testdata/stub_udp.tpkg
vendored
BIN
testdata/stub_udp.tpkg
vendored
Binary file not shown.
BIN
testdata/stub_udp6.tpkg
vendored
BIN
testdata/stub_udp6.tpkg
vendored
Binary file not shown.
BIN
testdata/tcp_sigpipe.tpkg
vendored
BIN
testdata/tcp_sigpipe.tpkg
vendored
Binary file not shown.
Loading…
Reference in a new issue