From: Ondřej Surý Date: Wed, 18 Oct 2017 12:56:26 +0000 (+0200) Subject: [rt46602] Adjust rpzrecurse for dynamic port usage X-Git-Tag: v9.13.0~158^2~50 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2a435708e4a99651a800a01f4f990459d4144414;p=thirdparty%2Fbind9.git [rt46602] Adjust rpzrecurse for dynamic port usage Resolve conflict in run.sh during cherry-pick from an experimental branch. --- diff --git a/bin/tests/system/Makefile.in b/bin/tests/system/Makefile.in index 16a5f6c96b1..484bccf2fb2 100644 --- a/bin/tests/system/Makefile.in +++ b/bin/tests/system/Makefile.in @@ -45,16 +45,14 @@ feature-test@EXEEXT@: feature-test.@O@ check: test -TESTS = allow_query serve-stale +TESTS = allow_query serve-stale rpzrecurse test: subdirs $(TESTS) if test -f ./runall.sh; then $(SHELL) ./runall.sh; fi -serve-stale: - $(SHELL) ./run.sh -p 5304 -c 9954 $@ - -allow_query: - $(SHELL) ./run.sh -p 5305 -c 9955 $@ +$(TESTS): + PORT=$$((32767+$$RANDOM)); \ + $(SHELL) ./run.sh -p $$(($$PORT)) -c $$(($$PORT+1)) $@ testclean clean distclean:: if test -f ./cleanall.sh; then sh ./cleanall.sh; fi diff --git a/bin/tests/system/conf.sh.in b/bin/tests/system/conf.sh.in index d76a817ddad..bc553905c8d 100644 --- a/bin/tests/system/conf.sh.in +++ b/bin/tests/system/conf.sh.in @@ -82,7 +82,7 @@ SUBDIRS="acl additional addzone auth autosign builtin logfileconfig masterfile masterformat metadata mkeys names notify nslookup nsupdate nzd2nzf padding pending pipelined @PKCS11_TEST@ reclimit redirect resolver rndc - rpz rpzrecurse rrchecker rrl rrsetorder rsabigexponent + rpz rrchecker rrl rrsetorder rsabigexponent runtime sfcache smartsign sortlist spf staticstub statistics statschannel stub synthfromdnssec tcp tkey tools tsig tsiggss unknown upforwd verify views wildcard xfer diff --git a/bin/tests/system/conf.sh.win32 b/bin/tests/system/conf.sh.win32 index 2d48882289c..492fbb81d21 100644 --- a/bin/tests/system/conf.sh.win32 +++ b/bin/tests/system/conf.sh.win32 @@ -79,7 +79,7 @@ KRB5_CONFIG=NUL # The "stress" test is not run by default since it creates enough # load on the machine to make it unusable to other users. # v6synth -SUBDIRS="acl additional addzone allow_query autosign builtin +SUBDIRS="acl additional addzone autosign builtin cacheclean case catz checkconf @CHECKDS@ checknames checkzone cookie @COVERAGE@ database digdelv dlv dlvauto dlz dlzexternal dname @@ -89,7 +89,7 @@ SUBDIRS="acl additional addzone allow_query autosign builtin keepalive @KEYMGR@ legacy limits logfileconfig masterfile masterformat metadata mkeys names notify nslookup nsupdate nzd2nzf padding pending pipelined @PKCS11_TEST@ reclimit - redirect resolver rndc rpz rpzrecurse rrchecker rrl + redirect resolver rndc rpz rrchecker rrl rrsetorder rsabigexponent runtime sfcache smartsign sortlist spf staticstub statistics statschannel stub tcp tkey tsig tsiggss unknown upforwd verify views wildcard xfer xferquota diff --git a/bin/tests/system/getopts.sh b/bin/tests/system/getopts.sh index cd8d5b0e143..af61ae281b6 100644 --- a/bin/tests/system/getopts.sh +++ b/bin/tests/system/getopts.sh @@ -10,7 +10,7 @@ port=5300 controlport=9953 -while getopts "p:c:" flag; do +while getopts ":p:c:" flag; do case "$flag" in p) port=$OPTARG ;; c) controlport=$OPTARG ;; @@ -19,5 +19,6 @@ while getopts "p:c:" flag; do esac done shift $(($OPTIND - 1)) +OPTIND=1 SEDPORTS="sed -e s/@PORT@/${port}/g -e s/@CONTROLPORT@/${controlport}/g" diff --git a/bin/tests/system/rpzrecurse/.gitignore b/bin/tests/system/rpzrecurse/.gitignore index 6154e068775..ed45f426ce1 100644 --- a/bin/tests/system/rpzrecurse/.gitignore +++ b/bin/tests/system/rpzrecurse/.gitignore @@ -1,2 +1,11 @@ -/rpz -/rpz.o +/ns1/named.conf +/ns2/named.conf.header +/ns2/named.conf +/ns3/named.conf +/ns4/named.conf +/ans5/ans.pl +/ans5/ans.pid +/dnsrps-slave.conf +/dnsrps.conf +/dnsrpzd.conf +session.key diff --git a/bin/tests/system/rpzrecurse/ans5/ans.pl b/bin/tests/system/rpzrecurse/ans5/ans.pl.in similarity index 96% rename from bin/tests/system/rpzrecurse/ans5/ans.pl rename to bin/tests/system/rpzrecurse/ans5/ans.pl.in index 481b794cc83..1e04f88c045 100644 --- a/bin/tests/system/rpzrecurse/ans5/ans.pl +++ b/bin/tests/system/rpzrecurse/ans5/ans.pl.in @@ -12,7 +12,7 @@ use Net::DNS; use Net::DNS::Packet; my $sock = IO::Socket::INET->new(LocalAddr => "10.53.0.5", - LocalPort => 5300, Proto => "udp") or die "$!"; + LocalPort => @PORT@, Proto => "udp") or die "$!"; my $pidf = new IO::File "ans.pid", "w" or die "cannot open pid file: $!"; print $pidf "$$\n" or die "cannot write pid file: $!"; diff --git a/bin/tests/system/rpzrecurse/ns1/named.conf b/bin/tests/system/rpzrecurse/ns1/named.conf.in similarity index 98% rename from bin/tests/system/rpzrecurse/ns1/named.conf rename to bin/tests/system/rpzrecurse/ns1/named.conf.in index d1b1319be33..ddd7b1c54ae 100644 --- a/bin/tests/system/rpzrecurse/ns1/named.conf +++ b/bin/tests/system/rpzrecurse/ns1/named.conf.in @@ -10,7 +10,7 @@ options { query-source address 10.53.0.1; notify-source 10.53.0.1; transfer-source 10.53.0.1; - port 5300; + port @PORT@; session-keyfile "session.key"; pid-file "named.pid"; listen-on { 10.53.0.1; }; diff --git a/bin/tests/system/rpzrecurse/ns2/named.conf.header b/bin/tests/system/rpzrecurse/ns2/named.conf.header.in similarity index 89% rename from bin/tests/system/rpzrecurse/ns2/named.conf.header rename to bin/tests/system/rpzrecurse/ns2/named.conf.header.in index 3fdd026b9fc..ec60cb540fe 100644 --- a/bin/tests/system/rpzrecurse/ns2/named.conf.header +++ b/bin/tests/system/rpzrecurse/ns2/named.conf.header.in @@ -12,7 +12,7 @@ options { query-source address 10.53.0.2; notify-source 10.53.0.2; transfer-source 10.53.0.2; - port 5300; + port @PORT@; session-keyfile "session.key"; pid-file "named.pid"; listen-on { 10.53.0.2; }; @@ -30,6 +30,6 @@ key rndc_key { }; controls { - inet 10.53.0.2 port 9953 allow { any; } keys { rndc_key; }; + inet 10.53.0.2 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; }; diff --git a/bin/tests/system/rpzrecurse/ns3/named1.conf b/bin/tests/system/rpzrecurse/ns3/named1.conf.in similarity index 90% rename from bin/tests/system/rpzrecurse/ns3/named1.conf rename to bin/tests/system/rpzrecurse/ns3/named1.conf.in index c98c8c9182b..5572ddbd88e 100644 --- a/bin/tests/system/rpzrecurse/ns3/named1.conf +++ b/bin/tests/system/rpzrecurse/ns3/named1.conf.in @@ -9,14 +9,14 @@ include "../../common/rndc.key"; controls { - inet 10.53.0.3 port 9953 allow { any; } keys { rndc_key; }; + inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; }; options { query-source address 10.53.0.3; notify-source 10.53.0.3; transfer-source 10.53.0.3; - port 5300; + port @PORT@; session-keyfile "session.key"; pid-file "named.pid"; listen-on { 10.53.0.3; }; diff --git a/bin/tests/system/rpzrecurse/ns3/named2.conf b/bin/tests/system/rpzrecurse/ns3/named2.conf.in similarity index 90% rename from bin/tests/system/rpzrecurse/ns3/named2.conf rename to bin/tests/system/rpzrecurse/ns3/named2.conf.in index f7b9e9ef615..5fb8f010f7a 100644 --- a/bin/tests/system/rpzrecurse/ns3/named2.conf +++ b/bin/tests/system/rpzrecurse/ns3/named2.conf.in @@ -9,14 +9,14 @@ include "../../common/rndc.key"; controls { - inet 10.53.0.3 port 9953 allow { any; } keys { rndc_key; }; + inet 10.53.0.3 port @CONTROLPORT@ allow { any; } keys { rndc_key; }; }; options { query-source address 10.53.0.3; notify-source 10.53.0.3; transfer-source 10.53.0.3; - port 5300; + port @PORT@; pid-file "named.pid"; listen-on { 10.53.0.3; }; listen-on-v6 { none; }; diff --git a/bin/tests/system/rpzrecurse/ns4/named.conf b/bin/tests/system/rpzrecurse/ns4/named.conf.in similarity index 97% rename from bin/tests/system/rpzrecurse/ns4/named.conf rename to bin/tests/system/rpzrecurse/ns4/named.conf.in index f76d7bce1ce..0473d5c2039 100644 --- a/bin/tests/system/rpzrecurse/ns4/named.conf +++ b/bin/tests/system/rpzrecurse/ns4/named.conf.in @@ -12,7 +12,7 @@ options { query-source address 10.53.0.4; notify-source 10.53.0.4; transfer-source 10.53.0.4; - port 5300; + port @PORT@; session-keyfile "session.key"; pid-file "named.pid"; listen-on { 10.53.0.4; }; diff --git a/bin/tests/system/rpzrecurse/setup.sh b/bin/tests/system/rpzrecurse/setup.sh index 795d357acd9..dba93e35d2f 100644 --- a/bin/tests/system/rpzrecurse/setup.sh +++ b/bin/tests/system/rpzrecurse/setup.sh @@ -13,6 +13,8 @@ set -e SYSTEMTESTTOP=.. . $SYSTEMTESTTOP/conf.sh +. ../getopts.sh + USAGE="$0: [-xD]" DEBUG= while getopts "xD" c; do @@ -32,8 +34,16 @@ fi [ ${NOCLEAN:-unset} = unset ] && $SHELL clean.sh $DEBUG $PERL testgen.pl +$SEDPORTS < ns1/named.conf.in > ns1/named.conf +echo "${port}" > ns1/named.port +$SEDPORTS < ns2/named.conf.header.in > ns2/named.conf.header +echo "${port}" > ns2/named.port cp -f ns2/named.default.conf ns2/named.conf -cp -f ns3/named1.conf ns3/named.conf +$SEDPORTS < ns3/named1.conf.in > ns3/named.conf +echo "${port}" > ns3/named.port +$SEDPORTS < ns4/named.conf.in > ns4/named.conf +echo "${port}" > ns4/named.port +$SEDPORTS < ans5/ans.pl.in > ans5/ans.pl # decide whether to test DNSRPS $SHELL ../rpz/ckdnsrps.sh $TEST_DNSRPS $DEBUG diff --git a/bin/tests/system/rpzrecurse/tests.sh b/bin/tests/system/rpzrecurse/tests.sh index 38032175523..f35159c0ad6 100644 --- a/bin/tests/system/rpzrecurse/tests.sh +++ b/bin/tests/system/rpzrecurse/tests.sh @@ -38,18 +38,18 @@ trap 'exit 1' 1 2 15 DNSRPSCMD=../rpz/dnsrps -RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p 9953 -s" +RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s" # $1 = test name (such as 1a, 1b, etc. for which named.$1.conf exists) run_server() { TESTNAME=$1 - echo "I:stopping resolver" + echo_i "stopping resolver" $PERL $SYSTEMTESTTOP/stop.pl . ns2 sleep 1 - echo "I:starting resolver using named.$TESTNAME.conf" + echo_i "starting resolver using named.$TESTNAME.conf" cp -f ns2/named.$TESTNAME.conf ns2/named.conf $PERL $SYSTEMTESTTOP/start.pl --noclean --restart . ns2 sleep 3 @@ -60,7 +60,7 @@ run_query() { LINE=$2 NAME=`sed -n -e "$LINE,"'$p' ns2/$TESTNAME.queries | head -n 1` - $DIG $DIGOPTS $NAME a @10.53.0.2 -p 5300 -b 127.0.0.1 > dig.out.${t} + $DIG $DIGOPTS $NAME a @10.53.0.2 -p ${PORT} -b 127.0.0.1 > dig.out.${t} grep "status: SERVFAIL" dig.out.${t} > /dev/null 2>&1 && return 1 return 0 } @@ -73,10 +73,10 @@ expect_norecurse() { NAME=`sed -n -e "$LINE,"'$p' ns2/$TESTNAME.queries | head -n 1` t=`expr $t + 1` - echo "I:testing $NAME doesn't recurse (${t})" + echo_i "testing $NAME doesn't recurse (${t})" add_test_marker 10.53.0.2 run_query $TESTNAME $LINE || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } } @@ -89,10 +89,10 @@ expect_recurse() { NAME=`sed -n -e "$LINE,"'$p' ns2/$TESTNAME.queries | head -n 1` t=`expr $t + 1` - echo "I:testing $NAME recurses (${t})" + echo_i "testing $NAME recurses (${t})" add_test_marker 10.53.0.2 run_query $TESTNAME $LINE && { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } } @@ -118,17 +118,17 @@ do case $mode in native) if [ ${DNSRPS_TEST_MODE:-unset} = unset -a -e dnsrps-only ] ; then - echo "I:'dnsrps-only' found: skipping native RPZ sub-test" + echo_i "'dnsrps-only' found: skipping native RPZ sub-test" continue fi ;; dnsrps) if [ ${DNSRPS_TEST_MODE:-unset} = unset -a -e dnsrps-off ] ; then - echo "I:'dnsrps-off' found: skipping DNSRPS sub-test" + echo_i "'dnsrps-off' found: skipping DNSRPS sub-test" continue fi if grep '^#skip' dnsrps.conf > /dev/null ; then - echo "I:DNSRPS sub-test skipped" + echo_i "DNSRPS sub-test skipped" continue fi $SHELL ./setup.sh -N -D $DEBUG @@ -143,20 +143,20 @@ do sed -n 's/^## /I:/p' dnsrps.conf t=`expr $t + 1` - echo "I:testing that l1.l0 exists without RPZ (${t})" + echo_i "testing that l1.l0 exists without RPZ (${t})" add_test_marker 10.53.0.2 - $DIG $DIGOPTS l1.l0 ns @10.53.0.2 -p 5300 > dig.out.${t} + $DIG $DIGOPTS l1.l0 ns @10.53.0.2 -p ${PORT} > dig.out.${t} grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } t=`expr $t + 1` - echo "I:testing that l2.l1.l0 returns SERVFAIL without RPZ (${t})" + echo_i "testing that l2.l1.l0 returns SERVFAIL without RPZ (${t})" add_test_marker 10.53.0.2 - $DIG $DIGOPTS l2.l1.l0 ns @10.53.0.2 -p 5300 > dig.out.${t} + $DIG $DIGOPTS l2.l1.l0 ns @10.53.0.2 -p ${PORT} > dig.out.${t} grep "status: SERVFAIL" dig.out.${t} > /dev/null 2>&1 || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } @@ -210,7 +210,7 @@ do run_server 4$n ni=$1 t=`expr $t + 1` - echo "I:testing that ${ni} of 33 queries skip recursion (${t})" + echo_i "testing that ${ni} of 33 queries skip recursion (${t})" add_test_marker 10.53.0.2 c=0 for i in 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 \ @@ -221,7 +221,7 @@ do done skipped=`expr 33 - $c` if [ $skipped != $ni ]; then - echo "I:test $t failed (actual=$skipped, expected=$ni)" + echo_i "test $t failed (actual=$skipped, expected=$ni)" status=1 fi shift @@ -239,15 +239,15 @@ do if [ ! "$CYGWIN" -o -n "$PSSUSPEND" ] then # Group 6 - echo "I:check recursive behavior consistency during policy update races" + echo_i "check recursive behavior consistency during policy update races" run_server 6a sleep 1 t=`expr $t + 1` - echo "I:running dig to cache CNAME record (${t})" + echo_i "running dig to cache CNAME record (${t})" add_test_marker 10.53.0.1 10.53.0.2 - $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org CNAME > dig.out.${t} + $DIG $DIGOPTS @10.53.0.2 -p ${PORT} www.test.example.org CNAME > dig.out.${t} sleep 1 - echo "I:suspending authority server" + echo_i "suspending authority server" PID=`cat ns1/named.pid` if [ "$CYGWIN" ] then @@ -255,23 +255,23 @@ do else $KILL -STOP $PID fi - echo "I:adding an NSDNAME policy" + echo_i "adding an NSDNAME policy" cp ns2/db.6a.00.policy.local ns2/saved.policy.local cp ns2/db.6b.00.policy.local ns2/db.6a.00.policy.local - $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /' + $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT} reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /' test -f dnsrpzd.pid && $KILL -USR1 `cat dnsrpzd.pid` sleep 1 t=`expr $t + 1` - echo "I:running dig to follow CNAME (blocks, so runs in the background) (${t})" + echo_i "running dig to follow CNAME (blocks, so runs in the background) (${t})" add_test_marker 10.53.0.2 - $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org A > dig.out.${t} & + $DIG $DIGOPTS @10.53.0.2 -p ${PORT} www.test.example.org A > dig.out.${t} & sleep 1 - echo "I:removing the NSDNAME policy" + echo_i "removing the NSDNAME policy" cp ns2/db.6c.00.policy.local ns2/db.6a.00.policy.local - $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /' + $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT} reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /' test -f dnsrpzd.pid && $KILL -USR1 `cat dnsrpzd.pid` sleep 1 - echo "I:resuming authority server" + echo_i "resuming authority server" PID=`cat ns1/named.pid` if [ "$CYGWIN" ] then @@ -287,20 +287,20 @@ do grep "status: .*," dig.out.${t} > /dev/null 2>&1 && break done grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } - echo "I:check recursive behavior consistency during policy removal races" + echo_i "check recursive behavior consistency during policy removal races" cp ns2/saved.policy.local ns2/db.6a.00.policy.local run_server 6a sleep 1 t=`expr $t + 1` - echo "I:running dig to cache CNAME record (${t})" + echo_i "running dig to cache CNAME record (${t})" add_test_marker 10.53.0.1 10.53.0.2 - $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org CNAME > dig.out.${t} + $DIG $DIGOPTS @10.53.0.2 -p ${PORT} www.test.example.org CNAME > dig.out.${t} sleep 1 - echo "I:suspending authority server" + echo_i "suspending authority server" PID=`cat ns1/named.pid` if [ "$CYGWIN" ] then @@ -308,22 +308,22 @@ do else $KILL -STOP $PID fi - echo "I:adding an NSDNAME policy" + echo_i "adding an NSDNAME policy" cp ns2/db.6b.00.policy.local ns2/db.6a.00.policy.local - $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /' + $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT} reload 6a.00.policy.local 2>&1 | sed 's/^/I:ns2 /' test -f dnsrpzd.pid && $KILL -USR1 `cat dnsrpzd.pid` sleep 1 t=`expr $t + 1` - echo "I:running dig to follow CNAME (blocks, so runs in the background) (${t})" + echo_i "running dig to follow CNAME (blocks, so runs in the background) (${t})" add_test_marker 10.53.0.2 - $DIG $DIGOPTS @10.53.0.2 -p 5300 www.test.example.org A > dig.out.${t} & + $DIG $DIGOPTS @10.53.0.2 -p ${PORT} www.test.example.org A > dig.out.${t} & sleep 1 - echo "I:removing the policy zone" + echo_i "removing the policy zone" cp ns2/named.default.conf ns2/named.conf - $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p 9953 reconfig 2>&1 | sed 's/^/I:ns2 /' + $RNDC -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT} reconfig 2>&1 | sed 's/^/I:ns2 /' test -f dnsrpzd.pid && $KILL -USR1 `cat dnsrpzd.pid` sleep 1 - echo "I:resuming authority server" + echo_i "resuming authority server" PID=`cat ns1/named.pid` if [ "$CYGWIN" ] then @@ -338,160 +338,160 @@ do grep "status: .*," dig.out.${t} > /dev/null 2>&1 && break done grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } fi # Check CLIENT-IP behavior t=`expr $t + 1` - echo "I:testing CLIENT-IP behavior (${t})" + echo_i "testing CLIENT-IP behavior (${t})" add_test_marker 10.53.0.2 run_server clientip - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.4 > dig.out.${t} + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.4 > dig.out.${t} grep "status: NOERROR" dig.out.${t} > /dev/null 2>&1 || { - echo "I:test $t failed: query failed" + echo_i "test $t failed: query failed" status=1 } grep "^l2.l1.l0.[ ]*[0-9]*[ ]*IN[ ]*A[ ]*10.53.0.2" dig.out.${t} > /dev/null 2>&1 || { - echo "I:test $t failed: didn't get expected answer" + echo_i "test $t failed: didn't get expected answer" status=1 } # Check CLIENT-IP behavior #2 t=`expr $t + 1` - echo "I:testing CLIENT-IP behavior #2 (${t})" + echo_i "testing CLIENT-IP behavior #2 (${t})" add_test_marker 10.53.0.2 run_server clientip2 - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.1 > dig.out.${t}.1 + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.1 > dig.out.${t}.1 grep "status: SERVFAIL" dig.out.${t}.1 > /dev/null 2>&1 || { - echo "I:test $t failed: query failed" + echo_i "test $t failed: query failed" status=1 } - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.2 > dig.out.${t}.2 + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.2 > dig.out.${t}.2 grep "status: NXDOMAIN" dig.out.${t}.2 > /dev/null 2>&1 || { - echo "I:test $t failed: query failed" + echo_i "test $t failed: query failed" status=1 } - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.3 > dig.out.${t}.3 + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.3 > dig.out.${t}.3 grep "status: NOERROR" dig.out.${t}.3 > /dev/null 2>&1 || { - echo "I:test $t failed: query failed" + echo_i "test $t failed: query failed" status=1 } grep "^l2.l1.l0.[ ]*[0-9]*[ ]*IN[ ]*A[ ]*10.53.0.1" dig.out.${t}.3 > /dev/null 2>&1 || { - echo "I:test $t failed: didn't get expected answer" + echo_i "test $t failed: didn't get expected answer" status=1 } - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.4 > dig.out.${t}.4 + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.4 > dig.out.${t}.4 grep "status: SERVFAIL" dig.out.${t}.4 > /dev/null 2>&1 || { - echo "I:test $t failed: query failed" + echo_i "test $t failed: query failed" status=1 } # Check RPZ log clause t=`expr $t + 1` - echo "I:testing RPZ log clause (${t})" + echo_i "testing RPZ log clause (${t})" add_test_marker 10.53.0.2 run_server log cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns2/named.run` - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.4 > dig.out.${t} - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.3 >> dig.out.${t} - $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p 5300 -b 10.53.0.2 >> dig.out.${t} + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.4 > dig.out.${t} + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.3 >> dig.out.${t} + $DIG $DIGOPTS l2.l1.l0 a @10.53.0.2 -p ${PORT} -b 10.53.0.2 >> dig.out.${t} sed -n "$cur,"'$p' < ns2/named.run | grep "view recursive: rpz CLIENT-IP Local-Data rewrite l2.l1.l0 via 32.4.0.53.10.rpz-client-ip.log1" > /dev/null && { - echo "I: failed: unexpected rewrite message for policy zone log1 was logged" + echo_i " failed: unexpected rewrite message for policy zone log1 was logged" status=1 } sed -n "$cur,"'$p' < ns2/named.run | grep "view recursive: rpz CLIENT-IP Local-Data rewrite l2.l1.l0 via 32.3.0.53.10.rpz-client-ip.log2" > /dev/null || { - echo "I: failed: expected rewrite message for policy zone log2 was not logged" + echo_i " failed: expected rewrite message for policy zone log2 was not logged" status=1 } sed -n "$cur,"'$p' < ns2/named.run | grep "view recursive: rpz CLIENT-IP Local-Data rewrite l2.l1.l0 via 32.2.0.53.10.rpz-client-ip.log3" > /dev/null || { - echo "I: failed: expected rewrite message for policy zone log3 was not logged" + echo_i " failed: expected rewrite message for policy zone log3 was not logged" status=1 } # Check wildcard behavior t=`expr $t + 1` - echo "I:testing wildcard behavior with 1 RPZ zone (${t})" + echo_i "testing wildcard behavior with 1 RPZ zone (${t})" add_test_marker 10.53.0.2 run_server wildcard1 - $DIG $DIGOPTS www.test1.example.net a @10.53.0.2 -p 5300 > dig.out.${t}.1 + $DIG $DIGOPTS www.test1.example.net a @10.53.0.2 -p ${PORT} > dig.out.${t}.1 grep "status: NXDOMAIN" dig.out.${t}.1 > /dev/null || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } - $DIG $DIGOPTS test1.example.net a @10.53.0.2 -p 5300 > dig.out.${t}.2 + $DIG $DIGOPTS test1.example.net a @10.53.0.2 -p ${PORT} > dig.out.${t}.2 grep "status: NXDOMAIN" dig.out.${t}.2 > /dev/null || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } t=`expr $t + 1` - echo "I:testing wildcard behavior with 2 RPZ zones (${t})" + echo_i "testing wildcard behavior with 2 RPZ zones (${t})" add_test_marker 10.53.0.2 run_server wildcard2 - $DIG $DIGOPTS www.test1.example.net a @10.53.0.2 -p 5300 > dig.out.${t}.1 + $DIG $DIGOPTS www.test1.example.net a @10.53.0.2 -p ${PORT} > dig.out.${t}.1 grep "status: NXDOMAIN" dig.out.${t}.1 > /dev/null || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } - $DIG $DIGOPTS test1.example.net a @10.53.0.2 -p 5300 > dig.out.${t}.2 + $DIG $DIGOPTS test1.example.net a @10.53.0.2 -p ${PORT} > dig.out.${t}.2 grep "status: NXDOMAIN" dig.out.${t}.2 > /dev/null || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } t=`expr $t + 1` - echo "I:testing wildcard behavior with 1 RPZ zone and no non-wildcard triggers (${t})" + echo_i "testing wildcard behavior with 1 RPZ zone and no non-wildcard triggers (${t})" add_test_marker 10.53.0.2 run_server wildcard3 - $DIG $DIGOPTS www.test1.example.net a @10.53.0.2 -p 5300 > dig.out.${t}.1 + $DIG $DIGOPTS www.test1.example.net a @10.53.0.2 -p ${PORT} > dig.out.${t}.1 grep "status: NXDOMAIN" dig.out.${t}.1 > /dev/null || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } - $DIG $DIGOPTS test1.example.net a @10.53.0.2 -p 5300 > dig.out.${t}.2 + $DIG $DIGOPTS test1.example.net a @10.53.0.2 -p ${PORT} > dig.out.${t}.2 grep "status: NOERROR" dig.out.${t}.2 > /dev/null || { - echo "I:test ${t} failed" + echo_i "test ${t} failed" status=1 } t=`expr $t + 1` - echo "I:checking 'nsip-wait-recurse no' is faster than 'nsip-wait-recurse yes' ($t)" + echo_i "checking 'nsip-wait-recurse no' is faster than 'nsip-wait-recurse yes' ($t)" add_test_marker 10.53.0.2 - echo "I:timing 'nsip-wait-recurse yes' (default)" + echo_i "timing 'nsip-wait-recurse yes' (default)" ret=0 t1=`$PERL -e 'print time()."\n";'` - $DIG -p 5300 @10.53.0.3 foo.child.example.tld a > dig.out.yes.$t + $DIG -p ${PORT} @10.53.0.3 foo.child.example.tld a > dig.out.yes.$t t2=`$PERL -e 'print time()."\n";'` p1=`expr $t2 - $t1` - echo "I:elasped time $p1 seconds" + echo_i "elasped time $p1 seconds" - $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 flush + $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p ${CONTROLPORT} flush cp -f ns3/named2.conf ns3/named.conf - $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p 9953 reload > /dev/null + $RNDC -c ../common/rndc.conf -s 10.53.0.3 -p ${CONTROLPORT} reload > /dev/null - echo "I:timing 'nsip-wait-recurse no'" + echo_i "timing 'nsip-wait-recurse no'" t3=`$PERL -e 'print time()."\n";'` - $DIG -p 5300 @10.53.0.3 foo.child.example.tld a > dig.out.no.$t + $DIG -p ${PORT} @10.53.0.3 foo.child.example.tld a > dig.out.no.$t t4=`$PERL -e 'print time()."\n";'` p2=`expr $t4 - $t3` - echo "I:elasped time $p2 seconds" + echo_i "elasped time $p2 seconds" if test $p1 -le $p2; then ret=1; fi - if test $ret != 0; then echo "I:failed"; fi + if test $ret != 0; then echo_i "failed"; fi status=`expr $status + $ret` [ $status -ne 0 ] && pf=fail || pf=pass case $mode in native) native=$status - echo "I:status (native RPZ sub-test): $status ($pf)";; + echo_i "status (native RPZ sub-test): $status ($pf)";; dnsrps) dnsrps=$status - echo "I:status (DNSRPS sub-test): $status ($pf)";; - *) echo "I:invalid test mode";; + echo_i "status (DNSRPS sub-test): $status ($pf)";; + *) echo_i "invalid test mode";; esac done status=`expr ${native:-0} + ${dnsrps:-0}` diff --git a/bin/tests/system/run.sh b/bin/tests/system/run.sh index 908a91a052a..f26743cf4ad 100644 --- a/bin/tests/system/run.sh +++ b/bin/tests/system/run.sh @@ -38,9 +38,6 @@ if [ "$((${controlport}+0))" -ne "${controlport}" ] || [ "${controlport}" -le 10 echo "Specified control port '$controlport' must be numeric (1024,65535>" >&2; exit 1; fi -echo "PORT: ${port}" -echo "CONTROLPORT: ${controlport}" - shift $(($OPTIND - 1)) test $# -gt 0 || { echo "usage: $0 [-k|-n|-p ] test-directory" >&2; exit 1; } @@ -48,11 +45,13 @@ test $# -gt 0 || { echo "usage: $0 [-k|-n|-p ] test-directory" >&2; exit 1 test=$1 shift -test -d $test || { echo "$0: $test: no such test" >&2; exit 1; } +test -d $test || { echofail "$0: $test: no such test" >&2; exit 1; } echoinfo "S:$test:`date $dateargs`" >&2 echoinfo "T:$test:1:A" >&2 -echoinfo "A:System test $test" >&2 +echoinfo "A:$test:System test $test" >&2 +echoinfo "I:$test:PORT:${port}" >&2 +echoinfo "I:$test:CONTROLPORT:${controlport}" >&2 if [ x${PERL:+set} = x ] then @@ -63,7 +62,7 @@ then fi # Check for test-specific prerequisites. -test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh -c "$controlport" -p "$port" "$@" ) +test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh -c "$controlport" -p "$port" -- "$@" ) result=$? if [ $result -eq 0 ]; then @@ -98,14 +97,14 @@ fi # Set up any dynamically generated test data if test -f $test/setup.sh then - ( cd $test && $SHELL setup.sh -c "$controlport" -p "$port" "$@" ) + ( cd $test && $SHELL setup.sh -c "$controlport" -p "$port" -- "$@" ) fi # Start name servers running -$PERL start.pl -p $port $test || { echofail "R:$test:$FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; } +$PERL start.pl -p $port $test || { echofail "R:$test:FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; } # Run the tests -( cd $test ; $SHELL tests.sh -c "$controlport" -p "$port" "$@" ) +( cd $test ; $SHELL tests.sh -c "$controlport" -p "$port" -- "$@" ) status=$? @@ -132,7 +131,7 @@ else rm -f $SYSTEMTESTTOP/random.data if test -f $test/clean.sh then - ( cd $test && $SHELL clean.sh "-p" "$port" "$@" ) + ( cd $test && $SHELL clean.sh "-p" "$port" -- "$@" ) fi if test -d ../../../.git then