]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
[rt46602] More updates to the test running framework
authorStephen Morris <stephen@isc.org>
Fri, 24 Nov 2017 12:50:19 +0000 (12:50 +0000)
committerEvan Hunt <each@isc.org>
Sun, 25 Feb 2018 17:25:09 +0000 (09:25 -0800)
Tidy up the stop/start files and make switch usage consistent. Also
tidy up the various "clean" targets in the Makefile.

(cherry picked from commit b24c2e11d85db48f364f3cca94b3ba8e75eca138)
(cherry picked from commit 78494c3a4df383a235bc5d0b73676bc7b905d49a)
(cherry picked from commit 28c2b0be93a9b3b11d9822e22788361617e93280)

bin/tests/system/Makefile.in
bin/tests/system/run.sh
bin/tests/system/start.pl
bin/tests/system/stop.pl

index cf0c9d2fbab82c5517164a824861b786fddf8f2e..fea2107b0e8469f350f9e3270ec6b2d4cf1b93bb 100644 (file)
@@ -83,13 +83,20 @@ test: parallel.mk
 
 check: test
 
-# Other targets.
+# Other targets:
+#
+# testclean - delete files generated by running tests
+# clean - As for testclean, but also delete files built for the tests by "make"
+# distclean - As for clean, but also delete test-related files generated by
+#        "configure"
 
 testclean clean distclean::
        if test -f ./cleanall.sh; then $(SHELL) ./cleanall.sh; fi
        rm -f systests.output
        rm -f random.data
        rm -f parallel.mk
+
+clean distclean::
        rm -f ${TARGETS}
        rm -f ${OBJS}
 
index f3d62b9f424773adf69342d4cb4de86c57ee85cc..79a84f1bceca2330c0145de1673d29d6c209a018 100644 (file)
@@ -102,7 +102,7 @@ then
 fi
 
 # Start name servers running
