From: Stephen Morris Date: Wed, 15 Nov 2017 18:44:54 +0000 (+0000) Subject: [rt46602] Miscellaneous tidying up of code cherry-picked from experimental branch X-Git-Tag: v9.13.0~158^2~47 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e1a69e5d1f1e9e38db9cbd14bc2aeb54f420ace9;p=thirdparty%2Fbind9.git [rt46602] Miscellaneous tidying up of code cherry-picked from experimental branch --- diff --git a/bin/tests/system/allow_query/setup.sh b/bin/tests/system/allow_query/setup.sh index b267da98e67..53f030681b2 100644 --- a/bin/tests/system/allow_query/setup.sh +++ b/bin/tests/system/allow_query/setup.sh @@ -10,6 +10,6 @@ . ../getopts.sh -sed -e "s/@PORT@/${port}/g;s/@CONTROLPORT@/${controlport}/g;" < ../common/controls.conf.in > ns2/controls.conf -sed -e "s/@PORT@/${port}/g;s/@CONTROLPORT@/${controlport}/g;" < ns2/named01.conf.in > ns2/named.conf +copy_config ../common/controls.conf.in ns2/controls.conf +copy_config ns2/named01.conf.in ns2/named.conf echo "${port}" > ns2/named.port diff --git a/bin/tests/system/allow_query/tests.sh b/bin/tests/system/allow_query/tests.sh index 7cfbdbbd6d7..b8a7ea2749b 100644 --- a/bin/tests/system/allow_query/tests.sh +++ b/bin/tests/system/allow_query/tests.sh @@ -51,8 +51,7 @@ SYSTEMTESTTOP=.. . $SYSTEMTESTTOP/conf.sh - -. ../getopts.sh +. $SYSTEMTESTTOP/getopts.sh DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p ${port}" @@ -76,7 +75,7 @@ status=`expr $status + $ret` # Test 2 - explicit any, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named02.conf.in > ns2/named.conf +copy_config ns2/named02.conf.in ns2/named.conf rndc_reload sleep 5 @@ -90,7 +89,7 @@ status=`expr $status + $ret` # Test 3 - none, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named03.conf.in > ns2/named.conf +copy_config ns2/named03.conf.in ns2/named.conf rndc_reload sleep 5 @@ -104,7 +103,7 @@ status=`expr $status + $ret` # Test 4 - address allowed, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named04.conf.in > ns2/named.conf +copy_config ns2/named04.conf.in ns2/named.conf rndc_reload sleep 5 @@ -118,7 +117,7 @@ status=`expr $status + $ret` # Test 5 - address not allowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named05.conf.in > ns2/named.conf +copy_config ns2/named05.conf.in ns2/named.conf rndc_reload sleep 5 @@ -132,7 +131,7 @@ status=`expr $status + $ret` # Test 6 - address disallowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named06.conf.in > ns2/named.conf +copy_config ns2/named06.conf.in ns2/named.conf rndc_reload sleep 5 @@ -146,7 +145,7 @@ status=`expr $status + $ret` # Test 7 - acl allowed, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named07.conf.in > ns2/named.conf +copy_config ns2/named07.conf.in ns2/named.conf rndc_reload sleep 5 @@ -160,7 +159,7 @@ status=`expr $status + $ret` # Test 8 - acl not allowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named08.conf.in > ns2/named.conf +copy_config ns2/named08.conf.in ns2/named.conf rndc_reload sleep 5 @@ -175,7 +174,7 @@ status=`expr $status + $ret` # Test 9 - acl disallowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named09.conf.in > ns2/named.conf +copy_config ns2/named09.conf.in ns2/named.conf rndc_reload sleep 5 @@ -189,7 +188,7 @@ status=`expr $status + $ret` # Test 10 - key allowed, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named10.conf.in > ns2/named.conf +copy_config ns2/named10.conf.in ns2/named.conf rndc_reload sleep 5 @@ -203,7 +202,7 @@ status=`expr $status + $ret` # Test 11 - key not allowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named11.conf.in > ns2/named.conf +copy_config ns2/named11.conf.in ns2/named.conf rndc_reload sleep 5 @@ -217,7 +216,7 @@ status=`expr $status + $ret` # Test 12 - key disallowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named12.conf.in > ns2/named.conf +copy_config ns2/named12.conf.in ns2/named.conf rndc_reload sleep 5 @@ -234,7 +233,7 @@ status=`expr $status + $ret` n=20 # Test 21 - views default, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named21.conf.in > ns2/named.conf +copy_config ns2/named21.conf.in ns2/named.conf rndc_reload sleep 5 @@ -248,7 +247,7 @@ status=`expr $status + $ret` # Test 22 - views explicit any, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named22.conf.in > ns2/named.conf +copy_config ns2/named22.conf.in ns2/named.conf rndc_reload sleep 5 @@ -262,7 +261,7 @@ status=`expr $status + $ret` # Test 23 - views none, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named23.conf.in > ns2/named.conf +copy_config ns2/named23.conf.in ns2/named.conf rndc_reload sleep 5 @@ -276,7 +275,7 @@ status=`expr $status + $ret` # Test 24 - views address allowed, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named24.conf.in > ns2/named.conf +copy_config ns2/named24.conf.in ns2/named.conf rndc_reload sleep 5 @@ -290,7 +289,7 @@ status=`expr $status + $ret` # Test 25 - views address not allowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named25.conf.in > ns2/named.conf +copy_config ns2/named25.conf.in ns2/named.conf rndc_reload sleep 5 @@ -304,7 +303,7 @@ status=`expr $status + $ret` # Test 26 - views address disallowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named26.conf.in > ns2/named.conf +copy_config ns2/named26.conf.in ns2/named.conf rndc_reload sleep 5 @@ -318,7 +317,7 @@ status=`expr $status + $ret` # Test 27 - views acl allowed, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named27.conf.in > ns2/named.conf +copy_config ns2/named27.conf.in ns2/named.conf rndc_reload sleep 5 @@ -332,7 +331,7 @@ status=`expr $status + $ret` # Test 28 - views acl not allowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named28.conf.in > ns2/named.conf +copy_config ns2/named28.conf.in ns2/named.conf rndc_reload sleep 5 @@ -346,7 +345,7 @@ status=`expr $status + $ret` # Test 29 - views acl disallowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named29.conf.in > ns2/named.conf +copy_config ns2/named29.conf.in ns2/named.conf rndc_reload sleep 5 @@ -360,7 +359,7 @@ status=`expr $status + $ret` # Test 30 - views key allowed, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named30.conf.in > ns2/named.conf +copy_config ns2/named30.conf.in ns2/named.conf rndc_reload sleep 5 @@ -374,7 +373,7 @@ status=`expr $status + $ret` # Test 31 - views key not allowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named31.conf.in > ns2/named.conf +copy_config ns2/named31.conf.in ns2/named.conf rndc_reload sleep 5 @@ -388,7 +387,7 @@ status=`expr $status + $ret` # Test 32 - views key disallowed, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named32.conf.in > ns2/named.conf +copy_config ns2/named32.conf.in ns2/named.conf rndc_reload sleep 5 @@ -402,7 +401,7 @@ status=`expr $status + $ret` # Test 33 - views over options, views allow, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named33.conf.in > ns2/named.conf +copy_config ns2/named33.conf.in ns2/named.conf rndc_reload sleep 5 @@ -416,7 +415,7 @@ status=`expr $status + $ret` # Test 34 - views over options, views disallow, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named34.conf.in > ns2/named.conf +copy_config ns2/named34.conf.in ns2/named.conf rndc_reload sleep 5 @@ -434,7 +433,7 @@ n=40 # Test 41 - zone default, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named40.conf.in > ns2/named.conf +copy_config ns2/named40.conf.in ns2/named.conf rndc_reload sleep 5 @@ -558,7 +557,7 @@ status=`expr $status + $ret` # Test 53 - zones over options, zones allow, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named53.conf.in > ns2/named.conf +copy_config ns2/named53.conf.in ns2/named.conf rndc_reload sleep 5 @@ -572,7 +571,7 @@ status=`expr $status + $ret` # Test 54 - zones over options, zones disallow, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named54.conf.in > ns2/named.conf +copy_config ns2/named54.conf.in ns2/named.conf rndc_reload sleep 5 @@ -586,7 +585,7 @@ status=`expr $status + $ret` # Test 55 - zones over views, zones allow, query allowed n=`expr $n + 1` -$SEDPORTS < ns2/named55.conf.in > ns2/named.conf +copy_config ns2/named55.conf.in ns2/named.conf rndc_reload sleep 5 @@ -600,7 +599,7 @@ status=`expr $status + $ret` # Test 56 - zones over views, zones disallow, query refused n=`expr $n + 1` -$SEDPORTS < ns2/named56.conf.in > ns2/named.conf +copy_config ns2/named56.conf.in ns2/named.conf rndc_reload sleep 5 @@ -614,7 +613,7 @@ status=`expr $status + $ret` # Test 57 - zones over views, zones disallow, query refused (allow-query-on) n=`expr $n + 1` -$SEDPORTS < ns2/named57.conf.in > ns2/named.conf +copy_config ns2/named57.conf.in ns2/named.conf rndc_reload sleep 5 diff --git a/bin/tests/system/getopts.sh b/bin/tests/system/getopts.sh index af61ae281b6..cdb0922a532 100644 --- a/bin/tests/system/getopts.sh +++ b/bin/tests/system/getopts.sh @@ -21,4 +21,8 @@ done shift $(($OPTIND - 1)) OPTIND=1 -SEDPORTS="sed -e s/@PORT@/${port}/g -e s/@CONTROLPORT@/${controlport}/g" +# Convenience function to copy configuration file, replacing the port numbers +# during the copy - more readable than embedding a "sed" command in the script. +copy_config() { + sed -e "s/@PORT@/${port}/g" -e "s/@CONTROLPORT@/${controlport}/g" < $1 > $2 +} diff --git a/bin/tests/system/serve-stale/setup.sh b/bin/tests/system/serve-stale/setup.sh index 4e9363967de..55263409909 100644 --- a/bin/tests/system/serve-stale/setup.sh +++ b/bin/tests/system/serve-stale/setup.sh @@ -7,11 +7,11 @@ . ../getopts.sh -$SEDPORTS < ns1/named1.conf.in > ns1/named.conf +copy_config ns1/named1.conf.in ns1/named.conf echo "${port}" > ns1/named.port -$SEDPORTS < ans2/ans.pl.in > ans2/ans.pl +copy_config ans2/ans.pl.in ans2/ans.pl echo "${port}" > ans2/named.port -$SEDPORTS < ns3/named.conf.in > ns3/named.conf +copy_config ns3/named.conf.in ns3/named.conf echo "${port}" > ns3/named.port diff --git a/bin/tests/system/serve-stale/tests.sh b/bin/tests/system/serve-stale/tests.sh index 1cd8151193c..c7e2d0f30ce 100755 --- a/bin/tests/system/serve-stale/tests.sh +++ b/bin/tests/system/serve-stale/tests.sh @@ -8,18 +8,7 @@ SYSTEMTESTTOP=.. . $SYSTEMTESTTOP/conf.sh - -. ../getopts.sh - -TESTNAME="$(basename $(pwd))" - -while getopts "p:c:" flag; do - case "$flag" in - p) port=$OPTARG ;; - c) controlport=$OPTARG ;; - *) exit 1 ;; - esac -done +. $SYSTEMTESTTOP/getopts.sh RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${controlport} -s"