]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[rt46602] Pass port numbers to tests via environment variables
authorStephen Morris <stephen@isc.org>
Thu, 14 Dec 2017 15:02:01 +0000 (15:02 +0000)
committerStephen Morris <stephen@isc.org>
Fri, 16 Feb 2018 15:19:43 +0000 (15:19 +0000)
19 files changed:
bin/tests/system/README
bin/tests/system/allow_query/setup.sh
bin/tests/system/allow_query/tests.sh
bin/tests/system/catz/clean.sh
bin/tests/system/catz/ns1/named.conf.in
bin/tests/system/catz/ns2/named.conf.in
bin/tests/system/catz/setup.sh
bin/tests/system/catz/tests.sh
bin/tests/system/conf.sh.in
bin/tests/system/getopts.sh [deleted file]
bin/tests/system/rpz/setup.sh
bin/tests/system/rpz/tests.sh
bin/tests/system/rpzrecurse/clean.sh
bin/tests/system/rpzrecurse/setup.sh
bin/tests/system/rrl/tests.sh
bin/tests/system/run.sh
bin/tests/system/serve-stale/clean.sh
bin/tests/system/serve-stale/setup.sh
bin/tests/system/serve-stale/tests.sh

index a6604b37bf56bcafe2a430e77b3f0285352e4f40..5d8343fbac91265a3fed9dc9dd9ff84d236e623e 100644 (file)
@@ -67,7 +67,7 @@ Running the Tests
 ===
 The tests can be run individually using the following command:
 
-    sh run.sh [flags] <test-name>
+    sh run.sh [flags] <test-name> [<test-arguments>]
 
 e.g.
 
@@ -75,8 +75,12 @@ e.g.
 
 Optional flags are:
 
-    -p <number>     Sets the range of ports used by the test.  If not
-                    specified, the test will use ports 5300 to 5309.
+    -p <number>     Sets the range of ports used by the test.  A block of 10
+                    ports is available for each test, the number given to the
+                    "-p" switch being the number of the start of that block
+                    (e.g.  "-p 7900" will mean that the test is able to use
+                    ports 7900 through 7909).  If not specified, the test will
+                    use ports 5300 to 5309.
     -n              Noclean - do not remove the output files if the test
                     completes successfully.  By default, files created by the
                     test are deleted if it passes;  they are not deleted if the
@@ -87,17 +91,27 @@ Optional flags are:
                     Python or Perl) that feature test-specific behavior. The
                     servers are automatically started before the test is run
                     and stopped after it ends.  This flag leaves them running
-                    at the end of the test.
+                    at the end of the test, so that additional queries can be
+                    sent by hand.  To stop the servers afterwards, use the
+                    command "sh stop.sh <test-name>".
     -d <arg>        Arguments to the "date" command used to produce the
                     start and end time of the tests.  For example, the
                     switch
 
                         -d "+%Y-%m-%d:%h:%M:%s"
 
-                    would cause the "S" and "E" messages (see below) to have the
-                    date looking like "2017-11-23:16:06:32" instead of the
+                    would cause the "S" and "E" messages (see below) to have
+                    the date looking like "2017-11-23:16:06:32" instead of the
                     default "Thu, 23 Nov 2017 16:06:32 +0000".
 
+Arguments are:
+
+    test-name       Mandatory. The name of the test, which is the name of the
+                    subdirectory in bin/tests/system holding the test files.
+
+    test-arguments  Optional arguments that are passed to each of the test's
+                    scripts.
+
 To run all the system tests, type either:
 
     sh runall.sh [numproc]
@@ -110,7 +124,7 @@ When running all the tests, the output is sent to the file systests.output
 (in the bin/tests/system) directory.
 
 The "numproc" option specifies the maximum number of tests that can run
-simultaneously.  The default is 1, which means that all the test run
+simultaneously.  The default is 1, which means that all of the tests run
 sequentially. If greater than 1, up to "numproc" tests will run simultaneously.
 (Each will use a unique set of ports, so there is no danger of them interfering
 with one another.)
@@ -198,7 +212,7 @@ files produced by the tests should be deleted first.
 Deletion of files produced by an individual test can be done with the
 command:
 
-    (cd testname ; sh clean.sh)
+    sh clean.sh <test-name>
 
 Deletion of the files produced by the set of tests (e.g. after the execution
 of "runall.sh") can be deleted by the command:
@@ -253,29 +267,28 @@ ans<N>      Like ns[X], but these are simple mock name servers implemented in
 Port Usage
 ---
 In order for the tests to run in parallel, each test requires a unique set of
-ports.  These are specified by the "-p" option passed to "run.sh".  This option
-is then passed to each of the test control scripts listed above.
+ports.  These are specified by the "-p" option passed to "run.sh", which sets
+environment variables that the scripts listed above can reference.
 
 The convention used in the system tests is that the number passed is the start
 of a range of 10 ports.  The test is free to use the ports as required,
 although present usage is that the lowest port is used as the query port and
-the highest is used as the control port.  This is reinforced by the script
-getopts.sh: if used to parse the "-p" option (see below), the script sets the
-following shell variables:
+the highest is used as the control port.  This is reinforced by the environment
+variables set by run.sh. These are:
+
+    PORT                     Number to be used for the query port.
+    CONTROLPORT              Number to be used as the RNDC control port.
+    EXTRAPORT1 - EXTRAPORT8  Eight port numbers that can be use as needed.
+
+Two other environment variables are defined:
 
-    port                Number to be used for the query port.
-    controlport         Number to be used as the RNDC control port.
-    aport1 - aport8     Eight port numbers that the test can use as needed.
+    LOWPORT                  The lowest port number in the range.
+    HIGHPORT                 The highest port number in the range.
 
 When running tests in paralel (i.e. giving a value of "numproc" greater than 1
 in the "make" or "runall.sh" commands listed above), it is guaranteed that each
 test will get a set of unique port numbers.
 
-In addition, the "getopts.sh" script also defines the following symbols:
-
-    portlow             Lowest port number in the range.
-    porthigh            Highest port number in the range.
-
 
 Writing a Test
 ---
@@ -285,51 +298,19 @@ nameserver instances) to run.  Certain expectations are put on each script:
 
 General
 ---
-Each of the four scripts will be invoked with the command
+1. Each of the four scripts will be invoked with the command
+
+    sh <script> [<arguments>]
 
-    sh <script> -p <baseport> -- <arguments>
+Thhe optional arguments are test-specific.  They are 
 
 Each script should start with the following lines:
 
     SYSTEMTESTTOP=..
     . $SYSTEMTESTTOP/conf.sh
-    . $SYSTEMTESTTOP/getopts.sh
 
 "conf.sh" defines a series of environment variables together with functions
