mirror of
https://github.com/curl/curl.git
synced 2025-09-29 15:36:53 +03:00
Make runtests.pl actually support any (valid) server specification
for the <killserver> section of test harness definition files.
This commit is contained in:
parent
b32a96eda0
commit
7525670610
|
@ -259,6 +259,7 @@ my $postmortem; # display detailed info about failed tests
|
||||||
|
|
||||||
my %run; # running server
|
my %run; # running server
|
||||||
my %doesntrun; # servers that don't work, identified by pidfile
|
my %doesntrun; # servers that don't work, identified by pidfile
|
||||||
|
my %serverpidfile;# all server pid file names, identified by server id
|
||||||
|
|
||||||
# torture test variables
|
# torture test variables
|
||||||
my $torture;
|
my $torture;
|
||||||
|
@ -316,6 +317,32 @@ $ENV{'SSL_CERT_DIR'}=undef;
|
||||||
$ENV{'SSL_CERT_PATH'}=undef;
|
$ENV{'SSL_CERT_PATH'}=undef;
|
||||||
$ENV{'CURL_CA_BUNDLE'}=undef;
|
$ENV{'CURL_CA_BUNDLE'}=undef;
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# Load serverpidfile hash with pidfile names for all possible servers.
|
||||||
|
#
|
||||||
|
sub init_serverpidfile_hash {
|
||||||
|
for my $proto (('ftp', 'http', 'imap', 'pop3', 'smtp')) {
|
||||||
|
for my $ssl (('', 's')) {
|
||||||
|
for my $ipvnum ((4, 6)) {
|
||||||
|
for my $idnum ((1, 2)) {
|
||||||
|
my $serv = servername_id("$proto$ssl", $ipvnum, $idnum);
|
||||||
|
my $pidf = server_pidfilename("$proto$ssl", $ipvnum, $idnum);
|
||||||
|
$serverpidfile{$serv} = $pidf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for my $proto (('tftp', 'sftp', 'socks', 'ssh')) {
|
||||||
|
for my $ipvnum ((4, 6)) {
|
||||||
|
for my $idnum ((1, 2)) {
|
||||||
|
my $serv = servername_id($proto, $ipvnum, $idnum);
|
||||||
|
my $pidf = server_pidfilename($proto, $ipvnum, $idnum);
|
||||||
|
$serverpidfile{$serv} = $pidf;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Check if a given child process has just died. Reaps it if so.
|
# Check if a given child process has just died. Reaps it if so.
|
||||||
#
|
#
|
||||||
|
@ -2346,19 +2373,43 @@ sub singletest {
|
||||||
my @killservers = getpart("client", "killserver");
|
my @killservers = getpart("client", "killserver");
|
||||||
foreach my $serv (@killservers) {
|
foreach my $serv (@killservers) {
|
||||||
chomp $serv;
|
chomp $serv;
|
||||||
if($serv =~ /^(ftp|imap|pop3|smtp)(\d*)(-ipv6|)/) {
|
my $pid;
|
||||||
|
# handle given server no matter if secure or not
|
||||||
|
if($run{$serv}) {
|
||||||
|
# stop server pid(s) from %run hash clearing them
|
||||||
|
stopserver($run{$serv});
|
||||||
|
$run{$serv} = 0;
|
||||||
|
}
|
||||||
|
# deal with unexpectedly still alive server
|
||||||
|
$pid = processexists($serverpidfile{$serv});
|
||||||
|
if($pid > 0) {
|
||||||
|
print STDERR "Warning: $serv server unexpectedly alive\n";
|
||||||
|
stopserver($pid);
|
||||||
|
}
|
||||||
|
# handle unsecure server when given a secure one
|
||||||
|
my $unsec = $serv;
|
||||||
|
if($serv =~ /^(ftp|http|imap|pop3|smtp)s(.*)$/) {
|
||||||
|
$unsec = "$1$2";
|
||||||
|
# stop unsecure server when stopping a secure one
|
||||||
|
if($run{$unsec}) {
|
||||||
|
# stop server pid(s) from %run hash clearing them
|
||||||
|
stopserver($run{$unsec});
|
||||||
|
$run{$unsec} = 0;
|
||||||
|
}
|
||||||
|
# deal with unexpectedly still alive server
|
||||||
|
$pid = processexists($serverpidfile{$unsec});
|
||||||
|
if($pid > 0) {
|
||||||
|
print STDERR "Warning: $unsec server unexpectedly alive\n";
|
||||||
|
stopserver($pid);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
# handle potentially still alive server sockfilters
|
||||||
|
if($unsec =~ /^(ftp|imap|pop3|smtp)(\d*)(-ipv6|)/) {
|
||||||
my $proto = $1;
|
my $proto = $1;
|
||||||
my $idnum = ($2 && ($2 > 1)) ? $2 : 1;
|
my $idnum = ($2 && ($2 > 1)) ? $2 : 1;
|
||||||
my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4;
|
my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4;
|
||||||
killsockfilters($proto, $ipvnum, $idnum, $verbose);
|
killsockfilters($proto, $ipvnum, $idnum, $verbose);
|
||||||
}
|
}
|
||||||
if($run{$serv}) {
|
|
||||||
stopserver($run{$serv}); # the pid file is in the hash table
|
|
||||||
$run{$serv}=0; # clear pid
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
logmsg "RUN: The $serv server is not running\n";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# remove the test server commands file after each test
|
# remove the test server commands file after each test
|
||||||
|
@ -3316,12 +3367,18 @@ $SMTP6PORT = $base++;
|
||||||
cleardir($LOGDIR);
|
cleardir($LOGDIR);
|
||||||
mkdir($LOGDIR, 0777);
|
mkdir($LOGDIR, 0777);
|
||||||
|
|
||||||
|
#######################################################################
|
||||||
|
# initialize some variables
|
||||||
|
#
|
||||||
|
|
||||||
|
get_disttests();
|
||||||
|
init_serverpidfile_hash();
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
# Output curl version and host info being tested
|
# Output curl version and host info being tested
|
||||||
#
|
#
|
||||||
|
|
||||||
if(!$listonly) {
|
if(!$listonly) {
|
||||||
get_disttests();
|
|
||||||
checksystem();
|
checksystem();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user