aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYang Tse <yangsita@gmail.com>2008-01-18 09:18:59 +0000
committerYang Tse <yangsita@gmail.com>2008-01-18 09:18:59 +0000
commit01d95b56a017fba457ad2eb88f4fae626d159ce3 (patch)
tree347b464412c206c01ed0b583d1d2703e4f2087c0 /tests
parentf6adae8d35f0d2b0bf80a47a5b0dd5ab35dff6b0 (diff)
fix failure to properly detect SSH and SOCKS servers start up on loaded systems
Diffstat (limited to 'tests')
-rwxr-xr-xtests/runtests.pl22
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 9eeaa3f78..77b57b1dc 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -1110,6 +1110,10 @@ sub runsshserver {
my $cmd="$perl $srcdir/sshserver.pl ${flag}-u $USER -l $ip -p $port -s $socksport";
my ($sshpid, $pid2) = startnew($cmd, $pidfile, 60, 0);
+ # on loaded systems sshserver start up can take longer than the timeout
+ # passed to startnew, when this happens startnew completes without being
+ # able to read the pidfile and consequently returns a zero pid2 above.
+
if($sshpid <= 0 || !kill(0, $sshpid)) {
# it is NOT alive
logmsg "RUN: failed to start the SSH server\n";
@@ -1118,15 +1122,22 @@ sub runsshserver {
return (0,0);
}
- if (!verifyserver("ssh",$ip,$port)) {
+ # server verification allows some extra time for the server to start up
+ # and gives us the opportunity of recovering the pid from the pidfile,
+ # which will be assigned to pid2 ONLY if pid2 was not already positive.
+
+ my $pid3 = verifyserver("ssh",$ip,$port);
+ if(!$pid3) {
logmsg "RUN: SSH server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$sshpid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}
+ $pid2 = $pid3 if($pid2 <= 0);
+
if($verbose) {
- logmsg "RUN: SSH server is now running PID $sshpid\n";
+ logmsg "RUN: SSH server is now running PID $pid2\n";
}
return ($pid2, $sshpid);
@@ -1237,15 +1248,18 @@ sub runsocksserver {
}
# Ugly hack but ssh doesn't support pid files
- if (!verifyserver("socks",$ip,$port)) {
+ my $pid3 = verifyserver("socks",$ip,$port);
+ if(!$pid3) {
logmsg "RUN: SOCKS server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$sshpid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}
+ $pid2 = $pid3 if($pid2 <= 0);
+
if($verbose) {
- logmsg "RUN: SOCKS server is now running PID $sshpid\n";
+ logmsg "RUN: SOCKS server is now running PID $pid2\n";
}
return ($pid2, $sshpid);