-useful for the test scripts.  "getopts.sh" parses the "-p" option and sets the
-shell variables listed above. (They are not combined into one script because,
-in certain instances - notably in "run.sh" - some processing is required
-between the setting of the environment variables and the parsing of the port).
-
-The "--" between the "-p <baseport>" and any other arguments is required:
-without it, any other switches passed to the script would be parsed by
-getopts.sh, which would return an error because it would not recognise them.
-getopts.sh removes the "-p <port> --" from the argument list, leaving the
-script free to do its own parsing of any additional arguments.
-
-For example, if "test.sh" is invoked as:
-
-    sh tests.sh -p 12340 -- -D 1
-
-... and it includes the three lines listed above, after the execution of the
-code in getopts.sh, the following variables would be defined (with their
-associated values):
-
-    port        12340
-    aport1      12341
-    aport2      12342
-      :           :
-    aport8      12348
-    controlport 12349
-    portlow     12340
-    porthigh    12349
-
-    $1          -D
-    $2          1
-
-Should a script need to invoke another, it should pass the base port with the
-"-p" switch and add any additional arguments after the "--", i.e.  using the
-same format as listed above in the example for invoking "tests.sh"
+useful for the test scripts.
 
 
 prereq.sh
@@ -338,8 +319,9 @@ As noted above, this is optional.  If present, it should check whether specific
 software needed to run the test is available and/or whether BIND has been
 configured with the appropriate options required.
 
-    * If the software required to run the test is present and the BIND configure
-      options are correct, prereq.sh should return with a status code of 0.
+    * If the software required to run the test is present and the BIND
+      configure options are correct, prereq.sh should return with a status code
+       of 0.
 
     * If the software required to run the test is not available and/or BIND
       has not been configured with the appropriate options, prereq.sh should
@@ -362,10 +344,10 @@ Instead, setup.sh is responsible for editing the configuration files to set the
 port numbers.
 
 To do this, configuration files should be supplied in the form of templates
-containing tokens identifying ports.  The tokens have the same name as the shell
-variables listed above, but in upper-case and prefixed and suffixed by the "@"
-symbol.  For example, a fragment of a configuration file template might look
-like:
+containing tokens identifying ports.  The tokens have the same name as the
+shell variables listed above, but in upper-case and prefixed and suffixed by
+the "@" symbol.  For example, a fragment of a configuration file template might
+look like:
 
     controls {
         inet 10.53.0.1 port @CONTROLPORT@ allow { any; } keys { rndc_key; };
@@ -380,32 +362,19 @@ like:
     };
 
 setup.sh should copy the template to the desired filename using the
-"copy_setports" shell function defined in "getopts.sh", i.e.
+"copy_setports" shell function defined in "conf.sh", i.e.
 
     copy_setports ns1/named.conf.in ns1/named.conf
 
-This replaces the tokens @PORT@, @CONTROLPORT@, @APORT1@ through @APORT8@ with
-the contents of the shell variables listed above.  setup.sh should do this for
-all configuration files required when the test starts.
-
-A second important responsibility of setup.sh is to create a file called
-named.port in each "named" nameserver directory that defines the query port for
-that server, e.g.
-
-    echo $port > ns1/named.port
-
-The file is used by the framework to determine the port it should use to query
-the nameserver.  In most cases, all nameservers will use the same port number
-for queries.  Some tests may require a different port to be used for queries,
-which is why this task has been delegated to test-specific setup rather than be
-part of the framework.
-
+This replaces the tokens @PORT@, @CONTROLPORT@, @EXTRAPORT1@ through
+@EXTRAPORT8@ with the contents of the shell variables listed above.  setup.sh
+should do this for all configuration files required when the test starts.
 
 tests.sh
 ---
-This is the main test file and the contents depend on the test. The contents are
-completely up to the developer, although most test scripts have a form similar
-to the following for each test:
+This is the main test file and the contents depend on the test. The contents
+are completely up to the developer, although most test scripts have a form
+similar to the following for each test:
 
     1. n=`expr $n + 1`
     2. echo_i "prime cache nodata.example ($n)"
index 3e14f3533a0170037bea0fcb3104b8bf06a69000..696c27079ecac6abd3d4450c26c933e6f4e5b1c6 100644 (file)
@@ -8,8 +8,8 @@
 
 # $Id: setup.sh,v 1.2 2010/11/16 01:37:36 sar Exp $
 
-. ../getopts.sh
+SYSTEMTESTTOP=..
+. $SYSTEMTESTTOP/conf.sh
 
 copy_setports ../common/controls.conf.in ns2/controls.conf
 copy_setports  ns2/named01.conf.in ns2/named.conf
-echo "${port}" > ns2/named.port
index 58a4c37369ea6fa95a176398546c58388b572444..994c9cff347c71d15819f2803cada7158dd367fe 100644 (file)
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
-DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p ${port}"
+DIGOPTS="+tcp +nosea +nostat +nocmd +norec +noques +noauth +noadd +nostats +dnssec -p ${PORT}"
 
 rndc_reload() {
-    RNDCOUT=`$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p ${controlport} reload 2>&1`
+    RNDCOUT=`$RNDC -c ../common/rndc.conf -s 10.53.0.2 -p ${CONTROLPORT} reload 2>&1`
     echo_i "ns2 $RNDCOUT"
 }
 
index bae45099bf57f73b1dcffd6711539f2dfb6e9d79..b37f9538679d61539fa24d0fec0424ed5671f814 100644 (file)
@@ -12,7 +12,6 @@ rm -f ns*/named.lock
 rm -f ns*/named.memstats
 rm -f ns*/named.conf
 rm -f ns*/named.run
