diff options
author | Yang Tse <yangsita@gmail.com> | 2010-01-14 17:36:57 +0000 |
---|---|---|
committer | Yang Tse <yangsita@gmail.com> | 2010-01-14 17:36:57 +0000 |
commit | 7624527591499ecf22634a28675e5bb2845149b5 (patch) | |
tree | 99bb826aea49d8880962cd0187680b6310007b1f /tests | |
parent | 383bf1e4764cf141846e27bca8872f80fecdd1a7 (diff) |
Squeeze slack time when killing more than one server from
the <killserver> section of test harness definition files.
Diffstat (limited to 'tests')
-rwxr-xr-x | tests/runtests.pl | 91 |
1 files changed, 54 insertions, 37 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl index 3ddadbb46..c5091e841 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -1919,7 +1919,7 @@ sub singletest { $timeprepini{$testnum} = Time::HiRes::time() if($timestats); if($disttests !~ /test$testnum\W/ ) { - print STDERR "Warning: data/test$testnum is not present in tests/data/Makefile.am\n"; + logmsg "Warning: test$testnum not present in tests/data/Makefile.am\n"; } @@ -2370,45 +2370,62 @@ sub singletest { $timesrvrlog{$testnum} = Time::HiRes::time() if($timestats); # test definition might instruct to stop some servers + # stop also non-secure server when stopping a ssl one my @killservers = getpart("client", "killserver"); - foreach my $serv (@killservers) { - chomp $serv; - 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); + if(@killservers) { + # + # kill sockfilter processes for pingpong servers + # + foreach my $server (@killservers) { + chomp $server; + if($server =~ /^(ftp|imap|pop3|smtp)s?(\d*)(-ipv6|)$/) { + my $proto = $1; + my $idnum = ($2 && ($2 > 1)) ? $2 : 1; + my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4; + killsockfilters($proto, $ipvnum, $idnum, $verbose); + } + } + # + # kill server pids from %run hash clearing them + # + my $pidlist; + foreach my $server (@killservers) { + chomp $server; + if($run{$server}) { + $pidlist .= " $run{$server}"; + $run{$server} = 0; + } + if($server =~ /^(ftp|http|imap|pop3|smtp)s(.*)$/) { + $server = "$1$2"; + if($run{$server}) { + $pidlist .= " $run{$server}"; + $run{$server} = 0; + } } } - # handle potentially still alive server sockfilters - if($unsec =~ /^(ftp|imap|pop3|smtp)(\d*)(-ipv6|)/) { - my $proto = $1; - my $idnum = ($2 && ($2 > 1)) ? $2 : 1; - my $ipvnum = ($3 && ($3 =~ /6$/)) ? 6 : 4; - killsockfilters($proto, $ipvnum, $idnum, $verbose); + killpid($verbose, $pidlist); + # + # cleanup server pid files + # + foreach my $server (@killservers) { + chomp $server; + my $pidfile = $serverpidfile{$server}; + my $pid = processexists($pidfile); + if($pid > 0) { + logmsg "Warning: $server server unexpectedly alive\n"; + killpid($verbose, $pid); + } + unlink($pidfile) if(-f $pidfile); + if($server =~ /^(ftp|http|imap|pop3|smtp)s(.*)$/) { + $server = "$1$2"; + $pidfile = $serverpidfile{$server}; + $pid = processexists($pidfile); + if($pid > 0) { + logmsg "Warning: $server server unexpectedly alive\n"; + killpid($verbose, $pid); + } + unlink($pidfile) if(-f $pidfile); + } } } |