summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2004-12-11 21:41:00 +0000
committerDaniel Stenberg <daniel@haxx.se>2004-12-11 21:41:00 +0000
commit9b3b7ad22ea6d677e2e50f3a7d1c41214b49ae29 (patch)
treec73a2d417536cbaff96a99369fe7f063f8db90e2
parent1b8ac7c6b5c95a74ea49b2aa6d4b4650c401e95e (diff)
downloadcurl-9b3b7ad22ea6d677e2e50f3a7d1c41214b49ae29.tar.gz
HTTP IPv6 support added to the test suite
-rw-r--r--CHANGES20
-rw-r--r--RELEASE-NOTES2
-rw-r--r--tests/FILEFORMAT6
-rw-r--r--tests/data/Makefile.am3
-rw-r--r--tests/data/test12
-rw-r--r--tests/data/test24050
-rw-r--r--tests/data/test24144
-rw-r--r--tests/data/test24245
-rwxr-xr-xtests/httpserver.pl6
-rwxr-xr-xtests/runtests.pl88
-rw-r--r--tests/server/sws.c81
11 files changed, 308 insertions, 39 deletions
diff --git a/CHANGES b/CHANGES
index 9bed6d360..cf9c9d486 100644
--- a/CHANGES
+++ b/CHANGES
@@ -7,6 +7,26 @@
Changelog
+Daniel (11 December 2004)
+- Made the test suite HTTP server (sws) capable of using IPv6, and then
+ extended the test environment to support that and also added three test
+ cases (240, 241, 242) that run tests using IPv6. One of them uses a URL that
+ didn't work before the 10 dec fix by Kai Sommerfeld.
+
+- Made a failed file:// resume output an error message
+
+- Corrected the CURLE_BAD_DOWNLOAD_RESUME error message in lib/strerror.c
+
+- Dan Fandrich:
+
+ simplified and consolidated the SSL checks in configure and the usage of the
+ defines in lib/setup.h
+
+ provided a first libcurl.pc.in file for pkg-config (but the result is not
+ installed anywhere at this point)
+
+ extended the cross compile section in the docs/INSTALL file
+
Daniel (10 December 2004)
- When providing user name in the URL and a IPv6-style IP-address (like in
"ftp://user@[::1]/tmp"), the URL parser didn't get the host extracted
diff --git a/RELEASE-NOTES b/RELEASE-NOTES
index 7a8948083..4e70eb7f9 100644
--- a/RELEASE-NOTES
+++ b/RELEASE-NOTES
@@ -66,6 +66,6 @@ advice from friends like these:
Tim Sneddon, Ian Gulliver, Jean-Philippe Barrette-LaPierre, Jeff Phillips,
Wojciech Zwiefka, David Phillips, Reinout van Schouwen, Maurice Barnum,
Richard Atterer, Rene Bernhardt, Matt Veenstra, Bryan Henderson, Ton Voon,
- Kai Sommerfeld
+ Kai Sommerfeld, David Byron
Thanks! (and sorry if I forgot to mention someone)
diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT
index 07be4e087..c30ebcff9 100644
--- a/tests/FILEFORMAT
+++ b/tests/FILEFORMAT
@@ -77,10 +77,8 @@ reply is sent
<client>
<server>
-protocols as in 'http' 'ftp' etc. Give only one per line. Used for test cases
-500+ (at this point) to specify which servers the test case requires. In the
-future all test cases should use this. Makes us independent of the test
-case number.
+What server(s) this test case requires/uses:
+'http' 'ftp', 'https', 'ftps', 'http-ipv6'. Give only one per line.
</server>
<features>
diff --git a/tests/data/Makefile.am b/tests/data/Makefile.am
index a70db442c..b29e00c3d 100644
--- a/tests/data/Makefile.am
+++ b/tests/data/Makefile.am
@@ -29,7 +29,8 @@ EXTRA_DIST = test1 test108 test117 test127 test20 test27 test34 test46 \
test184 test185 test186 test187 test188 test189 test191 test192 \
test193 test194 test195 test196 test197 test198 test515 test516 \
test517 test518 test210 test211 test212 test220 test221 test222 \
- test223 test224 test206 test207 test208 test209 test213
+ test223 test224 test206 test207 test208 test209 test213 test240 \
+ test241 test242
# The following tests have been removed from the dist since they no longer
# work. We need to fix the test suite's FTPS server first, then bring them
diff --git a/tests/data/test1 b/tests/data/test1
index cd23462b5..7ddff50d1 100644
--- a/tests/data/test1
+++ b/tests/data/test1
@@ -24,7 +24,7 @@ Funny-head: yesyes
http
</server>
<name>
-simple HTTP GET
+HTTP GET
</name>
<command>
http://%HOSTIP:%HTTPPORT/1
diff --git a/tests/data/test240 b/tests/data/test240
new file mode 100644
index 000000000..e7617eec7
--- /dev/null
+++ b/tests/data/test240
@@ -0,0 +1,50 @@
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Last-Modified: Tue, 13 Jun 2000 12:10:00 GMT
+ETag: "21025-dc7-39462498"
+Accept-Ranges: bytes
+Content-Length: 6
+Connection: close
+Content-Type: text/html
+Funny-head: yesyes
+
+<foo>
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<features>
+ipv6
+</features>
+<server>
+http-ipv6
+</server>
+ <name>
+HTTP-IPv6 GET
+ </name>
+ <command>
+-g "http://%HOST6IP:%HTTP6PORT/240"
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:
+</strip>
+<protocol>
+GET /240 HTTP/1.1
+Host: %HOST6IP:%HTTP6PORT
+Pragma: no-cache
+Accept: */*
+
+</protocol>
+</verify>
diff --git a/tests/data/test241 b/tests/data/test241
new file mode 100644
index 000000000..4f3d64b66
--- /dev/null
+++ b/tests/data/test241
@@ -0,0 +1,44 @@
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Server: test-server/fake
+Content-Length: 6
+
+hello
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<features>
+ipv6
+</features>
+<server>
+http-ipv6
+</server>
+ <name>
+HTTP-IPv6 GET (using ip6-localhost)
+ </name>
+ <command>
+-g "http://ip6-localhost:%HTTP6PORT/241"
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:
+</strip>
+<protocol>
+GET /241 HTTP/1.1
+Host: ip6-localhost:%HTTP6PORT
+Pragma: no-cache
+Accept: */*
+
+</protocol>
+</verify>
diff --git a/tests/data/test242 b/tests/data/test242
new file mode 100644
index 000000000..205f4de4a
--- /dev/null
+++ b/tests/data/test242
@@ -0,0 +1,45 @@
+#
+# Server-side
+<reply>
+<data>
+HTTP/1.1 200 OK
+Date: Thu, 09 Nov 2010 14:49:00 GMT
+Content-Length: 6
+Connection: close
+
+hello
+</data>
+</reply>
+
+#
+# Client-side
+<client>
+<features>
+ipv6
+</features>
+<server>
+http-ipv6
+</server>
+ <name>
+HTTP-IPv6 GET with username+password in URL
+ </name>
+ <command>
+-g "http://foobar:barfoo@%HOST6IP:%HTTP6PORT/242"
+</command>
+</client>
+
+#
+# Verify data after the test has been "shot"
+<verify>
+<strip>
+^User-Agent:
+</strip>
+<protocol>
+GET /242 HTTP/1.1
+Authorization: Basic Zm9vYmFyOmJhcmZvbw==
+Host: %HOST6IP:%HTTP6PORT
+Pragma: no-cache
+Accept: */*
+
+</protocol>
+</verify>
diff --git a/tests/httpserver.pl b/tests/httpserver.pl
index d458a35c2..bdd21f9a8 100755
--- a/tests/httpserver.pl
+++ b/tests/httpserver.pl
@@ -6,6 +6,7 @@ my $verbose=0; # set to 1 for debugging
my $dir=".";
my $port = 8999; # just a default
+my $ipv6;
do {
if($ARGV[0] eq "-v") {
$verbose=1;
@@ -17,6 +18,9 @@ do {
elsif($ARGV[0] =~ /^(\d+)$/) {
$port = $1;
}
+ elsif($ARGV[0] =~ /^ipv6/i) {
+ $ipv6="--ipv6 ";
+ }
} while(shift @ARGV);
-exec("server/sws $port $dir");
+exec("server/sws $ipv6$port $dir");
diff --git a/tests/runtests.pl b/tests/runtests.pl
index dfc065dcf..2a03117e8 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -32,10 +32,12 @@ require "getpart.pm"; # array functions
my $srcdir = $ENV{'srcdir'} || '.';
my $HOSTIP="127.0.0.1";
+my $HOST6IP="[::1]";
my $base = 8990; # base port number
my $HTTPPORT; # HTTP server port
+my $HTTP6PORT; # HTTP IPv6 server port
my $HTTPSPORT; # HTTPS server port
my $FTPPORT; # FTP server port
my $FTPSPORT; # FTPS server port
@@ -61,6 +63,7 @@ my $TESTCASES="all";
#
my $HTTPPIDFILE=".http.pid";
+my $HTTP6PIDFILE=".http6.pid";
my $HTTPSPIDFILE=".https.pid";
my $FTPPIDFILE=".ftp.pid";
my $FTPSPIDFILE=".ftps.pid";
@@ -95,6 +98,7 @@ my $gdb = checkcmd("gdb");
my $ssl_version; # set if libcurl is built with SSL support
my $large_file; # set if libcurl is built with large file support
my $has_idn; # set if libcurl is built with IDN support
+my $http_ipv6; # set if HTTP server has IPv6 support
my $has_ipv6; # set if libcurl is built with IPv6 support
my $has_libz; # set if libcurl is built with libz support
my $has_getrlimit; # set if system has getrlimit()
@@ -325,14 +329,28 @@ sub checkserver {
# test server on the test-port!
#
sub runhttpserver {
- my $verbose = $_[0];
+ my ($verbose, $ipv6) = @_;
my $RUNNING;
my $pid;
- $pid = checkserver ($HTTPPIDFILE);
+ my $pidfile = $HTTPPIDFILE;
+ my $port = $HTTPPORT;
+ my $ip = $HOSTIP;
+ my $nameext;
+
+ if($ipv6) {
+ # if IPv6, use a different setup
+ $pidfile = $HTTP6PIDFILE;
+ $port = $HTTP6PORT;
+ $ip = $HOST6IP;
+ $nameext="-ipv6";
+ }
+
+
+ $pid = checkserver($pidfile);
# verify if our/any server is running on this port
- my $cmd = "$CURL -o log/verifiedserver http://$HOSTIP:$HTTPPORT/verifiedserver 2>/dev/null";
+ my $cmd = "$CURL -o log/verifiedserver -g \"http://$ip:$port/verifiedserver\" 2>/dev/null";
print "CMD; $cmd\n" if ($verbose);
my $res = system($cmd);
@@ -350,15 +368,15 @@ sub runhttpserver {
$pid = 0+$1;
}
elsif($data || ($res != 7)) {
- print "RUN: Unknown HTTP server is running on port $HTTPPORT\n";
+ print "RUN: Unknown server is running on port $port\n";
return -2;
}
if($pid > 0) {
my $res = kill (9, $pid); # die!
if(!$res) {
- print "RUN: Failed to kill test HTTP server, do it manually and",
- " restart the tests.\n";
+ print "RUN: Failed to kill test HTTP$nameext server, do it ",
+ "manually and restart the tests.\n";
exit;
}
sleep(1);
@@ -369,7 +387,7 @@ sub runhttpserver {
if($dir) {
$flag .= "-d \"$dir\" ";
}
- $cmd="$perl $srcdir/httpserver.pl $flag $HTTPPORT &";
+ $cmd="$perl $srcdir/httpserver.pl $flag $port $ipv6 &";
system($cmd);
if($verbose) {
print "CMD: $cmd\n";
@@ -378,7 +396,7 @@ sub runhttpserver {
my $verified;
for(1 .. 10) {
# verify that our server is up and running:
- my $data=`$CURL --silent $HOSTIP:$HTTPPORT/verifiedserver 2>/dev/null`;
+ my $data=`$CURL --silent -g \"$ip:$port/verifiedserver\" 2>/dev/null`;
if ( $data =~ /WE ROOLZ: (\d+)/ ) {
$pid = 0+$1;
@@ -387,19 +405,19 @@ sub runhttpserver {
}
else {
if($verbose) {
- print STDERR "RUN: Retrying HTTP server existence in 3 sec\n";
+ print STDERR "RUN: Retrying HTTP$nameext server existence in 3 sec\n";
}
sleep(3);
next;
}
}
if(!$verified) {
- print STDERR "RUN: failed to start our HTTP server\n";
+ print STDERR "RUN: failed to start our HTTP$nameext server\n";
return -1;
}
if($verbose) {
- print "RUN: HTTP server is now verified to be our server\n";
+ print "RUN: HTTP$nameext server is now verified to be our server\n";
}
return $pid;
@@ -783,6 +801,15 @@ sub checkcurl {
close(CONF);
}
+ if($has_ipv6) {
+ # client has ipv6 support, check that the HTTP server has it!
+ my @sws = `server/sws --version`;
+ if($sws[0] =~ /IPv6/) {
+ # HTTP server has ipv6 support!
+ $http_ipv6 = 1;
+ }
+ }
+
if(!$curl_debug && $torture) {
die "can't run torture tests since curl was not build with debug";
}
@@ -797,15 +824,20 @@ sub checkcurl {
"* Host: $hostname",
"* System: $hosttype";
- printf("* Server SSL: %s\n", $stunnel?"ON":"OFF");
- printf("* libcurl SSL: %s\n", $ssl_version?"ON":"OFF");
- printf("* libcurl debug: %s\n", $curl_debug?"ON":"OFF");
- printf("* valgrind: %s\n", $valgrind?"ON":"OFF");
- printf("* HTTP on port: %d\n", $HTTPPORT);
- printf("* FTP on port: %d\n", $FTPPORT);
+ printf("* Server SSL: %s\n", $stunnel?"ON":"OFF");
+ printf("* libcurl SSL: %s\n", $ssl_version?"ON":"OFF");
+ printf("* libcurl debug: %s\n", $curl_debug?"ON":"OFF");
+ printf("* valgrind: %s\n", $valgrind?"ON":"OFF");
+ printf("* HTTP IPv6 %s\n", $http_ipv6?"ON":"OFF");
+
+ printf("* HTTP port: %d\n", $HTTPPORT);
+ printf("* FTP port: %d\n", $FTPPORT);
if($stunnel) {
- printf("* FTPS on port: %d\n", $FTPSPORT);
- printf("* HTTPS on port: %d\n", $HTTPSPORT);
+ printf("* FTPS port: %d\n", $FTPSPORT);
+ printf("* HTTPS port: %d\n", $HTTPSPORT);
+ }
+ if($http_ipv6) {
+ printf("* HTTP IPv6 port: %d\n", $HTTP6PORT);
}
print "***************************************** \n";
}
@@ -818,6 +850,8 @@ sub subVariables {
my ($thing) = @_;
$$thing =~ s/%HOSTIP/$HOSTIP/g;
$$thing =~ s/%HTTPPORT/$HTTPPORT/g;
+ $$thing =~ s/%HOST6IP/$HOST6IP/g;
+ $$thing =~ s/%HTTP6PORT/$HTTP6PORT/g;
$$thing =~ s/%HTTPSPORT/$HTTPSPORT/g;
$$thing =~ s/%FTPPORT/$FTPPORT/g;
$$thing =~ s/%FTPSPORT/$FTPSPORT/g;
@@ -1116,7 +1150,7 @@ sub singletest {
}
if($valgrind) {
- $CMDLINE = "valgrind ".$valgrind_tool."--leak-check=yes --logfile=log/valgrind$testnum -q $CMDLINE";
+ $CMDLINE = "valgrind ".$valgrind_tool."--leak-check=yes --logfile=log/valgrind$testnum $CMDLINE";
}
$CMDLINE .= "$cmdargs >>$STDOUT 2>>$STDERR";
@@ -1439,7 +1473,7 @@ sub startservers {
my $pid;
for(@what) {
my $what = lc($_);
- $what =~ s/[^a-z]//g;
+ $what =~ s/[^a-z0-9-]//g;
if($what eq "ftp") {
if(!$run{'ftp'}) {
$pid = runftpserver($verbose);
@@ -1460,6 +1494,16 @@ sub startservers {
$run{'http'}=$pid;
}
}
+ elsif($what eq "http-ipv6") {
+ if(!$run{'http-ipv6'}) {
+ $pid = runhttpserver($verbose, "IPv6");
+ if($pid <= 0) {
+ return 2; # error starting
+ }
+ printf ("* pid http-ipv6 => %-5d\n", $pid) if($verbose);
+ $run{'http-ipv6'}=$pid;
+ }
+ }
elsif($what eq "ftps") {
if(!$stunnel || !$ssl_version) {
# we can't run ftps tests without stunnel
@@ -1671,6 +1715,8 @@ $HTTPPORT = $base + 0; # HTTP server port
$HTTPSPORT = $base + 1; # HTTPS server port
$FTPPORT = $base + 2; # FTP server port
$FTPSPORT = $base + 3; # FTPS server port
+$HTTP6PORT = $base + 4; # HTTP IPv6 server port (different IP protocol
+ # but we follow the same port scheme anyway)
#######################################################################
# Output curl version and host info being tested
diff --git a/tests/server/sws.c b/tests/server/sws.c
index 8503cf2fb..269d0806c 100644
--- a/tests/server/sws.c
+++ b/tests/server/sws.c
@@ -58,6 +58,10 @@
#include "curlx.h" /* from the private lib dir */
#include "getpart.h"
+#ifdef ENABLE_IPV6
+#define SWS_IPV6
+#endif
+
#ifndef FALSE
#define FALSE 0
#endif
@@ -709,19 +713,46 @@ static void win32_cleanup(void)
}
#endif
+char use_ipv6=FALSE;
+
int main(int argc, char *argv[])
{
struct sockaddr_in me;
+#ifdef ENABLE_IPV6
+ struct sockaddr_in6 me6;
+#endif /* ENABLE_IPV6 */
int sock, msgsock, flag;
unsigned short port = DEFAULT_PORT;
FILE *pidfile;
struct httprequest req;
+ int rc;
if(argc>1) {
- port = (unsigned short)atoi(argv[1]);
+ int arg=1;
+ if(!strcmp("--version", argv[arg])) {
+ printf("sws IPv4%s\n",
+#ifdef ENABLE_IPV6
+ "/IPv6"
+#else
+ ""
+#endif
+ );
+ return 0;
+ }
+ if(!strcmp("--ipv6", argv[arg])) {
+#ifdef ENABLE_IPV6
+ use_ipv6=TRUE;
+#endif
+ arg++;
+ }
+ if(argc>arg) {
+
+ if(atoi(argv[arg]))
+ port = (unsigned short)atoi(argv[arg++]);
+
+ if(argc>arg)
+ path = argv[arg];
- if(argc>2) {
- path = argv[2];
}
}
@@ -740,10 +771,18 @@ int main(int argc, char *argv[])
#endif
#endif
- sock = socket(AF_INET, SOCK_STREAM, 0);
+#ifdef ENABLE_IPV6
+ if(!use_ipv6)
+#endif
+ sock = socket(AF_INET, SOCK_STREAM, 0);
+#ifdef ENABLE_IPV6
+ else
+ sock = socket(AF_INET6, SOCK_STREAM, 0);
+#endif
+
if (sock < 0) {
perror("opening stream socket");
- logmsg("Error opening socket -- aborting\n");
+ logmsg("Error opening socket");
exit(1);
}
@@ -754,12 +793,26 @@ int main(int argc, char *argv[])
perror("setsockopt(SO_REUSEADDR)");
}
- me.sin_family = AF_INET;
- me.sin_addr.s_addr = INADDR_ANY;
- me.sin_port = htons(port);
- if (bind(sock, (struct sockaddr *) &me, sizeof me) < 0) {
+#ifdef ENABLE_IPV6
+ if(!use_ipv6) {
+#endif
+ me.sin_family = AF_INET;
+ me.sin_addr.s_addr = INADDR_ANY;
+ me.sin_port = htons(port);
+ rc = bind(sock, (struct sockaddr *) &me, sizeof(me));
+#ifdef ENABLE_IPV6
+ }
+ else {
+ memset(&me6, 0, sizeof(struct sockaddr_in6));
+ me6.sin6_family = AF_INET6;
+ me6.sin6_addr = in6addr_any;
+ me6.sin6_port = htons(port);
+ rc = bind(sock, (struct sockaddr *) &me6, sizeof(me6));
+ }
+#endif /* ENABLE_IPV6 */
+ if(rc < 0) {
perror("binding stream socket");
- logmsg("Error binding socket -- aborting\n");
+ logmsg("Error binding socket");
exit(1);
}
@@ -771,6 +824,14 @@ int main(int argc, char *argv[])
else
fprintf(stderr, "Couldn't write pid file\n");
+ logmsg("Running IPv%d version",
+#ifdef ENABLE_IPV6
+ (use_ipv6?6:4)
+#else
+ 4
+#endif
+ );
+
/* start accepting connections */
listen(sock, 5);