-rm -f ns*/named.port
 rm -f ns1/*dom*example.db
 rm -f ns2/__catz__*db
 rm -f ns2/named.conf.tmp
index 05678357e2fe37ba1aec0f363b0114589807ea6d..30d357a4c12afee9185fb6abba421febbf1d69cc 100644 (file)
@@ -20,7 +20,7 @@ options {
        allow-new-zones yes;
        pid-file "named.pid";
        listen-on { 10.53.0.1; };
-       listen-on port @APORT1@ { 10.53.0.1; };
+       listen-on port @EXTRAPORT1@ { 10.53.0.1; };
        listen-on-v6 { none; };
        notify no;
        recursion no;
index 5b23350110fbd7cee27219bd51df4d56baa3dfc0..91e44deb1f1431c16bbf56b18cf632f40d26379a 100644 (file)
@@ -29,7 +29,7 @@ options {
                        in-memory no
                        zone-directory "zonedir";
                zone "catalog2.example"
-                       default-masters { 10.53.0.1 port @APORT1@; }
+                       default-masters { 10.53.0.1 port @EXTRAPORT1@; }
                        in-memory yes;
                zone "catalog3.example"
                        default-masters { 10.53.0.1; }
index a8b3d98a5f811f7402694b711ee56025be99f0bb..02fc258c083d0a7d832582cc5dfe25bae34b58f9 100644 (file)
@@ -8,7 +8,6 @@
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
 copy_setports ns1/named.conf.in ns1/named.conf
 copy_setports ns2/named.conf.in ns2/named.conf
@@ -20,7 +19,3 @@ cp -f ns1/catalog.example.db.in ns1/catalog3.example.db
 cp -f ns1/catalog.example.db.in ns1/catalog4.example.db
 
 mkdir -p ns2/zonedir
-
-echo "${port}" > ns1/named.port
-echo "${port}" > ns2/named.port
-echo "${port}" > ns3/named.port
index ed71005da02fd00a4aba63828bcc810855f7e788..58fc507fd3914cafb34c0e7cf307e1c8a50d216e 100644 (file)
@@ -8,9 +8,8 @@
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
-RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p $controlport -s"
+RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p $CONTROLPORT -s"
 
 status=0
 n=0
@@ -19,7 +18,7 @@ echo_i "Testing adding/removing of domain in catalog zone"
 n=`expr $n + 1`
 echo_i "checking that dom1.example is not served by master ($n)"
 ret=0
-$DIG soa dom1.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom1.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -36,7 +35,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom1.example is now served by master ($n)"
 ret=0
-$DIG soa dom1.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom1.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -47,7 +46,7 @@ n=`expr $n + 1`
 echo_i "Adding domain dom1.example to catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add e721433b6160b450260d4f54b3ec8bab30cb3b83.zones.catalog1.example 3600 IN PTR dom1.example.
     send
 END
@@ -73,7 +72,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom1.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom1.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -86,7 +85,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom1.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom1.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom1.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -106,7 +105,7 @@ n=`expr $n + 1`
 echo_i "removing domain dom1.example from catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-   server 10.53.0.1 ${port}
+   server 10.53.0.1 ${PORT}
    update delete e721433b6160b450260d4f54b3ec8bab30cb3b83.zones.catalog1.example
    send
 END
@@ -132,7 +131,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom1.example is not served by slave ($n)"
 ret=0
-$DIG soa dom1.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom1.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -168,7 +167,7 @@ n=`expr $n + 1`
 echo_i "adding domains dom2.example, dom3.example and some garbage to catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 636722929740e507aaf27c502812fc395d30fb17.zones.catalog1.example 3600 IN PTR dom2.example.
     update add b901f492f3ebf6c1e5b597e51766f02f0479eb03.zones.catalog1.example 3600 IN PTR dom3.example.
     update add e721433b6160b450260d4f54b3ec8bab30cb3b83.zones.catalog1.example 3600 IN NS foo.bar.
@@ -190,7 +189,7 @@ n=`expr $n + 1`
 echo_i "adding domain dom4.example to catalog2 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.3 ${port}
+    server 10.53.0.3 ${PORT}
     update add de26b88d855397a03f77ff1162fd055d8b419584.zones.catalog2.example 3600 IN PTR dom4.example.
     send
 END
@@ -217,7 +216,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom4.example/IN' from 10.53.0.1#${aport1}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom4.example/IN' from 10.53.0.1#${EXTRAPORT1}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -230,7 +229,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom4.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom4.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom4.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -243,7 +242,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom3.example is not served by master ($n)"
 ret=0
-$DIG soa dom3.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom3.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -260,7 +259,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom3.example is served by master ($n)"
 ret=0
-$DIG soa dom3.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom3.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -285,8 +284,8 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom2.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null &&
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom3.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom2.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null &&
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom3.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -299,7 +298,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom3.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom3.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom3.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -312,7 +311,7 @@ n=`expr $n + 1`
 echo_i "removing all records from catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete 636722929740e507aaf27c502812fc395d30fb17.zones.catalog1.example 3600 IN PTR dom2.example.
     update delete b901f492f3ebf6c1e5b597e51766f02f0479eb03.zones.catalog1.example 3600 IN PTR dom3.example.
     update delete e721433b6160b450260d4f54b3ec8bab30cb3b83.zones.catalog1.example 3600 IN NS foo.bar.
@@ -334,7 +333,7 @@ n=`expr $n + 1`
 echo_i "removing all records from catalog2 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.3 ${port}
+    server 10.53.0.3 ${PORT}
     update delete de26b88d855397a03f77ff1162fd055d8b419584.zones.catalog2.example 3600 IN PTR dom4.example.
     send
 END
@@ -347,7 +346,7 @@ n=`expr $n + 1`
 echo_i "adding dom5.example with a valid masters suboption (IP without TSIG) and a random label ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add somerandomlabel.zones.catalog1.example 3600 IN PTR dom5.example.
     update add masters.somerandomlabel.zones.catalog1.example 3600 IN A 10.53.0.3
     send
@@ -374,7 +373,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom5.example/IN' from 10.53.0.3#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom5.example/IN' from 10.53.0.3#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -387,7 +386,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom5.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom5.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom5.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -400,7 +399,7 @@ n=`expr $n + 1`
 echo_i "removing dom5.example ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete somerandomlabel.zones.catalog1.example 3600 IN PTR dom5.example.
     update delete masters.somerandomlabel.zones.catalog1.example 3600 IN A 10.53.0.3
     send
@@ -427,7 +426,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom5.example is no longer served by slave ($n)"
 ret=0
-$DIG soa dom5.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom5.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -439,7 +438,7 @@ n=`expr $n + 1`
 echo_i "adding dom6.example and a valid global masters option (IP without TSIG) ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add masters.catalog1.example 3600 IN A 10.53.0.3
     update add masters.catalog1.example 3600 IN AAAA  fd92:7065:b8e:ffff::3
     update add 4346f565b4d63ddb99e5d2497ff22d04e878e8f8.zones.catalog1.example 3600 IN PTR dom6.example.
@@ -482,7 +481,7 @@ echo_i "checking that dom6.example is served by slave ($n)"
 try=0
 while test $try -lt 150
 do
-    $DIG soa dom6.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom6.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -496,7 +495,7 @@ n=`expr $n + 1`
 echo_i "removing dom6.example ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete masters.catalog1.example 3600 IN A 10.53.0.3
     update delete masters.catalog1.example 3600 IN AAAA  fd92:7065:b8e:ffff::3
     update delete 4346f565b4d63ddb99e5d2497ff22d04e878e8f8.zones.catalog1.example 3600 IN PTR dom6.example.
@@ -524,7 +523,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom6.example is no longer served by slave ($n)"
 ret=0
-$DIG soa dom6.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom6.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -628,7 +627,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom7.example is now served by master ($n)"
 ret=0
-$DIG soa dom7.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom7.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -639,7 +638,7 @@ n=`expr $n + 1`
 echo_i "adding domain dom7.example to catalog1 zone with an allow-query statement ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 78833ec3c0059fd4540fee81c7eaddce088e7cd7.zones.catalog1.example 3600 IN PTR dom7.example.
     update add allow-query.78833ec3c0059fd4540fee81c7eaddce088e7cd7.zones.catalog1.example 3600 IN APL 1:10.53.0.1/32 !1:10.53.0.0/30 1:0.0.0.0/0
     send
@@ -666,7 +665,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom7.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom7.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -679,7 +678,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom7.example is accessible from 10.53.0.1 ($n)"
 ret=0
-$DIG soa dom7.example -b 10.53.0.1 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom7.example -b 10.53.0.1 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -687,7 +686,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom7.example is not accessible from 10.53.0.2 ($n)"
 ret=0
-$DIG soa dom7.example -b 10.53.0.2 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom7.example -b 10.53.0.2 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -695,7 +694,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom7.example is accessible from 10.53.0.5 ($n)"
 ret=0
-$DIG soa dom7.example -b 10.53.0.5 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom7.example -b 10.53.0.5 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -705,7 +704,7 @@ n=`expr $n + 1`
 echo_i "adding dom8.example domain and global allow-query and allow-transfer ACLs ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add cba95222e308baba42417be6021026fdf20827b6.zones.catalog1.example 3600 IN PTR dom8.example
     update add allow-query.catalog1.example 3600 IN APL 1:10.53.0.1/32
     update add allow-transfer.catalog1.example 3600 IN APL 1:10.53.0.2/32
@@ -733,7 +732,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is accessible from 10.53.0.1 ($n)"
 ret=0
-$DIG soa dom8.example -b 10.53.0.1 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom8.example -b 10.53.0.1 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -741,7 +740,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is not accessible from 10.53.0.2 ($n)"
 ret=0
-$DIG soa dom8.example -b 10.53.0.2 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom8.example -b 10.53.0.2 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -749,7 +748,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is not AXFR accessible from 10.53.0.1 ($n)"
 ret=0
-$DIG axfr dom8.example -b 10.53.0.1 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG axfr dom8.example -b 10.53.0.1 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "Transfer failed." dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -757,7 +756,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is AXFR accessible from 10.53.0.2 ($n)"
 ret=0
-$DIG axfr dom8.example -b 10.53.0.2 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG axfr dom8.example -b 10.53.0.2 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep -v "Transfer failed." dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -767,7 +766,7 @@ n=`expr $n + 1`
 echo_i "deleting global allow-query and allow-domain ACLs ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete allow-query.catalog1.example 3600 IN APL 1:10.53.0.1/32
     update delete allow-transfer.catalog1.example 3600 IN APL 1:10.53.0.2/32
     send
@@ -791,7 +790,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is accessible from 10.53.0.1 ($n)"
 ret=0
-$DIG soa dom8.example -b 10.53.0.1 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom8.example -b 10.53.0.1 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -799,7 +798,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is accessible from 10.53.0.2 ($n)"
 ret=0
-$DIG soa dom8.example -b 10.53.0.2 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom8.example -b 10.53.0.2 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -807,7 +806,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is AXFR accessible from 10.53.0.1 ($n)"
 ret=0
-$DIG axfr dom8.example -b 10.53.0.1 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG axfr dom8.example -b 10.53.0.1 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep -v "Transfer failed." dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -815,7 +814,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom8.example is AXFR accessible from 10.53.0.2 ($n)"
 ret=0
-$DIG axfr dom8.example -b 10.53.0.2 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG axfr dom8.example -b 10.53.0.2 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep -v "Transfer failed." dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -835,7 +834,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom9.example is now served by master ($n)"
 ret=0
-$DIG soa dom9.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom9.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -846,7 +845,7 @@ n=`expr $n + 1`
 echo_i "adding domain dom9.example to catalog1 zone with a valid masters suboption (IP with TSIG) ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add f0f989bc71c5c8ca3a1eb9c9ab5246521907e3af.zones.catalog1.example 3600 IN PTR dom9.example.
     update add label1.masters.f0f989bc71c5c8ca3a1eb9c9ab5246521907e3af.zones.catalog1.example 3600 IN A 10.53.0.1
     update add label1.masters.f0f989bc71c5c8ca3a1eb9c9ab5246521907e3af.zones.catalog1.example 3600 IN TXT "tsig_key"
@@ -874,7 +873,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom9.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom9.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -887,7 +886,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom9.example is accessible on slave ($n)"
 ret=0
-$DIG soa dom9.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom9.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -896,7 +895,7 @@ n=`expr $n + 1`
 echo_i "deleting domain dom9.example from catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete f0f989bc71c5c8ca3a1eb9c9ab5246521907e3af.zones.catalog1.example 3600 IN PTR dom9.example.
     update delete label1.masters.f0f989bc71c5c8ca3a1eb9c9ab5246521907e3af.zones.catalog1.example 3600 IN A 10.53.0.1
     update delete label1.masters.f0f989bc71c5c8ca3a1eb9c9ab5246521907e3af.zones.catalog1.example 3600 IN TXT "tsig_key"
@@ -924,7 +923,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom9.example is no longer accessible on slave ($n)"
 ret=0
-$DIG soa dom9.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom9.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1006,7 +1005,7 @@ echo_i "Testing very long domain in catalog"
 n=`expr $n + 1`
 echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example is not served by master ($n)"
 ret=0
-$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1023,7 +1022,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example is now served by master ($n)"
 ret=0
-$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1034,7 +1033,7 @@ n=`expr $n + 1`
 echo_i "Adding domain this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example to catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 825f48b1ce1b4cf5a041d20255a0c8e98d114858.zones.catalog1.example 3600 IN PTR this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example.
     send
 END
@@ -1060,7 +1059,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -1073,7 +1072,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example is served by slave ($n)"
 ret=0
-$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1089,7 +1088,7 @@ n=`expr $n + 1`
 echo_i "removing domain this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example from catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-   server 10.53.0.1 ${port}
+   server 10.53.0.1 ${PORT}
    update delete 825f48b1ce1b4cf5a041d20255a0c8e98d114858.zones.catalog1.example
    send
 END
@@ -1115,7 +1114,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example is not served by slave ($n)"
 ret=0
-$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa this.is.a.very.very.long.long.long.domain.that.will.cause.catalog.zones.to.generate.hash.instead.of.using.regular.filename.dom10.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1132,7 +1131,7 @@ echo_i "Testing adding a domain and a subdomain of it"
 n=`expr $n + 1`
 echo_i "checking that dom11.example is not served by master ($n)"
 ret=0
-$DIG soa dom11.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom11.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1149,7 +1148,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom11.example is now served by master ($n)"
 ret=0
-$DIG soa dom11.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom11.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1160,7 +1159,7 @@ n=`expr $n + 1`
 echo_i "Adding domain dom11.example to catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 0580d70e769c86c8b951a488d8b776627f427d7a.zones.catalog1.example 3600 IN PTR dom11.example.
     send
 END
@@ -1186,7 +1185,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom11.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom11.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -1199,7 +1198,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom11.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom11.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom11.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -1211,7 +1210,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that subdomain.of.dom11.example is not served by master ($n)"
 ret=0
-$DIG soa subdomain.of.dom11.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa subdomain.of.dom11.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1228,7 +1227,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that subdomain.of.dom11.example is now served by master ($n)"
 ret=0
-$DIG soa subdomain.of.dom11.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa subdomain.of.dom11.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1239,7 +1238,7 @@ n=`expr $n + 1`
 echo_i "Adding domain subdomain.of.dom11.example to catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 25557e0bdd10cb3710199bb421b776df160f241e.zones.catalog1.example 3600 IN PTR subdomain.of.dom11.example.
     send
 END
@@ -1265,7 +1264,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'subdomain.of.dom11.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'subdomain.of.dom11.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -1278,7 +1277,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that subdomain.of.dom11.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa subdomain.of.dom11.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa subdomain.of.dom11.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -1293,7 +1292,7 @@ n=`expr $n + 1`
 echo_i "removing domain dom11.example from catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-   server 10.53.0.1 ${port}
+   server 10.53.0.1 ${PORT}
    update delete 0580d70e769c86c8b951a488d8b776627f427d7a.zones.catalog1.example
    send
 END
@@ -1319,7 +1318,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom11.example is not served by slave ($n)"
 ret=0
-$DIG soa dom11.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom11.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1327,7 +1326,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that subdomain.of.dom11.example is still served by slave ($n)"
 ret=0
-$DIG soa subdomain.of.dom11.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa subdomain.of.dom11.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1336,7 +1335,7 @@ n=`expr $n + 1`
 echo_i "removing domain subdomain.of.dom11.example from catalog1 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-   server 10.53.0.1 ${port}
+   server 10.53.0.1 ${PORT}
    update delete 25557e0bdd10cb3710199bb421b776df160f241e.zones.catalog1.example
    send
 END
@@ -1362,7 +1361,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that subdomain.of.dom11.example is not served by slave ($n)"
 ret=0
-$DIG soa subdomain.of.dom11.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa subdomain.of.dom11.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1373,7 +1372,7 @@ echo_i "Testing adding a catalog zone at runtime with rndc reconfig"
 n=`expr $n + 1`
 echo_i "checking that dom12.example is not served by master ($n)"
 ret=0
-$DIG soa dom12.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom12.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1390,7 +1389,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom12.example is now served by master ($n)"
 ret=0
-$DIG soa dom12.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom12.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1401,7 +1400,7 @@ n=`expr $n + 1`
 echo_i "Adding domain dom12.example to catalog4 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 871d51e5433543c0f6fb263c40f359fbc152c8ae.zones.catalog4.example 3600 IN PTR dom12.example.
     send
 END
@@ -1411,7 +1410,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom12.example is not served by slave ($n)"
 ret=0
-$DIG soa dom12.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom12.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1445,7 +1444,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom12.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom12.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -1458,7 +1457,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom7.example is still served by slave after reconfiguration ($n)"
 ret=0
-$DIG soa dom7.example -b 10.53.0.1 @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom7.example -b 10.53.0.1 @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1466,7 +1465,7 @@ n=`expr $n + 1`
 
 echo_i "checking that dom12.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom12.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom12.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -1495,7 +1494,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom12.example is not served by slave ($n)"
 ret=0
-$DIG soa dom12.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG soa dom12.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1504,7 +1503,7 @@ n=`expr $n + 1`
 echo_i "removing domain dom12.example from catalog4 zone ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete 871d51e5433543c0f6fb263c40f359fbc152c8ae.zones.catalog4.example 3600 IN PTR dom12.example.
     send
 END
@@ -1516,7 +1515,7 @@ echo_i "Testing having a zone in two different catalogs"
 n=`expr $n + 1`
 echo_i "checking that dom13.example is not served by master ($n)"
 ret=0
-$DIG soa dom13.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom13.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1534,7 +1533,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom13.example is now served by master ns1 ($n)"
 ret=0
-$DIG soa dom13.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom13.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1552,7 +1551,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom13.example is now served by master ns3 ($n)"
 ret=0
-$DIG soa dom13.example @10.53.0.3 -p ${port} > dig.out.test$n
+$DIG soa dom13.example @10.53.0.3 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1564,7 +1563,7 @@ n=`expr $n + 1`
 echo_i "Adding domain dom13.example to catalog1 zone with ns1 as master ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add 8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog1.example 3600 IN PTR dom13.example.
     update add masters.8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog1.example 3600 IN A 10.53.0.1
     send
@@ -1591,7 +1590,7 @@ if [ $ret = 0 ]; then
        while test $try -lt 45
        do
            sleep 1
-           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom13.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+           sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom13.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
                ret=0
                break
            }
@@ -1606,7 +1605,7 @@ cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns2/named.run`
 n=`expr $n + 1`
 echo_i "checking that dom13.example is served by slave and that it's the one from ns1 ($n)"
 ret=0
-$DIG a dom13.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom13.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "192.0.2.1" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1616,7 +1615,7 @@ n=`expr $n + 1`
 echo_i "Adding domain dom13.example to catalog2 zone with ns3 as master ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.3 ${port}
+    server 10.53.0.3 ${PORT}
     update add 8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog2.example 3600 IN PTR dom13.example.
     update add masters.8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog2.example 3600 IN A 10.53.0.3
     send
@@ -1643,7 +1642,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom13.example is served by slave and that it's still the one from ns1 ($n)"
 ret=0
-$DIG a dom13.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom13.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "192.0.2.1" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1655,7 +1654,7 @@ n=`expr $n + 1`
 echo_i "Deleting domain dom13.example from catalog2 ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.3 ${port}
+    server 10.53.0.3 ${PORT}
     update delete 8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog2.example 3600 IN PTR dom13.example.
     update delete masters.8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog2.example 3600 IN A 10.53.0.3
     send
@@ -1682,7 +1681,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom13.example is served by slave and that it's still the one from ns1 ($n)"
 ret=0
-$DIG a dom13.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom13.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "192.0.2.1" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1692,7 +1691,7 @@ n=`expr $n + 1`
 echo_i "Deleting domain dom13.example from catalog1 ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete 8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog1.example 3600 IN PTR dom13.example.
     update delete masters.8d7989c746b3f92b3bba2479e72afd977198363f.zones.catalog1.example 3600 IN A 10.53.0.2
     send
@@ -1719,7 +1718,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom13.example is no longer served by slave ($n)"
 ret=0
-$DIG a dom13.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom13.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1729,7 +1728,7 @@ echo_i "Testing having a regular zone and a zone in catalog zone of the same nam
 n=`expr $n + 1`
 echo_i "checking that dom14.example is not served by master ($n)"
 ret=0
-$DIG soa dom14.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom14.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1747,7 +1746,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom14.example is now served by master ns1 ($n)"
 ret=0
-$DIG soa dom14.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom14.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1765,7 +1764,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom14.example is now served by master ns3 ($n)"
 ret=0
-$DIG soa dom14.example @10.53.0.3 -p ${port} > dig.out.test$n
+$DIG soa dom14.example @10.53.0.3 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1786,7 +1785,7 @@ try=0
 while test $try -lt 45
 do
     sleep 1
-    sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom14.example/IN' from 10.53.0.1#${port}: Transfer status: success" > /dev/null && {
+    sed -n "$cur,"'$p' < ns2/named.run | grep "transfer of 'dom14.example/IN' from 10.53.0.1#${PORT}: Transfer status: success" > /dev/null && {
        ret=0
        break
     }
@@ -1800,7 +1799,7 @@ cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns2/named.run`
 n=`expr $n + 1`
 echo_i "checking that dom14.example is served by slave and that it's the one from ns1 ($n)"
 ret=0
-$DIG a dom14.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom14.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "192.0.2.1" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1810,7 +1809,7 @@ n=`expr $n + 1`
 echo_i "Adding domain dom14.example to catalog2 zone with ns3 as master ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.3 ${port}
+    server 10.53.0.3 ${PORT}
     update add 45e3d45ea5f7bd01c395ccbde6ae2e750a3ee8ab.zones.catalog2.example 3600 IN PTR dom14.example.
     update add masters.45e3d45ea5f7bd01c395ccbde6ae2e750a3ee8ab.zones.catalog2.example 3600 IN A 10.53.0.3
     send
@@ -1837,7 +1836,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom14.example is served by slave and that it's still the one from ns1 ($n)"
 ret=0
-$DIG a dom14.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom14.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "192.0.2.1" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1849,7 +1848,7 @@ n=`expr $n + 1`
 echo_i "Deleting domain dom14.example from catalog2 ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.3 ${port}
+    server 10.53.0.3 ${PORT}
     update delete 45e3d45ea5f7bd01c395ccbde6ae2e750a3ee8ab.zones.catalog2.example 3600 IN PTR dom14.example.
     update delete masters.45e3d45ea5f7bd01c395ccbde6ae2e750a3ee8ab.zones.catalog2.example 3600 IN A 10.53.0.3
     send
@@ -1876,7 +1875,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom14.example is served by slave and that it's still the one from ns1 ($n)"
 ret=0
-$DIG a dom14.example @10.53.0.2 -p ${port} > dig.out.test$n
+$DIG a dom14.example @10.53.0.2 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "192.0.2.1" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -1887,7 +1886,7 @@ echo_i "Testing changing label for a member zone"
 n=`expr $n + 1`
 echo_i "checking that dom15.example is not served by master ($n)"
 ret=0
-$DIG soa dom15.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom15.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: REFUSED" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1904,7 +1903,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom15.example is now served by master ns1 ($n)"
 ret=0
-$DIG soa dom15.example @10.53.0.1 -p ${port} > dig.out.test$n
+$DIG soa dom15.example @10.53.0.1 -p ${PORT} > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -1914,7 +1913,7 @@ cur=`awk 'BEGIN {l=0} /^/ {l++} END { print l }' ns2/named.run`
 echo_i "Adding domain dom15.example to catalog1 zone with 'dom15label1' label ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update add dom15label1.zones.catalog1.example 3600 IN PTR dom15.example.
     send
 END
@@ -1942,7 +1941,7 @@ sleep 3
 n=`expr $n + 1`
 echo_i "checking that dom15.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom15.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom15.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
@@ -1957,7 +1956,7 @@ n=`expr $n + 1`
 echo_i "Changing label of domain dom15.example from 'dom15label1' to 'dom15label2' ($n)"
 ret=0
 $NSUPDATE -d <<END >> nsupdate.out.test$n 2>&1 || ret=1
-    server 10.53.0.1 ${port}
+    server 10.53.0.1 ${PORT}
     update delete dom15label1.zones.catalog1.example 3600 IN PTR dom15.example.
     update add dom15label2.zones.catalog1.example 3600 IN PTR dom15.example.
     send
@@ -1984,7 +1983,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "checking that dom15.example is served by slave ($n)"
 for try in 0 1 2 3 4 5 6 7 8 9; do
-    $DIG soa dom15.example @10.53.0.2 -p ${port} > dig.out.test$n
+    $DIG soa dom15.example @10.53.0.2 -p ${PORT} > dig.out.test$n
     ret=0
     grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
     [ $ret -eq 0 ] && break
index 8646d6cff021417a43222d8eb9d557d43a71b5f1..d66a89f61d59801eee2b9e4f0bb796aa689a530d 100644 (file)
@@ -225,6 +225,29 @@ nextpart () {
          END          { print NR > "/dev/stderr" }' $1 2> $1.prev
 }
 
+# copy_setports - Copy Configuration File and Replace Ports
+#
+# Convenience function to copy a configuration file, replacing the symbols
+# QUERYPORT, CONTROLPORT and EXTRAPORT[1-8] with the values of the equivalent
+# environment variables. (These values are set by "run.sh", which calls the
+# scripts invoking this function.)
+#
+# Usage:
+#   copy_setports infile outfile
+
+copy_setports() {
+    sed -e "s/@PORT@/${PORT}/g" \
+        -e "s/@EXTRAPORT1@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT2@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT3@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT4@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT5@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT6@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT7@/${EXTRAPORT1}/g" \
+        -e "s/@EXTRAPORT8@/${EXTRAPORT1}/g" \
+        -e "s/@CONTROLPORT@/${CONTROLPORT}/g" $1 > $2
+}
+
 #
 # Export command paths
 #
diff --git a/bin/tests/system/getopts.sh b/bin/tests/system/getopts.sh
deleted file mode 100644 (file)
index e2e8455..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-#!/bin/sh
-# Copyright (C) 2017  Internet Systems Consortium, Inc. ("ISC")
-#
-# This Source Code Form is subject to the terms of the Mozilla Public
-# License, v. 2.0. If a copy of the MPL was not distributed with this
-# file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
-# Shell script snippet, must be sourced.
-#
-# Most system tests require use of at least two ports: the nameserver query
-# port and a port for RNDC access.  In addition, some tests require additional
-# ports (e.g. for tests of transfers between nameservers).
-#
-# To allow tests to run in parallel, each test must be allocated a unique set
-# ports to use.
-#
-# This script is used during testing to parse the "-p" option on the command
-# line invoking scripts used during the test.  The option sets the base of
-# a block of 10 ports used by the test.  A shell symbol is set for each port:
-#
-# port         Port used for queries (default to 5300)
-# aport1       First additional port (set to $port + 1)
-#   :
-# aport8       Eighth additional port (set to $port + 8)
-# controlport  Port used for RNDC (set to $port + 9)
-#
-# The fiule also defines a simple shell function to 
-
-port=5300
-
-while getopts ":p:" flag; do
-    case "$flag" in
-       p) port=$OPTARG ;;
-       -) break ;;
-       *) exit 1 ;;
-    esac
-done
-shift $(($OPTIND - 1))
-OPTIND=1
-
-# Ensure port is numeric, above 1024 (limit of privileged port) and that
-# the upper of the 10 ports notionally assigned does not exceed 65535.
-
-if [ "$((${port}+0))" != "${port}" ] || [ "${port}" -le 1024 ] || [ "${port}" -gt 65520 ]; then
-    echo "Base of port range ($port) must be numeric and in the range 1025 to 65520" >&2
-    exit 1
-fi
-
-aport1=$(($port + 1))
-aport2=$(($port + 2))
-aport3=$(($port + 3))
-aport4=$(($port + 4))
-aport5=$(($port + 5))
-aport6=$(($port + 6))
-aport7=$(($port + 7))
-aport8=$(($port + 8))
-controlport=$(($port + 9))
-
-# Two more symbols that denote the limits of the range.
-
-portlow=$port
-porthigh=$controlport
-
-
-# copy_setports - Copy Configuration File and Replace Ports
-#
-# Convenience function to copy a configuration file, replacing the symbols
-# PORT, CONTROLPORT and APORT[1-8] with the port numbers set by the "-p"
-# option passed to the script.
-#
-# Usage:
-#   copy_setports infile outfile
-
-copy_setports() {
-    sed -e "s/@PORT@/${port}/g" \
-        -e "s/@APORT1@/${aport1}/g" \
-        -e "s/@APORT2@/${aport1}/g" \
-        -e "s/@APORT3@/${aport1}/g" \
-        -e "s/@APORT4@/${aport1}/g" \
-        -e "s/@APORT5@/${aport1}/g" \
-        -e "s/@APORT6@/${aport1}/g" \
-        -e "s/@APORT7@/${aport1}/g" \
-        -e "s/@APORT8@/${aport1}/g" \
-        -e "s/@CONTROLPORT@/${controlport}/g" < $1 > $2
-}
index f079d6502edd4e1618e74ed24fcf89f8152245df..2cadd168a1410c336d96b116ef6ccad70aee7735 100644 (file)
@@ -12,7 +12,6 @@ set -e
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
 QPERF=`$SHELL qperf.sh`
 
index 2fcff21ada71de05ca7aaec4237bde6e0fc6d62b..38e5a6a55b7a7fd328b16977eb4d368e0a484b90 100644 (file)
@@ -13,7 +13,6 @@
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
 ns=10.53.0
 ns1=$ns.1              # root, defining the others
@@ -67,7 +66,7 @@ if [ -z "$DNSRPS_TEST_MODE" ]; then
         echo "I:'dnsrps-only' found: skipping native RPZ sub-test"
     else
         echo "I:running native RPZ sub-test"
-       $SHELL ./$0 -p $port -- -D1 $ARGS || status=1
+       $SHELL ./$0 -D1 $ARGS || status=1
     fi
 
     if [ -e dnsrps-off ]; then
index d339d67e30bbdb0bc2674c2de6b35d50a1191564..cc655d0f56f015299112e08808d805498a4ab303 100644 (file)
@@ -12,7 +12,6 @@ rm -f dig.out.*
 rm -f ns*/named.lock
 rm -f ns*/named.memstats
 rm -f ns*/*.run
-rm -f ns*/named.port
 rm -f ns*/*core *core
 rm -f ns*/named.conf
 
