aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2006-11-20 10:35:25 +0000
committerYang Tse <yangsita@gmail.com>2006-11-20 10:35:25 +0000
commit1e35d95df8ba86f62e52a08e2dfdb1eb35a9b710 (patch)
tree3fd1a2f046843ed0260081c47752159172762a63
parentd8387b418db176b952e931c9d54c1c04fd5499c8 (diff)
Add some message logging
-rw-r--r--tests/ftp.pm27
-rw-r--r--tests/ftpserver.pl2
-rwxr-xr-xtests/runtests.pl58
3 files changed, 58 insertions, 29 deletions
diff --git a/tests/ftp.pm b/tests/ftp.pm
index 57c45cfc9..41788fb57 100644
--- a/tests/ftp.pm
+++ b/tests/ftp.pm
@@ -147,7 +147,7 @@ sub checkalivepidfile {
# how many times a pid is repeated it will only be signalled once.
#
sub signalpids {
- my ($signal, $pids)=@_;
+ my ($signal, $pids, $verbose)=@_;
if((not defined $signal) || (not defined $pids)) {
return;
@@ -155,6 +155,7 @@ sub signalpids {
if($pids !~ /\s+/) {
# avoid sorting if only one pid
if(checkalivepid($pids) > 0) {
+ printf ("* pid $pids signalled ($signal)\n") if($verbose);
kill($signal, $pids);
}
return;
@@ -166,6 +167,7 @@ sub signalpids {
if($prev != $pid) {
$prev = $pid;
if(checkalivepid($pid) > 0) {
+ printf ("* pid $pid signalled ($signal)\n") if($verbose);
kill($signal, $pid);
}
}
@@ -180,11 +182,11 @@ sub signalpids {
# with that pid is actually alive.
#
sub signalpidfile {
- my ($signal, $pidfile)=@_;
+ my ($signal, $pidfile, $verbose)=@_;
my $pid = pidfromfile($pidfile);
if($pid > 0) {
- signalpids($signal, $pid);
+ signalpids($signal, $pid, $verbose);
}
}
@@ -257,16 +259,16 @@ sub waitalivepidfile {
# any of them in DEFAULT_TIMEOUT_STOP seconds then it returns 0.
#
sub stopprocess {
- my ($pids)=@_;
+ my ($pids, $verbose)=@_;
if(not defined $pids) {
return 1;
}
- signalpids("KILL", $pids);
+ signalpids("KILL", $pids, $verbose);
if(waitdeadpid($pids, $ONE_HALF_STOP_TIMEOUT) == 0) {
- signalpids("KILL", $pids);
+ signalpids("KILL", $pids, $verbose);
if(waitdeadpid($pids, $ONE_THIRD_STOP_TIMEOUT) == 0) {
- signalpids("KILL", $pids);
+ signalpids("KILL", $pids, $verbose);
if(waitdeadpid($pids, $ONE_SIXTH_STOP_TIMEOUT) == 0) {
return 0; # at least one pid is still alive !!!
}
@@ -284,7 +286,7 @@ sub stopprocess {
# returns 0.
#
sub stopprocesspidfile {
- my ($pidfile)=@_;
+ my ($pidfile, $verbose)=@_;
if(not defined $pidfile) {
return 1;
@@ -292,7 +294,7 @@ sub stopprocesspidfile {
my $ret = 1; # assume success stopping it
my $pid = checkalivepidfile($pidfile);
if($pid > 0) {
- $ret = stopprocess($pid);
+ $ret = stopprocess($pid, $verbose);
}
unlinkpidfiles($pidfile);
return $ret;
@@ -306,7 +308,7 @@ sub stopprocesspidfile {
# to stop it in DEFAULT_TIMEOUT_STOP seconds then it returns 0.
#
sub ftpkillslave {
- my ($id, $ext)=@_;
+ my ($id, $ext, $verbose)=@_;
if(not defined $id) {
$id = "";
@@ -326,7 +328,7 @@ sub ftpkillslave {
}
}
if($pids) {
- $ret = stopprocess($pids);
+ $ret = stopprocess($pids, $verbose);
}
if($pidfiles) {
unlinkpidfiles($pidfiles);
@@ -342,6 +344,7 @@ sub ftpkillslave {
# of them in DEFAULT_TIMEOUT_STOP seconds then returns 0.
#
sub ftpkillslaves {
+ my ($verbose)=@_;
my $ret = 1; # assume success stopping them
my $pids = "";
@@ -359,7 +362,7 @@ sub ftpkillslaves {
}
}
if($pids) {
- $ret = stopprocess($pids);
+ $ret = stopprocess($pids, $verbose);
}
if($pidfiles) {
unlinkpidfiles($pidfiles);
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl
index e7adef320..566453a3f 100644
--- a/tests/ftpserver.pl
+++ b/tests/ftpserver.pl
@@ -114,7 +114,7 @@ do {
sub catch_zap {
my $signame = shift;
print STDERR "ftpserver.pl received SIG$signame, exiting\n";
- ftpkillslaves();
+ ftpkillslave($ftpdnum, $ext, 1);
die "Somebody sent me a SIG$signame";
}
$SIG{INT} = \&catch_zap;
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 1e2e37c7e..bd4802632 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -440,6 +440,7 @@ sub stoptestserver {
my $serverpids = "";
if($run{$serv}) {
+ logmsg ("RUN: Stopping the $serv server...\n");
if($run{$serv}{'slavepidfiles'}) {
for $pidfile (split(" ", $run{$serv}{'slavepidfiles'})) {
$pidfiles .= " $pidfile";
@@ -450,29 +451,41 @@ sub stoptestserver {
}
delete $run{$serv}{'slavepidfiles'};
}
+ if($run{$serv}{'pids'}) {
+ $pid = $run{$serv}{'pids'};
+ $serverpids .= " $pid";
+ delete $run{$serv}{'pids'};
+ }
if($run{$serv}{'pidfile'}) {
$pidfile = $run{$serv}{'pidfile'};
$pidfiles .= " $pidfile";
$pid = checkalivepidfile($pidfile);
- if($pid > 0) {
+ if(($pid > 0) && ($serverpids !~ /\b$pid\b/)) {
$serverpids .= " $pid";
}
delete $run{$serv}{'pidfile'};
}
- if($run{$serv}{'pids'}) {
- $pid = $run{$serv}{'pids'};
- $serverpids .= " $pid";
- delete $run{$serv}{'pids'};
- }
if($run{$serv}) {
delete $run{$serv};
}
}
if($slavepids) {
- $ret = stopprocess($slavepids);
+ logmsg ("* slave pid(s) $slavepids\n");
+ }
+ if($serverpids) {
+ logmsg ("* server pid(s) $serverpids\n");
+ }
+ if($slavepids) {
+ $ret = stopprocess($slavepids, 1);
+ if($ret == 0) {
+ logmsg ("* slave process is still alive !!!\n");
+ }
}
if($serverpids) {
- $ret = stopprocess($serverpids);
+ $ret = stopprocess($serverpids, 1);
+ if($ret == 0) {
+ logmsg ("* server process is still alive !!!\n");
+ }
}
if($pidfiles) {
unlinkpidfiles($pidfiles);
@@ -1849,6 +1862,7 @@ sub stopalltestservers {
for my $serv (keys %run) {
if($run{$serv}) {
+ logmsg ("RUN: Stopping the $serv server...\n");
if($run{$serv}{'slavepidfiles'}) {
for $pidfile (split(" ", $run{$serv}{'slavepidfiles'})) {
$pidfiles .= " $pidfile";
@@ -1859,30 +1873,42 @@ sub stopalltestservers {
}
delete $run{$serv}{'slavepidfiles'};
}
+ if($run{$serv}{'pids'}) {
+ $pid = $run{$serv}{'pids'};
+ $serverpids .= " $pid";
+ delete $run{$serv}{'pids'};
+ }
if($run{$serv}{'pidfile'}) {
$pidfile = $run{$serv}{'pidfile'};
$pidfiles .= " $pidfile";
$pid = checkalivepidfile($pidfile);
- if($pid > 0) {
+ if(($pid > 0) && ($serverpids !~ /\b$pid\b/)) {
$serverpids .= " $pid";
}
delete $run{$serv}{'pidfile'};
}
- if($run{$serv}{'pids'}) {
- $pid = $run{$serv}{'pids'};
- $serverpids .= " $pid";
- delete $run{$serv}{'pids'};
- }
if($run{$serv}) {
delete $run{$serv};
}
}
}
if($slavepids) {
- $ret = stopprocess($slavepids);
+ logmsg ("* slave pid(s) $slavepids\n");
+ }
+ if($serverpids) {
+ logmsg ("* server pid(s) $serverpids\n");
+ }
+ if($slavepids) {
+ $ret = stopprocess($slavepids, 1);
+ if($ret == 0) {
+ logmsg ("* slave process is still alive !!!\n");
+ }
}
if($serverpids) {
- $ret = stopprocess($serverpids);
+ $ret = stopprocess($serverpids, 1);
+ if($ret == 0) {
+ logmsg ("* server process is still alive !!!\n");
+ }
}
if($pidfiles) {
unlinkpidfiles($pidfiles);