aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Makefile.am2
-rwxr-xr-xtests/httpserver.pl120
-rwxr-xr-xtests/runtests.pl70
-rwxr-xr-xtests/tftpserver.pl110
4 files changed, 241 insertions, 61 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index ba8da787c..e5fed714c 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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 \
sshserver.pl sshhelp.pm testcurl.1 runtests.1 $(HTMLPAGES) $(PDFPAGES) \
CMakeLists.txt certs/scripts/*.sh certs/Server* certs/EdelCurlRoot* \
- serverhelp.pm
+ serverhelp.pm tftpserver.pl
SUBDIRS = data server libtest
diff --git a/tests/httpserver.pl b/tests/httpserver.pl
index 22b79159b..ae913e780 100755
--- a/tests/httpserver.pl
+++ b/tests/httpserver.pl
@@ -1,44 +1,114 @@
#!/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;
-my $verbose=0; # set to 1 for debugging
+use serverhelp qw(
+ server_pidfilename
+ server_logfilename
+ );
-my $dir=".";
-my $port = 8999; # just a default
-my $ipv6;
-my $pid=".http.pid"; # name of the pidfile
+my $verbose = 0; # set to 1 for debugging
+my $port = 8990; # just a default
+my $ipvnum = 4; # default IP version of http server
+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 $flags = "";
+my $path = '.';
+my $logdir = $path .'/log';
-do {
- if($ARGV[0] eq "-v") {
- $verbose=1;
+while(@ARGV) {
+ if($ARGV[0] eq '--pidfile') {
+ if($ARGV[1]) {
+ $pidfile = $ARGV[1];
+ shift @ARGV;
+ }
}
- elsif($ARGV[0] eq "-d") {
- $dir=$ARGV[1];
- shift @ARGV;
+ elsif($ARGV[0] eq '--logfile') {
+ if($ARGV[1]) {
+ $logfile = $ARGV[1];
+ shift @ARGV;
+ }
}
- elsif($ARGV[0] eq "-p") {
- $pid=$ARGV[1];
- shift @ARGV;
+ elsif($ARGV[0] eq '--srcdir') {
+ if($ARGV[1]) {
+ $srcdir = $ARGV[1];
+ shift @ARGV;
+ }
}
- elsif($ARGV[0] eq "--fork") {
- $fork = $ARGV[0];
- 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] =~ /^(\d+)$/) {
- $port = $1;
+ elsif($ARGV[0] eq '--id') {
+ if($ARGV[1] =~ /^(\d+)$/) {
+ $idnum = $1 if($1 > 0);
+ shift @ARGV;
+ }
}
- elsif($ARGV[0] =~ /^ipv6/i) {
- $ipv6="--ipv6 ";
+ elsif($ARGV[0] eq '--verbose') {
+ $verbose = 1;
}
-} while(shift @ARGV);
+ elsif($ARGV[0] eq '--fork') {
+ $fork = $ARGV[0];
+ }
+ else {
+ print STDERR "\nWarning: httpserver.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 \"$pid\" ";
$flags .= "--fork " if(defined($fork));
-$flags .= "--ipv6 " if(defined($ipv6));
-$flags .= "--port $port --srcdir \"$dir\"";
+$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
+$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
exec("server/sws $flags");
diff --git a/tests/runtests.pl b/tests/runtests.pl
index 3f333063c..20ad732dd 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -73,6 +73,8 @@ use Cwd;
# Subs imported from serverhelp module
use serverhelp qw(
servername_str
+ server_pidfilename
+ server_logfilename
);
# Variables and subs imported from sshhelp module
@@ -803,46 +805,48 @@ sub verifyserver {
#
sub runhttpserver {
my ($verbose, $ipv6) = @_;
- my $RUNNING;
- my $pidfile = $HTTPPIDFILE;
my $port = $HTTPPORT;
my $ip = $HOSTIP;
my $proto = 'http';
my $ipvnum = 4;
my $idnum = 1;
my $srvrname;
- my $fork = $forkserver?"--fork":"";
+ my $pidfile;
+ my $logfile;
+ my $flags = "";
if($ipv6) {
# if IPv6, use a different setup
$ipvnum = 6;
- $pidfile = $HTTP6PIDFILE;
$port = $HTTP6PORT;
$ip = $HOST6IP;
}
+ $pidfile = server_pidfilename($proto, $ipvnum, $idnum);
+
# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}
- $srvrname = servername_str($proto, $ipvnum, $idnum);
-
my $pid = processexists($pidfile);
if($pid > 0) {
stopserver($pid);
}
unlink($pidfile);
- my $flag=$debugprotocol?"-v ":"";
- my $dir=$ENV{'srcdir'};
- if($dir) {
- $flag .= "-d \"$dir\" ";
- }
+ $srvrname = servername_str($proto, $ipvnum, $idnum);
- my $cmd="$perl $srcdir/httpserver.pl -p $pidfile $fork$flag $port $ipv6";
- my ($httppid, $pid2) =
- startnew($cmd, $pidfile, 15, 0); # start the server in a new process
+ $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
+
+ $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)) {
# it is NOT alive
@@ -854,7 +858,7 @@ sub runhttpserver {
}
# Server is up. Verify that we can speak to it.
- my $pid3 = verifyserver("http", $ip, $port);
+ my $pid3 = verifyserver($proto, $ip, $port);
if(!$pid3) {
logmsg "RUN: $srvrname server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
@@ -1132,50 +1136,46 @@ sub runftpsserver {
#
sub runtftpserver {
my ($id, $verbose, $ipv6) = @_;
- my $STATUS;
- my $RUNNING;
my $port = $TFTPPORT;
- # check for pidfile
- my $pidfile = $TFTPPIDFILE;
- my $ip=$HOSTIP;
- my $cmd;
+ my $ip = $HOSTIP;
my $proto = 'tftp';
my $ipvnum = 4;
my $idnum = ($id && ($id =~ /^(\d+)$/) && ($id > 1)) ? $id : 1;
my $srvrname;
+ my $pidfile;
+ my $logfile;
+ my $flags = "";
if($ipv6) {
# if IPv6, use a different setup
$ipvnum = 6;
- $pidfile = $TFTP6PIDFILE;
$port = $TFTP6PORT;
$ip = $HOST6IP;
}
+ $pidfile = server_pidfilename($proto, $ipvnum, $idnum);
+
# don't retry if the server doesn't work
if ($doesntrun{$pidfile}) {
return (0,0);
}
- $srvrname = servername_str($proto, $ipvnum, $idnum);
-
my $pid = processexists($pidfile);
if($pid > 0) {
stopserver($pid);
}
unlink($pidfile);
- # start our server:
- my $flag=$debugprotocol?"-v ":"";
- $flag .= "--srcdir \"$srcdir\" ";
- if($idnum > 1) {
- $flag .="--id $idnum ";
- }
- if($ipv6) {
- $flag .="--ipv6 ";
- }
+ $srvrname = servername_str($proto, $ipvnum, $idnum);
+
+ $logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
- $cmd="./server/tftpd --pidfile $pidfile $flag --port $port";
+ $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);
if($tftppid <= 0 || !kill(0, $tftppid)) {
@@ -1188,7 +1188,7 @@ sub runtftpserver {
}
# Server is up. Verify that we can speak to it.
- my $pid3 = verifyserver("tftp", $ip, $port);
+ my $pid3 = verifyserver($proto, $ip, $port);
if(!$pid3) {
logmsg "RUN: $srvrname server failed verification\n";
# failed to talk to it properly. Kill the server and return failure
diff --git a/tests/tftpserver.pl b/tests/tftpserver.pl
new file mode 100755
index 000000000..78dc99c22
--- /dev/null
+++ b/tests/tftpserver.pl
@@ -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");