index a1c890d5ff3247c05d4966218f5e778172b85f92..a789675eeba970845ba2f91f7fa6dbbe1701185e 100644 (file)
@@ -12,7 +12,6 @@ set -e
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
 USAGE="$0: [-xD]"
 DEBUG=
@@ -36,18 +35,13 @@ OPTIND=1
 $PERL testgen.pl
 
 copy_setports ns1/named.conf.in ns1/named.conf
-echo "${port}" > ns1/named.port
 
 copy_setports ns2/named.conf.header.in ns2/named.conf.header
-echo "${port}" > ns2/named.port
-
 copy_setports ns2/named.default.conf ns2/named.conf
 
 copy_setports ns3/named1.conf.in ns3/named.conf
-echo "${port}" > ns3/named.port
 
 copy_setports ns4/named.conf.in ns4/named.conf
-echo "${port}" > ns4/named.port
 
 copy_setports ans5/ans.pl.in ans5/ans.pl
 
index ccee60cbb41ef785dec6a84849f4ed83307affaa..4906e1d79e79ff10abc9cccd74b0f769506d5065 100644 (file)
@@ -9,7 +9,6 @@
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
 #set -x
 
index 7b1e0af2af608947b2fe953e3b1642f691b5120e..ee720a7d5bc8eb60ccf8fadbe81dfb36d1cad06e 100644 (file)
@@ -37,13 +37,49 @@ shift
 
 test -d $test || { echofail "$0: $test: no such test" >&2; exit 1; }
 
