Skip to content

Commit

Permalink
Michal Marek made the test suite remember what test servers that fail to
Browse files Browse the repository at this point in the history
start so that subsequent tries are simply skipped.
  • Loading branch information
bagder committed Nov 16, 2007
1 parent ea3fe98 commit 59dcc7e
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 9 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Expand Up @@ -6,6 +6,10 @@

Changelog

Daniel S (17 Nov 2007)
- Michal Marek made the test suite remember what test servers that fail to
start so that subsequent tries are simply skipped.

Daniel S (16 Nov 2007)
- Ates Goral identified a problem in http.c:add_buffer_send() when a debug
callback was used, as it could wrongly pass on a bad size for the outgoing
Expand Down
70 changes: 61 additions & 9 deletions tests/runtests.pl
Expand Up @@ -186,7 +186,8 @@
my $listonly; # only list the tests
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

# torture test variables
my $torture;
Expand Down Expand Up @@ -708,6 +709,11 @@ sub runhttpserver {
$nameext="-ipv6";
}

# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

$pid = checkserver($pidfile);

if($pid > 0) {
Expand All @@ -727,6 +733,7 @@ sub runhttpserver {
if($httppid <= 0 || !kill(0, $httppid)) {
# it is NOT alive
logmsg "RUN: failed to start the HTTP$nameext server\n";
$doesntrun{$pidfile} = 1;
return (0,0);
}

Expand All @@ -735,6 +742,7 @@ sub runhttpserver {
logmsg "RUN: HTTP$nameext server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$httppid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}

Expand All @@ -755,6 +763,7 @@ sub runhttpsserver {
my $STATUS;
my $RUNNING;
my $ip = $HOSTIP;
my $pidfile = $HTTPSPIDFILE;

if(!$stunnel) {
return 0;
Expand All @@ -765,7 +774,12 @@ sub runhttpsserver {
$ip = $HOST6IP;
}

my $pid=checkserver($HTTPSPIDFILE);
# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

my $pid=checkserver($pidfile);

if($pid > 0) {
# kill previous stunnel!
Expand All @@ -775,12 +789,13 @@ sub runhttpsserver {
my $flag=$debugprotocol?"-v ":"";
my $cmd="$perl $srcdir/httpsserver.pl $flag -p https -s \"$stunnel\" -d $srcdir -r $HTTPPORT $HTTPSPORT";

my ($httpspid, $pid2) = startnew($cmd, $HTTPSPIDFILE,0);
my ($httpspid, $pid2) = startnew($cmd, $pidfile,0);

if($httpspid <= 0 || !kill(0, $httpspid)) {
# it is NOT alive
logmsg "RUN: failed to start the HTTPS server\n";
stopservers($verbose);
$doesntrun{$pidfile} = 1;
return(0,0);
}

Expand All @@ -789,6 +804,7 @@ sub runhttpsserver {
logmsg "RUN: HTTPS server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$httpspid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}

Expand Down Expand Up @@ -823,6 +839,11 @@ sub runftpserver {
$nameext="-ipv6";
}

# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

my $pid = checkserver($pidfile);
if($pid >= 0) {
stopserver($pid);
Expand Down Expand Up @@ -850,14 +871,16 @@ sub runftpserver {
if($ftppid <= 0 || !kill(0, $ftppid)) {
# it is NOT alive
logmsg "RUN: failed to start the FTP$id$nameext server\n";
return -1;
$doesntrun{$pidfile} = 1;
return (0,0);
}

# Server is up. Verify that we can speak to it.
if(!verifyserver("ftp", $ip, $port)) {
logmsg "RUN: FTP$id$nameext server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$ftppid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}

Expand All @@ -878,6 +901,7 @@ sub runftpsserver {
my $STATUS;
my $RUNNING;
my $ip = $HOSTIP;
my $pidfile = $FTPSPIDFILE;

if(!$stunnel) {
return 0;
Expand All @@ -888,7 +912,12 @@ sub runftpsserver {
$ip = $HOST6IP;
}

my $pid=checkserver($FTPSPIDFILE);
# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

my $pid=checkserver($pidfile);

if($pid > 0) {
# kill previous stunnel!
Expand All @@ -898,12 +927,13 @@ sub runftpsserver {
my $flag=$debugprotocol?"-v ":"";
my $cmd="$perl $srcdir/httpsserver.pl $flag -p ftps -s \"$stunnel\" -d $srcdir -r $FTPPORT $FTPSPORT";

my ($ftpspid, $pid2) = startnew($cmd, $FTPSPIDFILE,0);
my ($ftpspid, $pid2) = startnew($cmd, $pidfile,0);

if($ftpspid <= 0 || !kill(0, $ftpspid)) {
# it is NOT alive
logmsg "RUN: failed to start the FTPS server\n";
stopservers($verbose);
$doesntrun{$pidfile} = 1;
return(0,0);
}

Expand All @@ -912,6 +942,7 @@ sub runftpsserver {
logmsg "RUN: FTPS server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$ftpspid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}

Expand Down Expand Up @@ -946,6 +977,11 @@ sub runtftpserver {
$nameext="-ipv6";
}

# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

my $pid = checkserver($pidfile);
if($pid >= 0) {
stopserver($pid);
Expand All @@ -968,15 +1004,17 @@ sub runtftpserver {

if($tftppid <= 0 || !kill(0, $tftppid)) {
# it is NOT alive
logmsg "RUN: failed to start the FTP$id$nameext server\n";
return -1;
logmsg "RUN: failed to start the TFTP$id$nameext server\n";
$doesntrun{$pidfile} = 1;
return (0,0);
}

# Server is up. Verify that we can speak to it.
if(!verifyserver("tftp", $ip, $port)) {
logmsg "RUN: TFTP$id$nameext server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$tftppid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}

Expand All @@ -999,6 +1037,11 @@ sub runsshserver {
my $port = $SSHPORT;
my $pidfile = $SSHPIDFILE;

# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

my $pid = checkserver($pidfile);
if($pid > 0) {
stopserver($pid);
Expand All @@ -1014,11 +1057,13 @@ sub runsshserver {
logmsg "RUN: failed to start the SSH server\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$sshpid $pid2");
return -1;
$doesntrun{$pidfile} = 1;
return (0,0);
}

if (!verifyserver('ssh',$ip,$port)) {
logmsg "RUN: SSH server failed verification\n";
$doesntrun{$pidfile} = 1;
return (0,0);
}
if($verbose) {
Expand All @@ -1037,6 +1082,11 @@ sub runsocksserver {
my $port = $SOCKSPORT;
my $pidfile = $SOCKSPIDFILE;

# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}

my $flag=$debugprotocol?"-v ":"";
my $cmd="ssh -D ${HOSTIP}:$SOCKSPORT -N -F curl_ssh_config ${USER}\@${HOSTIP} -p ${SSHPORT} -vv >log/ssh.log 2>&1";
my ($sshpid, $pid2) =
Expand All @@ -1047,12 +1097,14 @@ sub runsocksserver {
logmsg "RUN: failed to start the SOCKS server\n";
# failed to talk to it properly. Kill the server and return failure
stopserver("$sshpid $pid2");
$doesntrun{$pidfile} = 1;
return (0,0);
}

# Ugly hack but ssh doesn't support pid files
if (!verifyserver('socks',$ip,$port)) {
logmsg "RUN: SOCKS server failed verification\n";
$doesntrun{$pidfile} = 1;
return (0,0);
}
if($verbose) {
Expand Down

0 comments on commit 59dcc7e

Please sign in to comment.