From 9e037431b427f7b8e0f87c6f43987d034eb2a635 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Thu, 28 Apr 2005 13:54:48 +0000 Subject: When staring a HTTP server, use the pidfile preferably since it turns out sometimes the server can start but curl cannot speak to it, and then we must remember the server (in order to kill it properly) anyway. Also, make sure to kill all servers on exit everywhere. --- tests/runtests.pl | 79 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 44 insertions(+), 35 deletions(-) (limited to 'tests') diff --git a/tests/runtests.pl b/tests/runtests.pl index 24041c7d0..bef5a59a3 100755 --- a/tests/runtests.pl +++ b/tests/runtests.pl @@ -304,9 +304,6 @@ sub torture { print "torture OK\n"; return 0; - - #stopservers(); - #exit; # for now, we stop after these tests } ####################################################################### @@ -362,7 +359,7 @@ sub runhttpserver { my ($verbose, $ipv6) = @_; my $RUNNING; my $pid; - + my $cmd; my $pidfile = $HTTPPIDFILE; my $port = $HTTPPORT; my $ip = $HOSTIP; @@ -378,41 +375,44 @@ sub runhttpserver { $pid = checkserver($pidfile); - # verify if our/any server is running on this port - my $cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>log/verifyhttp"; - print "CMD; $cmd\n" if ($verbose); - my $res = system($cmd); + if($pid <= 0 ) { - $res >>= 8; # rotate the result - my $data; + # verify if our/any server is running on this port + $cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>log/verifyhttp"; + print "CMD; $cmd\n" if ($verbose); + my $res = system($cmd); - if($res && $verbose) { - open(ERR, "; - close(ERR); - print "RUN: curl command returned $res\n"; - for(@e) { - if($_ !~ /^([ \t]*)$/) { - print "RUN: $_"; + $res >>= 8; # rotate the result + my $data; + + if($res && $verbose) { + open(ERR, "; + close(ERR); + print "RUN: curl command returned $res\n"; + for(@e) { + if($_ !~ /^([ \t]*)$/) { + print "RUN: $_"; + } } } - } - open(FILE, "; - close(FILE); - $data=$file[0]; # first line + open(FILE, "; + close(FILE); + $data=$file[0]; # first line - if ( $data =~ /WE ROOLZ: (\d+)/ ) { - $pid = 0+$1; - } - elsif($res == 6) { - # curl: (6) Couldn't resolve host '::1' - print "RUN: failed to resolve host\n"; - return -3; - } - elsif($data || ($res != 7)) { - print "RUN: Unknown server is running on port $port\n"; - return -2; + if ( $data =~ /WE ROOLZ: (\d+)/ ) { + $pid = 0+$1; + } + elsif($res == 6) { + # curl: (6) Couldn't resolve host '::1' + print "RUN: failed to resolve host\n"; + return -3; + } + elsif($data || ($res != 7)) { + print "RUN: Unknown server is running on port $port\n"; + return -2; + } } if($pid > 0) { @@ -420,6 +420,7 @@ sub runhttpserver { if(!$res) { print "RUN: Failed to kill test HTTP$nameext server, do it ", "manually and restart the tests.\n"; + stopservers(); exit; } sleep(1); @@ -441,6 +442,13 @@ sub runhttpserver { # verify that our server is up and running: my $data=`$CURL --silent -g \"$ip:$port/verifiedserver\" 2>>log/verifyhttp`; + $pid = checkserver($pidfile); + if($pid) { + print STDERR "RUN: got http server pid from pidfile\n" if($verbose); + $verified = 1; + last; + } + if ( $data =~ /WE ROOLZ: (\d+)/ ) { $pid = 0+$1; $verified = 1; @@ -1228,6 +1236,7 @@ sub singletest { if($@) { print "perl: $code\n"; print "precommand: $@"; + stopservers(); exit; } } @@ -1400,6 +1409,7 @@ sub singletest { my $filename=$hash{'name'}; if(!$filename) { print "ERROR: section verify=>file has no name attribute!\n"; + stopservers(); exit; } my $filemode=$hash{'mode'}; @@ -1953,7 +1963,6 @@ foreach $testnum (@at) { # close(CMDLOG); - # Tests done, stop the servers stopservers(); -- cgit v1.2.3