-# Validate the port number and obtain other port numbers.
-. $SYSTEMTESTTOP/getopts.sh -p "$baseport"
+# Define the number of ports allocated for this test, and the lowest and
+# highest valid values for the "-p" option.  The lowest valid value is one more
+# than the highest privileged port (1024).  As the number specifies the lowest
+# port number in a block of ports, the highest valid value is such that the
+# highest port number in that block is 65535.
+#
+# N.B.  It is assumed that the number of ports is >= 10.
+numport=10
+minvalid=`expr 1024 + 1`
+maxvalid=`expr 65535 - $numport + 1`
+
+test "$baseport" -eq "$baseport" > /dev/null 2>&1
+if [ $? -ne 0 ]; then
+    echofail "Must specify a numeric value for the port"
+    exit 1
+elif [ $baseport -lt $minvalid -o $baseport -gt $maxvalid  ]; then
+    echofail "The port must be in the range $minvalid to $maxvalid" >&2
+    exit 1
+fi
+
+# Name the first 10 ports in the set: the query port, the control port and
+# eight extra ports.  Since the lowest numbered port (specified in the command
+# line) will usually be a multiple of 10, the names are chosen so that the
+# number of EXTRAPORTn is "n".
+export PORT=$baseport
+export EXTRAPORT1=`expr $baseport + 1`
+export EXTRAPORT2=`expr $baseport + 2`
+export EXTRAPORT3=`expr $baseport + 3`
+export EXTRAPORT4=`expr $baseport + 4`
+export EXTRAPORT5=`expr $baseport + 5`
+export EXTRAPORT6=`expr $baseport + 6`
+export EXTRAPORT7=`expr $baseport + 7`
+export EXTRAPORT8=`expr $baseport + 8`
+export CONTROLPORT=`expr $baseport + 9`
+
+export LOWPORT=$baseport
+export HIGHPORT=`expr $baseport + $numport - 1`
+
 
 echoinfo "S:$test:`date $dateargs`" >&2
 echoinfo "T:$test:1:A" >&2
 echoinfo "A:$test:System test $test" >&2
