2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 22:15:20 +00:00

[rt46602] More updates to the test running framework

Tidy up the stop/start files and make switch usage consistent. Also
tidy up the various "clean" targets in the Makefile.
This commit is contained in:
Stephen Morris
2017-11-24 12:50:19 +00:00
parent 517d990bd4
commit b24c2e11d8
4 changed files with 70 additions and 41 deletions

View File

@@ -75,13 +75,20 @@ test: parallel.mk
check: test 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:: testclean clean distclean::
if test -f ./cleanall.sh; then $(SHELL) ./cleanall.sh; fi if test -f ./cleanall.sh; then $(SHELL) ./cleanall.sh; fi
rm -f systests.output rm -f systests.output
rm -f random.data rm -f random.data
rm -f parallel.mk rm -f parallel.mk
clean distclean::
rm -f ${TARGETS} rm -f ${TARGETS}
rm -f ${OBJS} rm -f ${OBJS}

View File

@@ -93,7 +93,7 @@ then
fi fi
# Start name servers running # 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 # Run the tests
( cd $test ; $SHELL tests.sh -p "$port" -- "$@" ) ( cd $test ; $SHELL tests.sh -p "$port" -- "$@" )

View File

@@ -16,39 +16,60 @@ use Cwd;
use Cwd 'abs_path'; use Cwd 'abs_path';
use Getopt::Long; use Getopt::Long;
# Option handling # Usage:
# --noclean test [server [options]] # perl start.pl [--noclean] --restart] [--port port] test [server [options]]
# #
# --noclean - Do not cleanup files in server directory # --noclean Do not cleanup files in server directory.
# test - name of the test directory #
# server - name of the server directory # --restart Indicate that the server is being restarted, so get the
# options - alternate options for the server # server to append output to an existing log file instead of
# NOTE: options must be specified with '-- "<option list>"', # starting a new one.
# for instance: start.pl . ns1 -- "-c n.conf -d 43" #
# ALSO NOTE: this variable will be filled with the # --port port Specify the default port being used by the server to answer
# contents of the first non-commented/non-blank line of args # queries (default 5300). This script will interrogate the
# in a file called "named.args" in an ns*/ subdirectory only # server on this port to see if it is running. (Note: for
# the FIRST non-commented/non-blank line is used (everything # "named" nameservers, this can be overridden by the presence
# else in the file is ignored. If "options" is already set, # of the file "named.port" in the server directory containing
# then "named.args" is ignored. # 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] test-directory [server-directory [server-options]]"; my $usage = "usage: $0 [--noclean] [--restart] [--port <port>] test-directory [server-directory [server-options]]";
my $noclean = ''; my $noclean = '';
my $restart = ''; my $restart = '';
my $defaultport = 5300; 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 $test = $ARGV[0];
my $server = $ARGV[1]; my $server = $ARGV[1];
my $options = $ARGV[2]; my $options = $ARGV[2];
if (!$test) { if (!$test) {
print "$usage\n"; die "$usage\n";
} }
if (!-d $test) { if (!-d $test) {
print "No test directory: \"$test\"\n"; die "No test directory: \"$test\"\n";
} }
if ($server && !-d "$test/$server") { if ($server && !-d "$test/$server") {
print "No server directory: \"$test/$server\"\n"; die "No server directory: \"$test/$server\"\n";
} }
# Global variables # Global variables
@@ -197,7 +218,7 @@ sub start_server {
} elsif ($server =~ /^ans/) { } elsif ($server =~ /^ans/) {
$cleanup_files = "{ans.run}"; $cleanup_files = "{ans.run}";
if (-e "$testdir/$server/ans.py") { 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") { } elsif (-e "$testdir/$server/ans.pl") {
$command = "$PERL ans.pl"; $command = "$PERL ans.pl";
} else { } else {
@@ -259,7 +280,7 @@ sub start_server {
sub verify_server { sub verify_server {
my $server = shift; my $server = shift;
my $n = $server; my $n = $server;
my $port = 5300; my $port = $defaultport;
my $tcp = "+tcp"; my $tcp = "+tcp";
$n =~ s/^ns//; $n =~ s/^ns//;

View File

@@ -15,30 +15,31 @@
use strict; use strict;
use Cwd 'abs_path'; use Cwd 'abs_path';
use Getopt::Long;
# Option handling # Usage:
# [--use-rndc] test [server] # perl stop.pl [[-use-rndc] [--port port] test [server]
# #
# test - name of the test directory # --use-rndc Attempt to stop the server via the "rndc stop" command.
# server - name of the server directory #
# --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 $usage = "usage: $0 [--use-rndc] [--port port] test-directory [server-directory]";
my $use_rndc;
while (@ARGV && $ARGV[0] =~ /^-/) { my $use_rndc = 0;
my $opt = shift @ARGV; my $port = 9953;
if ($opt eq '--use-rndc') { GetOptions('use-rndc' => \$use_rndc, 'port=i' => \$port) or die "$usage\n";
$use_rndc = 1;
} else {
die "$usage\n";
}
}
my $test = $ARGV[0];
my $server = $ARGV[1];
my $errors = 0; my $errors = 0;
my $test = $ARGV[0];
my $server = $ARGV[1];
die "$usage\n" unless defined($test); die "$usage\n" unless defined($test);
die "No test directory: \"$test\"\n" unless (-d $test); die "No test directory: \"$test\"\n" unless (-d $test);
die "No server directory: \"$server\"\n" if (defined($server) && !-d "$test/$server"); 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"; my $ip = "10.53.0.$1";
# Ugly, but should work. # 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; return;
} }