-$PERL start.pl -p $port $test || { echofail "R:$test:FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; }
+$PERL start.pl --port $port $test || { echofail "R:$test:FAIL"; echoinfo "E:$test:`date $dateargs`"; exit 1; }
 
 # Run the tests
 ( cd $test ; $SHELL tests.sh -p "$port" -- "$@" )
index c304492dfb058e3bf09e7db9cae5c6bf75f69aeb..a6766c23ede6abf82a043496db2ae21b2de7ed69 100644 (file)
@@ -15,8 +15,6 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id$
-
 # Framework for starting test servers.
 # Based on the type of server specified, check for port availability, remove
 # temporary files, start the server, and verify that the server is running.
@@ -27,39 +25,60 @@ use Cwd;
 use Cwd 'abs_path';
 use Getopt::Long;
 
-# Option handling
-#   --noclean test [server [options]]
+# Usage:
+#   perl start.pl [--noclean] --restart] [--port port]  test [server [options]]
+#
+#   --noclean       Do not cleanup files in server directory.
+#
+#   --restart       Indicate that the server is being restarted, so get the
+#                   server to append output to an existing log file instead of
+#                   starting a new one.
+#
+#   --port port     Specify the default port being used by the server to answer
+#                   queries (default 5300).  This script will interrogate the
+#                   server on this port to see if it is running. (Note: for
+#                   "named" nameservers, this can be overridden by the presence
+#                   of the file "named.port" in the server directory containing
+#                   the number of the query port.)
+#
+#   test            Name of the test directory.
+#
+#   server          Name of the server directory.  This will be of the form
+#                   "nsN" or "ansN", where "N" is an integer between 1 and 8.
+#                   If not given, the script will start all the servers in the
+#                   test directory.
 #
-#   --noclean - Do not cleanup files in server directory
-#   test - name of the test directory
-#   server - name of the server directory
-#   options - alternate options for the server
-#             NOTE: options must be specified with '-- "<option list>"',
-#              for instance: start.pl . ns1 -- "-c n.conf -d 43"
-#             ALSO NOTE: this variable will be filled with the
-#              contents of the first non-commented/non-blank line of args
-#              in a file called "named.args" in an ns*/ subdirectory only
-#              the FIRST non-commented/non-blank line is used (everything
-#              else in the file is ignored. If "options" is already set,
-#              then "named.args" is ignored.
-
-my $usage = "usage: $0 [--noclean] [--restart] test-directory [server-directory [server-options]]";
+#   options         Alternate options for the server,
+#
+#                   NOTE: options must be specified with '-- "<option list>"',
+#                   for instance: start.pl . ns1 -- "-c n.conf -d 43"
+#
+#                   ALSO NOTE: this variable will be filled with the contents
+#                   of the first non-commented/non-blank line of args in a file
+#                   called "named.args" in an ns*/ subdirectory. Only the FIRST
+#                          non-commented/non-blank line is used (everything else in the
+#                          file is ignored. If "options" is already set, then
+#                          "named.args" is ignored.
+
+my $usage = "usage: $0 [--noclean] [--restart] [--port <port>] test-directory [server-directory [server-options]]";
 my $noclean = '';
 my $restart = '';
 my $defaultport = 5300;
-GetOptions('noclean' => \$noclean, 'restart' => \$restart, 'p=i' => \$defaultport);
+
+GetOptions('noclean' => \$noclean, 'restart' => \$restart, 'port=i' => \$defaultport) or die "$usage\n";
+
 my $test = $ARGV[0];
 my $server = $ARGV[1];
 my $options = $ARGV[2];
 
 if (!$test) {
-       print "$usage\n";
+       die "$usage\n";
 }
 if (!-d $test) {
-       print "No test directory: \"$test\"\n";
+       die "No test directory: \"$test\"\n";
 }
 if ($server && !-d "$test/$server") {
-       print "No server directory: \"$test/$server\"\n";
+       die "No server directory: \"$test/$server\"\n";
 }
 
 # Global variables
@@ -229,7 +248,7 @@ sub start_server {
        } elsif ($server =~ /^ans/) {
                $cleanup_files = "{ans.run}";
                 if (-e "$testdir/$server/ans.py") {
-                        $command = "$PYTHON -u ans.py 10.53.0.$' 5300";
+                        $command = "$PYTHON -u ans.py 10.53.0.$' $defaultport";
                 } elsif (-e "$testdir/$server/ans.pl") {
                         $command = "$PERL ans.pl";
                 } else {
@@ -291,7 +310,7 @@ sub start_server {
 sub verify_server {
        my $server = shift;
        my $n = $server;
-       my $port = 5300;
+       my $port = $defaultport;
        my $tcp = "+tcp";
 
        $n =~ s/^ns//;
index e61868f1f18aa5a935d6ba3d4e7dd358cdfc4c66..027c67ac37b0e4ca2f8f264470e51c2ae70710a2 100644 (file)
@@ -15,8 +15,6 @@
 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 # PERFORMANCE OF THIS SOFTWARE.
 
-# $Id: stop.pl,v 1.12 2007/06/19 23:47:00 tbox Exp $
-
 # Framework for stopping test servers
 # Based on the type of server specified, signal the server to stop, wait
 # briefly for it to die, and then kill it if it is still alive.
 
 use strict;
 use Cwd 'abs_path';
+use Getopt::Long;
 
-# Option handling
-#   [--use-rndc] test [server]
+# Usage:
+#   perl stop.pl [[-use-rndc] [--port port] test [server]
 #
-#   test - name of the test directory
-#   server - name of the server directory
-
-my $usage = "usage: $0 [--use-rndc] test-directory [server-directory]";
-my $use_rndc;
+#   --use-rndc      Attempt to stop the server via the "rndc stop" command.
+#
+#   --port port     Only relevant if --use-rndc is specified, this sets the
+#                   command port over which the attempt should be made.  If
+#                   not specified, port 9953 is used.
+#
+#   test            Name of the test directory,
+#
+#   server          Name of the server directory
 
-while (@ARGV && $ARGV[0] =~ /^-/) {
-       my $opt = shift @ARGV;
-       if ($opt eq '--use-rndc') {
-               $use_rndc = 1;
-       } else {
-               die "$usage\n";
-       }
-}
+my $usage = "usage: $0 [--use-rndc] [--port port] test-directory [server-directory]";
 
-my $test = $ARGV[0];
-my $server = $ARGV[1];
+my $use_rndc = 0;
+my $port = 9953;
+GetOptions('use-rndc' => \$use_rndc, 'port=i' => \$port) or die "$usage\n";
 
 my $errors = 0;
 
+my $test = $ARGV[0];
+my $server = $ARGV[1];
 die "$usage\n" unless defined($test);
 die "No test directory: \"$test\"\n" unless (-d $test);
 die "No server directory: \"$server\"\n" if (defined($server) && !-d "$test/$server");
@@ -143,7 +142,7 @@ sub stop_rndc {
        my $ip = "10.53.0.$1";
 
        # Ugly, but should work.
-       system("$ENV{RNDC} -c $testdir/../common/rndc.conf -s $ip -p 9953 stop | sed 's/^/I:$server /'");
+       system("$ENV{RNDC} -c $testdir/../common/rndc.conf -s $ip -p $port stop | sed 's/^/I:$server /'");
        return;
 }