-echoinfo "I:$test:PORTRANGE:${portlow} - ${porthigh}"
+echoinfo "I:$test:PORTRANGE:${LOWPORT} - ${HIGHPORT}"
 
 if [ x${PERL:+set} = x ]
 then
@@ -54,7 +90,7 @@ then
 fi
 
 # Check for test-specific prerequisites.
-test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh -p "$port" -- "$@" )
+test ! -f $test/prereq.sh || ( cd $test && $SHELL prereq.sh "$@" )
 result=$?
 
 if [ $result -eq 0 ]; then
@@ -67,7 +103,7 @@ else
 fi
 
 # Test sockets after the prerequisites has been setup
-$PERL testsock.pl -p "${port}" || {
+$PERL testsock.pl -p $PORT  || {
     echowarn "I:$test:Network interface aliases not set up.  Skipping test." >&2;
     echowarn "R:$test:UNTESTED" >&2;
     echoinfo "E:$test:`date $dateargs`" >&2;
@@ -89,14 +125,14 @@ fi
 # Set up any dynamically generated test data
 if test -f $test/setup.sh
 then
-   ( cd $test && $SHELL setup.sh -p "$port" -- "$@" )
+   ( cd $test && $SHELL setup.sh "$@" )
 fi
 
 # Start name servers running
-$PERL start.pl --port $port $test || { echofail "R:$test:FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; }
+$PERL start.pl --port $PORT $test || { echofail "R:$test:FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; }
 
 # Run the tests
-( cd $test ; $SHELL tests.sh -p "$port" -- "$@" )
+( cd $test ; $SHELL tests.sh "$@" )
 status=$?
 
 if $stopservers
@@ -122,7 +158,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 "$@" )
         fi
         if test -d ../../../.git
         then
index e2efb77bf2576282d2431bbac0b9eec57d98636e..8ac658eeb85837e0c4e22e67b7f710809fb4a781 100644 (file)
@@ -6,8 +6,8 @@
 
 rm -f test.output
 rm -f dig.out.test*
-rm -f ns1/named.conf ns1/named.port
-rm -f ans2/ans.pl ans2/named.port
-rm -f ns3/named.conf ns3/named.port
+rm -f ns1/named.conf
+rm -f ans2/ans.pl
+rm -f ns3/named.conf
 rm -f ns3/root.bk
 rm -f rndc.out.test*
index 1e05053348e347aaa029fadf2864102b377b6429..690f43c813a261aa0832bf785c006634177728ed 100644 (file)
@@ -5,13 +5,9 @@
 # License, v. 2.0. If a copy of the MPL was not distributed with this
 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
 
-. ../getopts.sh
+SYSTEMTESTTOP=..
+. $SYSTEMTESTTOP/conf.sh
 
 copy_setports ns1/named1.conf.in ns1/named.conf
-echo "${port}" > ns1/named.port
-
 copy_setports ans2/ans.pl.in ans2/ans.pl
-echo "${port}" > ans2/named.port
-
 copy_setports ns3/named.conf.in ns3/named.conf
-echo "${port}" > ns3/named.port
index 7985433326ba2648ac000bec6729b224cca0bf91..a29a2d208fedf7fb7cf7f31bf8ff356fbf2aca7d 100755 (executable)
@@ -8,31 +8,30 @@
 
 SYSTEMTESTTOP=..
 . $SYSTEMTESTTOP/conf.sh
-. $SYSTEMTESTTOP/getopts.sh
 
-RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${controlport} -s"
+RNDCCMD="$RNDC -c $SYSTEMTESTTOP/common/rndc.conf -p ${CONTROLPORT} -s"
 
 status=0
 n=0
 
 #echo_i "check ans.pl server ($n)"
-#$DIG -p ${port} @10.53.0.2 example NS
-#$DIG -p ${port} @10.53.0.2 example SOA
-#$DIG -p ${port} @10.53.0.2 ns.example A
-#$DIG -p ${port} @10.53.0.2 ns.example AAAA
-#$DIG -p ${port} @10.53.0.2 txt enable
-#$DIG -p ${port} @10.53.0.2 txt disable
-#$DIG -p ${port} @10.53.0.2 ns.example AAAA
-#$DIG -p ${port} @10.53.0.2 txt enable
-#$DIG -p ${port} @10.53.0.2 ns.example AAAA
-##$DIG -p ${port} @10.53.0.2 data.example TXT
-#$DIG -p ${port} @10.53.0.2 nodata.example TXT
-#$DIG -p ${port} @10.53.0.2 nxdomain.example TXT
+#$DIG -p ${PORT} @10.53.0.2 example NS
+#$DIG -p ${PORT} @10.53.0.2 example SOA
+#$DIG -p ${PORT} @10.53.0.2 ns.example A
+#$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
+#$DIG -p ${PORT} @10.53.0.2 txt enable
+#$DIG -p ${PORT} @10.53.0.2 txt disable
+#$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
+#$DIG -p ${PORT} @10.53.0.2 txt enable
+#$DIG -p ${PORT} @10.53.0.2 ns.example AAAA
+##$DIG -p ${PORT} @10.53.0.2 data.example TXT
+#$DIG -p ${PORT} @10.53.0.2 nodata.example TXT
+#$DIG -p ${PORT} @10.53.0.2 nxdomain.example TXT
 
 n=`expr $n + 1`
 echo_i "prime cache data.example ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -41,7 +40,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "prime cache nodata.example ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -50,7 +49,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "prime cache nxdomain.example ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -59,7 +58,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "disable responses from authoritative server ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.2 txt disable  > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.2 txt disable  > dig.out.test$n
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -78,7 +77,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale data.example ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -87,7 +86,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nodata.example ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -96,7 +95,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nxdomain.example ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -120,7 +119,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale data.example (serve-stale off) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -130,7 +129,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nodata.example (serve-stale off) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -138,7 +137,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nxdomain.example (serve-stale off) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -161,7 +160,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale data.example (serve-stale on) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -170,7 +169,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nodata.example (serve-stale on) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -179,7 +178,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nxdomain.example (serve-stale on) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -203,7 +202,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale data.example (serve-stale no) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -213,7 +212,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nodata.example (serve-stale no) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -221,7 +220,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nxdomain.example (serve-stale no) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
 status=`expr $status + $ret`
@@ -244,7 +243,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale data.example (serve-stale yes) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -253,7 +252,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nodata.example (serve-stale yes) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -262,7 +261,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nxdomain.example (serve-stale yes) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -293,7 +292,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale data.example (serve-stale reset) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -302,7 +301,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nodata.example (serve-stale reset) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -311,7 +310,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check stale nxdomain.example (serve-stale reset) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.1 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -374,7 +373,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "enable responses from authoritative server ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.2 txt enable  > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.2 txt enable  > dig.out.test$n
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 grep "TXT.\"1\"" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -383,7 +382,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "prime cache data.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -392,7 +391,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "prime cache nodata.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -401,7 +400,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "prime cache nxdomain.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -410,7 +409,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "disable responses from authoritative server ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.2 txt disable  > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.2 txt disable  > dig.out.test$n
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 grep "TXT.\"0\"" dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -429,7 +428,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check fail of data.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -438,7 +437,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check fail of nodata.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -447,7 +446,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check fail of nxdomain.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
 grep "status: SERVFAIL" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -471,7 +470,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check data.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 data.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 data.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 1," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -480,7 +479,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check nodata.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 nodata.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 nodata.example TXT > dig.out.test$n
 grep "status: NOERROR" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi
@@ -489,7 +488,7 @@ status=`expr $status + $ret`
 n=`expr $n + 1`
 echo_i "check nxdomain.example (max-stale-ttl default) ($n)"
 ret=0
-$DIG -p ${port} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
+$DIG -p ${PORT} @10.53.0.3 nxdomain.example TXT > dig.out.test$n
 grep "status: NXDOMAIN" dig.out.test$n > /dev/null || ret=1
 grep "ANSWER: 0," dig.out.test$n > /dev/null || ret=1
 if [ $ret != 0 ]; then echo_i "failed"; fi