aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-01-11 20:17:33 +0000
committerYang Tse <yangsita@gmail.com>2008-01-11 20:17:33 +0000
commit35be09cf58639f4d30c2ffc3ff14ecf63f295fe8 (patch)
treee9667941a78ec61ff7f1a2e4dfe0091db5a0ec78
parent3564aec388ee0c0177849389bb136461cc95ee62 (diff)
When verifying that test harness's SSH and SOCKS servers have been
started check also that the process is actually alive, since they could have died once the pidfile was written out
-rwxr-xr-xtests/runtests.pl34
1 files changed, 26 insertions, 8 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 3e806acf1..f3e1905e5 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -661,14 +661,20 @@ sub verifyftp {
sub verifyssh {
my ($proto, $ip, $port) = @_;
- my $pid;
+ my $pid = 0;
if(open(FILE, "<$SSHPIDFILE")) {
$pid=0+<FILE>;
close(FILE);
- logmsg "TRACESSH:verifyssh: pid from $SSHPIDFILE is $pid\n";
}
- else {
- logmsg "TRACESSH:verifyssh: cannot open file $SSHPIDFILE\n";
+ if($pid > 0) {
+ # if we have a pid it is actually our ssh server,
+ # since runsshserver() unlinks previous pidfile
+ if(!kill(0, $pid) {
+ logmsg "RUN: SSH server has died after starting up\n";
+ checkdied($pid)
+ unlink($SSHPIDFILE);
+ $pid = -1;
+ }
}
return $pid;
}
@@ -678,9 +684,21 @@ sub verifyssh {
sub verifysocks {
my ($proto, $ip, $port) = @_;
- open(FILE, "<$SOCKSPIDFILE");
- my $pid=0+<FILE>;
- close(FILE);
+ my $pid = 0;
+ if(open(FILE, "<$SOCKSPIDFILE")) {
+ $pid=0+<FILE>;
+ close(FILE);
+ }
+ if($pid > 0) {
+ # if we have a pid it is actually our socks server,
+ # since runsocksserver() unlinks previous pidfile
+ if(!kill(0, $pid) {
+ logmsg "RUN: SOCKS server has died after starting up\n";
+ checkdied($pid)
+ unlink($SOCKSPIDFILE);
+ $pid = -1;
+ }
+ }
return $pid;
}
@@ -2500,7 +2518,7 @@ sub startservers {
}
if($what eq "socks4" || $what eq "socks5") {
if(!$run{'socks'}) {
- ($pid, $pid2) = runsocksserver("", 1);
+ ($pid, $pid2) = runsocksserver("", $verbose);
if($pid <= 0) {
return "failed starting socks server";
}