]> 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)
committerStephen Morris <stephen@isc.org>
Fri, 16 Feb 2018 14:57:52 +0000 (14:57 +0000)
Tidy up the stop/start files and make switch usage consistent. Also
tidy up the various "clean" targets in the Makefile.

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

index f14118acc4ea40356b4c6495da01fb9f185aa69a..34f003d6eafc5a1ed09a114bbea6cee9e20c3a46 100644 (file)
@@ -75,13 +75,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 68bc86c1877589a21b6c7561a3d74e39aef06bd8..7b1e0af2af608947b2fe953e3b1642f691b5120e 100644 (file)
@@ -93,7 +93,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 f29f1301df7c8407c40af6b27c34d44244ebc83f..179e8d09e5f3f79c8fe61e85b98e925d8d9363c3 100644 (file)
@@ -16,39 +16,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
-#   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]]";
+#   --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.
+#
+#   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
@@ -197,7 +218,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 {
@@ -259,7 +280,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 8f3ea2dec91a5cae8da5b6ef72d5b7f94b38ccf5..c79d41c7df940722b4510e3ad3a33f412f7c9b96 100644 (file)
 
 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
+#   --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
 
-my $usage = "usage: $0 [--use-rndc] test-directory [server-directory]";
-my $use_rndc;
+my $usage = "usage: $0 [--use-rndc] [--port port] test-directory [server-directory]";
 
-while (@ARGV && $ARGV[0] =~ /^-/) {
-       my $opt = shift @ARGV;
-       if ($opt eq '--use-rndc') {
-               $use_rndc = 1;
-       } else {
-               die "$usage\n";
-       }
-}
-
-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");
@@ -131,7 +132,7 @@ sub stop_rndc {
        my $ip = "10.53.0.$1";
 
        # Ugly, but should work.
-       system("$ENV{RNDC} -c ../common/rndc.conf -s $ip -p 9953 stop | sed 's/^/I:$server /'");
+       system("$ENV{RNDC} -c ../common/rndc.conf -s $ip -p $port stop | sed 's/^/I:$server /'");
        return;
 }