mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
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.
This commit is contained in:
parent
f71b3676bb
commit
9e037431b4
@ -304,9 +304,6 @@ sub torture {
|
|||||||
|
|
||||||
print "torture OK\n";
|
print "torture OK\n";
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
#stopservers();
|
|
||||||
#exit; # for now, we stop after these tests
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#######################################################################
|
#######################################################################
|
||||||
@ -362,7 +359,7 @@ sub runhttpserver {
|
|||||||
my ($verbose, $ipv6) = @_;
|
my ($verbose, $ipv6) = @_;
|
||||||
my $RUNNING;
|
my $RUNNING;
|
||||||
my $pid;
|
my $pid;
|
||||||
|
my $cmd;
|
||||||
my $pidfile = $HTTPPIDFILE;
|
my $pidfile = $HTTPPIDFILE;
|
||||||
my $port = $HTTPPORT;
|
my $port = $HTTPPORT;
|
||||||
my $ip = $HOSTIP;
|
my $ip = $HOSTIP;
|
||||||
@ -378,8 +375,10 @@ sub runhttpserver {
|
|||||||
|
|
||||||
$pid = checkserver($pidfile);
|
$pid = checkserver($pidfile);
|
||||||
|
|
||||||
|
if($pid <= 0 ) {
|
||||||
|
|
||||||
# verify if our/any server is running on this port
|
# verify if our/any server is running on this port
|
||||||
my $cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>log/verifyhttp";
|
$cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>log/verifyhttp";
|
||||||
print "CMD; $cmd\n" if ($verbose);
|
print "CMD; $cmd\n" if ($verbose);
|
||||||
my $res = system($cmd);
|
my $res = system($cmd);
|
||||||
|
|
||||||
@ -414,12 +413,14 @@ sub runhttpserver {
|
|||||||
print "RUN: Unknown server is running on port $port\n";
|
print "RUN: Unknown server is running on port $port\n";
|
||||||
return -2;
|
return -2;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
my $res = kill (9, $pid); # die!
|
my $res = kill (9, $pid); # die!
|
||||||
if(!$res) {
|
if(!$res) {
|
||||||
print "RUN: Failed to kill test HTTP$nameext server, do it ",
|
print "RUN: Failed to kill test HTTP$nameext server, do it ",
|
||||||
"manually and restart the tests.\n";
|
"manually and restart the tests.\n";
|
||||||
|
stopservers();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -441,6 +442,13 @@ sub runhttpserver {
|
|||||||
# verify that our server is up and running:
|
# verify that our server is up and running:
|
||||||
my $data=`$CURL --silent -g \"$ip:$port/verifiedserver\" 2>>log/verifyhttp`;
|
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+)/ ) {
|
if ( $data =~ /WE ROOLZ: (\d+)/ ) {
|
||||||
$pid = 0+$1;
|
$pid = 0+$1;
|
||||||
$verified = 1;
|
$verified = 1;
|
||||||
@ -1228,6 +1236,7 @@ sub singletest {
|
|||||||
if($@) {
|
if($@) {
|
||||||
print "perl: $code\n";
|
print "perl: $code\n";
|
||||||
print "precommand: $@";
|
print "precommand: $@";
|
||||||
|
stopservers();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1400,6 +1409,7 @@ sub singletest {
|
|||||||
my $filename=$hash{'name'};
|
my $filename=$hash{'name'};
|
||||||
if(!$filename) {
|
if(!$filename) {
|
||||||
print "ERROR: section verify=>file has no name attribute!\n";
|
print "ERROR: section verify=>file has no name attribute!\n";
|
||||||
|
stopservers();
|
||||||
exit;
|
exit;
|
||||||
}
|
}
|
||||||
my $filemode=$hash{'mode'};
|
my $filemode=$hash{'mode'};
|
||||||
@ -1953,7 +1963,6 @@ foreach $testnum (@at) {
|
|||||||
#
|
#
|
||||||
close(CMDLOG);
|
close(CMDLOG);
|
||||||
|
|
||||||
|
|
||||||
# Tests done, stop the servers
|
# Tests done, stop the servers
|
||||||
stopservers();
|
stopservers();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user