mirror of
https://github.com/moparisthebest/curl
synced 2024-12-22 08:08:50 -05:00
Start using the centralized pidfile and logfile name generation
subroutines for http and tftp test suite servers.
This commit is contained in:
parent
184f92d243
commit
aa2f447400
@ -28,7 +28,7 @@ EXTRA_DIST = ftpserver.pl httpserver.pl httpsserver.pl runtests.pl getpart.pm \
|
|||||||
FILEFORMAT README stunnel.pem memanalyze.pl testcurl.pl valgrind.pm ftp.pm \
|
FILEFORMAT README stunnel.pem memanalyze.pl testcurl.pl valgrind.pm ftp.pm \
|
||||||
sshserver.pl sshhelp.pm testcurl.1 runtests.1 $(HTMLPAGES) $(PDFPAGES) \
|
sshserver.pl sshhelp.pm testcurl.1 runtests.1 $(HTMLPAGES) $(PDFPAGES) \
|
||||||
CMakeLists.txt certs/scripts/*.sh certs/Server* certs/EdelCurlRoot* \
|
CMakeLists.txt certs/scripts/*.sh certs/Server* certs/EdelCurlRoot* \
|
||||||
serverhelp.pm
|
serverhelp.pm tftpserver.pl
|
||||||
|
|
||||||
SUBDIRS = data server libtest
|
SUBDIRS = data server libtest
|
||||||
|
|
||||||
|
@ -1,44 +1,114 @@
|
|||||||
#!/usr/bin/env perl
|
#!/usr/bin/env perl
|
||||||
|
#***************************************************************************
|
||||||
|
# _ _ ____ _
|
||||||
|
# Project ___| | | | _ \| |
|
||||||
|
# / __| | | | |_) | |
|
||||||
|
# | (__| |_| | _ <| |___
|
||||||
|
# \___|\___/|_| \_\_____|
|
||||||
|
#
|
||||||
|
# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
#
|
||||||
|
# This software is licensed as described in the file COPYING, which
|
||||||
|
# you should have received as part of this distribution. The terms
|
||||||
|
# are also available at http://curl.haxx.se/docs/copyright.html.
|
||||||
|
#
|
||||||
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
# copies of the Software, and permit persons to whom the Software is
|
||||||
|
# furnished to do so, under the terms of the COPYING file.
|
||||||
|
#
|
||||||
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
# KIND, either express or implied.
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#***************************************************************************
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
@INC=(@INC, $ENV{'srcdir'}, '.');
|
||||||
|
}
|
||||||
|
|
||||||
use strict;
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
my $verbose=0; # set to 1 for debugging
|
use serverhelp qw(
|
||||||
|
server_pidfilename
|
||||||
|
server_logfilename
|
||||||
|
);
|
||||||
|
|
||||||
my $dir=".";
|
my $verbose = 0; # set to 1 for debugging
|
||||||
my $port = 8999; # just a default
|
my $port = 8990; # just a default
|
||||||
my $ipv6;
|
my $ipvnum = 4; # default IP version of http server
|
||||||
my $pid=".http.pid"; # name of the pidfile
|
my $idnum = 1; # dafault http server instance number
|
||||||
|
my $proto = 'http'; # protocol the http server speaks
|
||||||
|
my $pidfile; # http server pid file
|
||||||
|
my $logfile; # http server log file
|
||||||
|
my $srcdir;
|
||||||
my $fork;
|
my $fork;
|
||||||
|
|
||||||
my $flags = "";
|
my $flags = "";
|
||||||
|
my $path = '.';
|
||||||
|
my $logdir = $path .'/log';
|
||||||
|
|
||||||
do {
|
while(@ARGV) {
|
||||||
if($ARGV[0] eq "-v") {
|
if($ARGV[0] eq '--pidfile') {
|
||||||
$verbose=1;
|
if($ARGV[1]) {
|
||||||
|
$pidfile = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-d") {
|
elsif($ARGV[0] eq '--logfile') {
|
||||||
$dir=$ARGV[1];
|
if($ARGV[1]) {
|
||||||
shift @ARGV;
|
$logfile = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "-p") {
|
elsif($ARGV[0] eq '--srcdir') {
|
||||||
$pid=$ARGV[1];
|
if($ARGV[1]) {
|
||||||
shift @ARGV;
|
$srcdir = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] eq "--fork") {
|
elsif($ARGV[0] eq '--ipv4') {
|
||||||
|
$ipvnum = 4;
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--ipv6') {
|
||||||
|
$ipvnum = 6;
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--port') {
|
||||||
|
if($ARGV[1] =~ /^(\d+)$/) {
|
||||||
|
$port = $1;
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--id') {
|
||||||
|
if($ARGV[1] =~ /^(\d+)$/) {
|
||||||
|
$idnum = $1 if($1 > 0);
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--verbose') {
|
||||||
|
$verbose = 1;
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--fork') {
|
||||||
$fork = $ARGV[0];
|
$fork = $ARGV[0];
|
||||||
shift @ARGV;
|
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] =~ /^(\d+)$/) {
|
else {
|
||||||
$port = $1;
|
print STDERR "\nWarning: httpserver.pl unknown parameter: $ARGV[0]\n";
|
||||||
}
|
}
|
||||||
elsif($ARGV[0] =~ /^ipv6/i) {
|
shift @ARGV;
|
||||||
$ipv6="--ipv6 ";
|
}
|
||||||
}
|
|
||||||
} while(shift @ARGV);
|
if(!$srcdir) {
|
||||||
|
$srcdir = $ENV{'srcdir'} || '.';
|
||||||
|
}
|
||||||
|
if(!$pidfile) {
|
||||||
|
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
|
||||||
|
}
|
||||||
|
if(!$logfile) {
|
||||||
|
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
|
||||||
|
}
|
||||||
|
|
||||||
$flags .= "--pidfile \"$pid\" ";
|
|
||||||
$flags .= "--fork " if(defined($fork));
|
$flags .= "--fork " if(defined($fork));
|
||||||
$flags .= "--ipv6 " if(defined($ipv6));
|
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
||||||
$flags .= "--port $port --srcdir \"$dir\"";
|
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
|
||||||
|
|
||||||
exec("server/sws $flags");
|
exec("server/sws $flags");
|
||||||
|
@ -73,6 +73,8 @@ use Cwd;
|
|||||||
# Subs imported from serverhelp module
|
# Subs imported from serverhelp module
|
||||||
use serverhelp qw(
|
use serverhelp qw(
|
||||||
servername_str
|
servername_str
|
||||||
|
server_pidfilename
|
||||||
|
server_logfilename
|
||||||
);
|
);
|
||||||
|
|
||||||
# Variables and subs imported from sshhelp module
|
# Variables and subs imported from sshhelp module
|
||||||
@ -803,46 +805,48 @@ sub verifyserver {
|
|||||||
#
|
#
|
||||||
sub runhttpserver {
|
sub runhttpserver {
|
||||||
my ($verbose, $ipv6) = @_;
|
my ($verbose, $ipv6) = @_;
|
||||||
my $RUNNING;
|
|
||||||
my $pidfile = $HTTPPIDFILE;
|
|
||||||
my $port = $HTTPPORT;
|
my $port = $HTTPPORT;
|
||||||
my $ip = $HOSTIP;
|
my $ip = $HOSTIP;
|
||||||
my $proto = 'http';
|
my $proto = 'http';
|
||||||
my $ipvnum = 4;
|
my $ipvnum = 4;
|
||||||
my $idnum = 1;
|
my $idnum = 1;
|
||||||
my $srvrname;
|
my $srvrname;
|
||||||
my $fork = $forkserver?"--fork":"";
|
my $pidfile;
|
||||||
|
my $logfile;
|
||||||
|
my $flags = "";
|
||||||
|
|
||||||
if($ipv6) {
|
if($ipv6) {
|
||||||
# if IPv6, use a different setup
|
# if IPv6, use a different setup
|
||||||
$ipvnum = 6;
|
$ipvnum = 6;
|
||||||
$pidfile = $HTTP6PIDFILE;
|
|
||||||
$port = $HTTP6PORT;
|
$port = $HTTP6PORT;
|
||||||
$ip = $HOST6IP;
|
$ip = $HOST6IP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pidfile = server_pidfilename($proto, $ipvnum, $idnum);
|
||||||
|
|
||||||
# don't retry if the server doesn't work
|
# don't retry if the server doesn't work
|
||||||
if ($doesntrun{$pidfile}) {
|
if ($doesntrun{$pidfile}) {
|
||||||
return (0,0);
|
return (0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$srvrname = servername_str($proto, $ipvnum, $idnum);
|
|
||||||
|
|
||||||
my $pid = processexists($pidfile);
|
my $pid = processexists($pidfile);
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
stopserver($pid);
|
stopserver($pid);
|
||||||
}
|
}
|
||||||
unlink($pidfile);
|
unlink($pidfile);
|
||||||
|
|
||||||
my $flag=$debugprotocol?"-v ":"";
|
$srvrname = servername_str($proto, $ipvnum, $idnum);
|
||||||
my $dir=$ENV{'srcdir'};
|
|
||||||
if($dir) {
|
|
||||||
$flag .= "-d \"$dir\" ";
|
|
||||||
}
|
|
||||||
|
|
||||||
my $cmd="$perl $srcdir/httpserver.pl -p $pidfile $fork$flag $port $ipv6";
|
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
|
||||||
my ($httppid, $pid2) =
|
|
||||||
startnew($cmd, $pidfile, 15, 0); # start the server in a new process
|
$flags .= "--fork " if($forkserver);
|
||||||
|
$flags .= "--verbose " if($debugprotocol);
|
||||||
|
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
||||||
|
$flags .= "--id $idnum " if($idnum > 1);
|
||||||
|
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
|
||||||
|
|
||||||
|
my $cmd = "$perl $srcdir/httpserver.pl $flags";
|
||||||
|
my ($httppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
|
||||||
|
|
||||||
if($httppid <= 0 || !kill(0, $httppid)) {
|
if($httppid <= 0 || !kill(0, $httppid)) {
|
||||||
# it is NOT alive
|
# it is NOT alive
|
||||||
@ -854,7 +858,7 @@ sub runhttpserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Server is up. Verify that we can speak to it.
|
# Server is up. Verify that we can speak to it.
|
||||||
my $pid3 = verifyserver("http", $ip, $port);
|
my $pid3 = verifyserver($proto, $ip, $port);
|
||||||
if(!$pid3) {
|
if(!$pid3) {
|
||||||
logmsg "RUN: $srvrname server failed verification\n";
|
logmsg "RUN: $srvrname server failed verification\n";
|
||||||
# failed to talk to it properly. Kill the server and return failure
|
# failed to talk to it properly. Kill the server and return failure
|
||||||
@ -1132,50 +1136,46 @@ sub runftpsserver {
|
|||||||
#
|
#
|
||||||
sub runtftpserver {
|
sub runtftpserver {
|
||||||
my ($id, $verbose, $ipv6) = @_;
|
my ($id, $verbose, $ipv6) = @_;
|
||||||
my $STATUS;
|
|
||||||
my $RUNNING;
|
|
||||||
my $port = $TFTPPORT;
|
my $port = $TFTPPORT;
|
||||||
# check for pidfile
|
my $ip = $HOSTIP;
|
||||||
my $pidfile = $TFTPPIDFILE;
|
|
||||||
my $ip=$HOSTIP;
|
|
||||||
my $cmd;
|
|
||||||
my $proto = 'tftp';
|
my $proto = 'tftp';
|
||||||
my $ipvnum = 4;
|
my $ipvnum = 4;
|
||||||
my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
|
my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
|
||||||
my $srvrname;
|
my $srvrname;
|
||||||
|
my $pidfile;
|
||||||
|
my $logfile;
|
||||||
|
my $flags = "";
|
||||||
|
|
||||||
if($ipv6) {
|
if($ipv6) {
|
||||||
# if IPv6, use a different setup
|
# if IPv6, use a different setup
|
||||||
$ipvnum = 6;
|
$ipvnum = 6;
|
||||||
$pidfile = $TFTP6PIDFILE;
|
|
||||||
$port = $TFTP6PORT;
|
$port = $TFTP6PORT;
|
||||||
$ip = $HOST6IP;
|
$ip = $HOST6IP;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$pidfile = server_pidfilename($proto, $ipvnum, $idnum);
|
||||||
|
|
||||||
# don't retry if the server doesn't work
|
# don't retry if the server doesn't work
|
||||||
if ($doesntrun{$pidfile}) {
|
if ($doesntrun{$pidfile}) {
|
||||||
return (0,0);
|
return (0,0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$srvrname = servername_str($proto, $ipvnum, $idnum);
|
|
||||||
|
|
||||||
my $pid = processexists($pidfile);
|
my $pid = processexists($pidfile);
|
||||||
if($pid > 0) {
|
if($pid > 0) {
|
||||||
stopserver($pid);
|
stopserver($pid);
|
||||||
}
|
}
|
||||||
unlink($pidfile);
|
unlink($pidfile);
|
||||||
|
|
||||||
# start our server:
|
$srvrname = servername_str($proto, $ipvnum, $idnum);
|
||||||
my $flag=$debugprotocol?"-v ":"";
|
|
||||||
$flag .= "--srcdir \"$srcdir\" ";
|
|
||||||
if($idnum > 1) {
|
|
||||||
$flag .="--id $idnum ";
|
|
||||||
}
|
|
||||||
if($ipv6) {
|
|
||||||
$flag .="--ipv6 ";
|
|
||||||
}
|
|
||||||
|
|
||||||
$cmd="./server/tftpd --pidfile $pidfile $flag --port $port";
|
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
|
||||||
|
|
||||||
|
$flags .= "--verbose " if($debugprotocol);
|
||||||
|
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
||||||
|
$flags .= "--id $idnum " if($idnum > 1);
|
||||||
|
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
|
||||||
|
|
||||||
|
my $cmd = "$perl $srcdir/tftpserver.pl $flags";
|
||||||
my ($tftppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
|
my ($tftppid, $pid2) = startnew($cmd, $pidfile, 15, 0);
|
||||||
|
|
||||||
if($tftppid <= 0 || !kill(0, $tftppid)) {
|
if($tftppid <= 0 || !kill(0, $tftppid)) {
|
||||||
@ -1188,7 +1188,7 @@ sub runtftpserver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Server is up. Verify that we can speak to it.
|
# Server is up. Verify that we can speak to it.
|
||||||
my $pid3 = verifyserver("tftp", $ip, $port);
|
my $pid3 = verifyserver($proto, $ip, $port);
|
||||||
if(!$pid3) {
|
if(!$pid3) {
|
||||||
logmsg "RUN: $srvrname server failed verification\n";
|
logmsg "RUN: $srvrname server failed verification\n";
|
||||||
# failed to talk to it properly. Kill the server and return failure
|
# failed to talk to it properly. Kill the server and return failure
|
||||||
|
110
tests/tftpserver.pl
Executable file
110
tests/tftpserver.pl
Executable file
@ -0,0 +1,110 @@
|
|||||||
|
#!/usr/bin/env perl
|
||||||
|
#***************************************************************************
|
||||||
|
# _ _ ____ _
|
||||||
|
# Project ___| | | | _ \| |
|
||||||
|
# / __| | | | |_) | |
|
||||||
|
# | (__| |_| | _ <| |___
|
||||||
|
# \___|\___/|_| \_\_____|
|
||||||
|
#
|
||||||
|
# Copyright (C) 1998 - 2010, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
|
#
|
||||||
|
# This software is licensed as described in the file COPYING, which
|
||||||
|
# you should have received as part of this distribution. The terms
|
||||||
|
# are also available at http://curl.haxx.se/docs/copyright.html.
|
||||||
|
#
|
||||||
|
# You may opt to use, copy, modify, merge, publish, distribute and/or sell
|
||||||
|
# copies of the Software, and permit persons to whom the Software is
|
||||||
|
# furnished to do so, under the terms of the COPYING file.
|
||||||
|
#
|
||||||
|
# This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
||||||
|
# KIND, either express or implied.
|
||||||
|
#
|
||||||
|
# $Id$
|
||||||
|
#***************************************************************************
|
||||||
|
|
||||||
|
BEGIN {
|
||||||
|
@INC=(@INC, $ENV{'srcdir'}, '.');
|
||||||
|
}
|
||||||
|
|
||||||
|
use strict;
|
||||||
|
use warnings;
|
||||||
|
|
||||||
|
use serverhelp qw(
|
||||||
|
server_pidfilename
|
||||||
|
server_logfilename
|
||||||
|
);
|
||||||
|
|
||||||
|
my $verbose = 0; # set to 1 for debugging
|
||||||
|
my $port = 8997; # just a default
|
||||||
|
my $ipvnum = 4; # default IP version of tftp server
|
||||||
|
my $idnum = 1; # dafault tftp server instance number
|
||||||
|
my $proto = 'tftp'; # protocol the tftp server speaks
|
||||||
|
my $pidfile; # tftp server pid file
|
||||||
|
my $logfile; # tftp server log file
|
||||||
|
my $srcdir;
|
||||||
|
my $fork;
|
||||||
|
|
||||||
|
my $flags = "";
|
||||||
|
my $path = '.';
|
||||||
|
my $logdir = $path .'/log';
|
||||||
|
|
||||||
|
while(@ARGV) {
|
||||||
|
if($ARGV[0] eq '--pidfile') {
|
||||||
|
if($ARGV[1]) {
|
||||||
|
$pidfile = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--logfile') {
|
||||||
|
if($ARGV[1]) {
|
||||||
|
$logfile = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--srcdir') {
|
||||||
|
if($ARGV[1]) {
|
||||||
|
$srcdir = $ARGV[1];
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--ipv4') {
|
||||||
|
$ipvnum = 4;
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--ipv6') {
|
||||||
|
$ipvnum = 6;
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--port') {
|
||||||
|
if($ARGV[1] =~ /^(\d+)$/) {
|
||||||
|
$port = $1;
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--id') {
|
||||||
|
if($ARGV[1] =~ /^(\d+)$/) {
|
||||||
|
$idnum = $1 if($1 > 0);
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
elsif($ARGV[0] eq '--verbose') {
|
||||||
|
$verbose = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
print STDERR "\nWarning: tftpserver.pl unknown parameter: $ARGV[0]\n";
|
||||||
|
}
|
||||||
|
shift @ARGV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!$srcdir) {
|
||||||
|
$srcdir = $ENV{'srcdir'} || '.';
|
||||||
|
}
|
||||||
|
if(!$pidfile) {
|
||||||
|
$pidfile = "$path/". server_pidfilename($proto, $ipvnum, $idnum);
|
||||||
|
}
|
||||||
|
if(!$logfile) {
|
||||||
|
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
|
||||||
|
}
|
||||||
|
|
||||||
|
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
|
||||||
|
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
|
||||||
|
|
||||||
|
exec("server/tftpd $flags");
|
Loading…
Reference in New Issue
Block a user