2
0
mirror of https://gitlab.isc.org/isc-projects/bind9 synced 2025-08-30 05:57:52 +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
# 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}

View 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" -- "$@" )

View 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.
# --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] test-directory [server-directory [server-options]]";
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//;

View File

@ -15,30 +15,31 @@
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;
}