aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Stenberg <daniel@haxx.se>2010-08-25 00:47:45 +0200
committerDaniel Stenberg <daniel@haxx.se>2010-08-25 14:21:25 +0200
commitecb3fe63d782dafcd6bacf834f964414b087a793 (patch)
treec302839a2e8630aa91512da6bc956f9e4f3b95da
parent6ed72fd7fa138e427ce51a95832ce9b398f67440 (diff)
gopher tests: use sws and adjusted to more standard style
-rw-r--r--tests/data/test12008
-rw-r--r--tests/data/test12018
-rw-r--r--tests/data/test12028
-rw-r--r--tests/data/test12038
-rwxr-xr-xtests/httpserver.pl5
-rwxr-xr-xtests/runtests.pl55
6 files changed, 56 insertions, 36 deletions
diff --git a/tests/data/test1200 b/tests/data/test1200
index 94327201a..4e15ec9dc 100644
--- a/tests/data/test1200
+++ b/tests/data/test1200
@@ -10,11 +10,11 @@ INDEX
#
# Server-side
<reply>
-<datacheck>
+<data>
iMenu results error.host 1
0Selector /bar bar.foo.invalid 70
.
-</datacheck>
+</data>
</reply>
# Client-side
@@ -26,7 +26,7 @@ gopher
Gopher index
</name>
<command>
-gopher://%HOSTIP:%GOPHERPORT
+gopher://%HOSTIP:%GOPHERPORT/1/1200
</command>
</client>
@@ -34,7 +34,7 @@ gopher://%HOSTIP:%GOPHERPORT
# Verify data after the test has been "shot"
<verify>
<protocol>
-
+/1200
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1201 b/tests/data/test1201
index bb3ccc5ef..ae5ebd11e 100644
--- a/tests/data/test1201
+++ b/tests/data/test1201
@@ -10,11 +10,11 @@ SELECTOR
#
# Server-side
<reply>
-<datacheck>
+<data>
iMenu results error.host 1
0Selector /selector/SELECTOR /bar bar.foo.invalid 70
.
-</datacheck>
+</data>
</reply>
# Client-side
@@ -26,7 +26,7 @@ gopher
Gopher selector
</name>
<command>
-gopher://%HOSTIP:%GOPHERPORT/1/selector/SELECTOR
+gopher://%HOSTIP:%GOPHERPORT/1/selector/SELECTOR/1201
</command>
</client>
@@ -34,7 +34,7 @@ gopher://%HOSTIP:%GOPHERPORT/1/selector/SELECTOR
# Verify data after the test has been "shot"
<verify>
<protocol>
-/selector/SELECTOR
+/selector/SELECTOR/1201
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1202 b/tests/data/test1202
index 8b8502d4b..253d42c73 100644
--- a/tests/data/test1202
+++ b/tests/data/test1202
@@ -10,12 +10,12 @@ QUERY
#
# Server-side
<reply>
-<datacheck>
+<data>
iSearch results error.host 1
0Query query succeeded /foo foo.bar.invalid 70
0Selector /the/search/engine /bar bar.foo.invalid 70
.
-</datacheck>
+</data>
</reply>
# Client-side
@@ -27,7 +27,7 @@ gopher
Gopher query
</name>
<command>
-gopher://%HOSTIP:%GOPHERPORT/7/the/search/engine?query%20succeeded
+gopher://%HOSTIP:%GOPHERPORT/7/the/search/engine?query%20succeeded/1202
</command>
</client>
@@ -35,7 +35,7 @@ gopher://%HOSTIP:%GOPHERPORT/7/the/search/engine?query%20succeeded
# Verify data after the test has been "shot"
<verify>
<protocol>
-/the/search/engine query succeeded
+/the/search/engine query succeeded/1202
</protocol>
</verify>
</testcase>
diff --git a/tests/data/test1203 b/tests/data/test1203
index c639512b2..318cd01b4 100644
--- a/tests/data/test1203
+++ b/tests/data/test1203
@@ -11,11 +11,11 @@ INDEX
#
# Server-side
<reply>
-<datacheck>
+<data>
iMenu results error.host 1
0Selector /bar bar.foo.invalid 70
.
-</datacheck>
+</data>
</reply>
# Client-side
@@ -27,7 +27,7 @@ gopher-ipv6
Gopher IPv6 index
</name>
<command>
--g "gopher://%HOSTIP:%GOPHER6PORT"
+-g "gopher://%HOSTIP:%GOPHER6PORT/1/moo/1203"
</command>
</client>
@@ -35,7 +35,7 @@ Gopher IPv6 index
# Verify data after the test has been "shot"
<verify>
<protocol>
-
+/moo/1203
</protocol>
</verify>
</testcase>
diff --git a/tests/httpserver.pl b/tests/httpserver.pl
index 98d62cd0e..37161f061 100755
--- a/tests/httpserver.pl
+++ b/tests/httpserver.pl
@@ -42,6 +42,7 @@ my $pidfile; # http server pid file
my $logfile; # http server log file
my $srcdir;
my $fork;
+my $gopher = 0;
my $flags = "";
my $path = '.';
@@ -72,6 +73,9 @@ while(@ARGV) {
elsif($ARGV[0] eq '--ipv6') {
$ipvnum = 6;
}
+ elsif($ARGV[0] eq '--gopher') {
+ $gopher = 1;
+ }
elsif($ARGV[0] eq '--port') {
if($ARGV[1] =~ /^(\d+)$/) {
$port = $1;
@@ -106,6 +110,7 @@ if(!$logfile) {
$logfile = server_logfilename($logdir, $proto, $ipvnum, $idnum);
}
+$flags .= "--gopher " if($gopher);
$flags .= "--fork " if(defined($fork));
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--ipv$ipvnum --port $port --srcdir \"$srcdir\"";
diff --git a/tests/runtests.pl b/tests/runtests.pl
index a3c402ebe..608875b6e 100755
--- a/tests/runtests.pl
+++ b/tests/runtests.pl
@@ -676,6 +676,7 @@ sub verifyhttp {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
my $server = servername_id($proto, $ipvnum, $idnum);
my $pid = 0;
+ my $bonus;
my $verifyout = "$LOGDIR/".
servername_canon($proto, $ipvnum, $idnum) .'_verify.out';
@@ -685,13 +686,18 @@ sub verifyhttp {
servername_canon($proto, $ipvnum, $idnum) .'_verify.log';
unlink($verifylog) if(-f $verifylog);
+ if($proto eq "gopher") {
+ # gopher is funny
+ $bonus="1/";
+ }
+
my $flags = "--max-time $server_response_maxtime ";
$flags .= "--output $verifyout ";
$flags .= "--silent ";
$flags .= "--verbose ";
$flags .= "--globoff ";
$flags .= "--insecure " if($proto eq 'https');
- $flags .= "\"$proto://$ip:$port/verifiedserver\"";
+ $flags .= "\"$proto://$ip:$port/${bonus}verifiedserver\"";
my $cmd = "$VCURL $flags 2>$verifylog";
@@ -732,8 +738,8 @@ sub verifyhttp {
logmsg "RUN: failed to resolve host ($proto://$ip:$port/verifiedserver)\n";
return -1;
}
- elsif($data || ($res != 7)) {
- logmsg "RUN: Unknown server on our $server port: $port\n";
+ elsif($data || ($res && ($res != 7))) {
+ logmsg "RUN: Unknown server on our $server port: $port ($res)\n";
return -1;
}
return $pid;
@@ -992,7 +998,7 @@ my %protofunc = ('http' => \&verifyhttp,
'tftp' => \&verifyftp,
'ssh' => \&verifyssh,
'socks' => \&verifysocks,
- 'gopher' => \&verifyftp);
+ 'gopher' => \&verifyhttp);
sub verifyserver {
my ($proto, $ipvnum, $idnum, $ip, $port) = @_;
@@ -1023,10 +1029,8 @@ sub verifyserver {
# start the http server
#
sub runhttpserver {
- my ($verbose, $ipv6) = @_;
- my $port = $HTTPPORT;
+ my ($proto, $verbose, $ipv6, $port) = @_;
my $ip = $HOSTIP;
- my $proto = 'http';
my $ipvnum = 4;
my $idnum = 1;
my $server;
@@ -1035,10 +1039,10 @@ sub runhttpserver {
my $logfile;
my $flags = "";
+
if($ipv6) {
# if IPv6, use a different setup
$ipvnum = 6;
- $port = $HTTP6PORT;
$ip = $HOST6IP;
}
@@ -1062,6 +1066,7 @@ sub runhttpserver {
$logfile = server_logfilename($LOGDIR, $proto, $ipvnum, $idnum);
$flags .= "--fork " if($forkserver);
+ $flags .= "--gopher " if($proto eq "gopher");
$flags .= "--verbose " if($debugprotocol);
$flags .= "--pidfile \"$pidfile\" --logfile \"$logfile\" ";
$flags .= "--id $idnum " if($idnum > 1);
@@ -1184,7 +1189,7 @@ sub runhttpsserver {
}
#######################################################################
-# start the pingpong server (FTP, POP3, IMAP, SMTP, GOPHER)
+# start the pingpong server (FTP, POP3, IMAP, SMTP)
#
sub runpingpongserver {
my ($proto, $id, $verbose, $ipv6) = @_;
@@ -1215,9 +1220,6 @@ sub runpingpongserver {
elsif($proto eq "smtp") {
$port = ($ipvnum==6) ? $SMTP6PORT : $SMTPPORT;
}
- elsif($proto eq "gopher") {
- $port = ($ipvnum==6) ? $GOPHER6PORT : $GOPHERPORT;
- }
else {
print STDERR "Unsupported protocol $proto!!\n";
return 0;
@@ -2041,15 +2043,14 @@ sub checksystem {
if($sws[0] =~ /IPv6/) {
# HTTP server has ipv6 support!
$http_ipv6 = 1;
+ $gopher_ipv6 = 1;
}
# check if the FTP server has it!
@sws = `server/sockfilt --version`;
if($sws[0] =~ /IPv6/) {
# FTP server has ipv6 support!
- # and since the Gopher server descends from it, we have it too!
$ftp_ipv6 = 1;
- $gopher_ipv6 = 1;
}
}
@@ -3227,7 +3228,6 @@ sub startservers {
if(($what eq "pop3") ||
($what eq "ftp") ||
($what eq "imap") ||
- ($what eq "gopher") ||
($what eq "smtp")) {
if(!$run{$what}) {
($pid, $pid2) = runpingpongserver($what, "", $verbose);
@@ -3259,20 +3259,33 @@ sub startservers {
$run{'ftp-ipv6'}="$pid $pid2";
}
}
+ elsif($what eq "gopher") {
+ if(!$run{'gopher'}) {
+ ($pid, $pid2) = runhttpserver("gopher", $verbose, 0,
+ $GOPHERPORT);
+ if($pid <= 0) {
+ return "failed starting GOPHER server";
+ }
+ printf ("* pid gopher => %d %d\n", $pid, $pid2) if($verbose);
+ $run{'gopher'}="$pid $pid2";
+ }
+ }
elsif($what eq "gopher-ipv6") {
if(!$run{'gopher-ipv6'}) {
- ($pid, $pid2) = runpingpongserver("gopher","",$verbose,"ipv6");
+ ($pid, $pid2) = runhttpserver("gopher", $verbose, "ipv6",
+ $GOPHER6PORT);
if($pid <= 0) {
return "failed starting GOPHER-IPv6 server";
}
logmsg sprintf("* pid gopher-ipv6 => %d %d\n", $pid,
- $pid2) if($verbose);
+ $pid2) if($verbose);
$run{'gopher-ipv6'}="$pid $pid2";
}
}
elsif($what eq "http") {
if(!$run{'http'}) {
- ($pid, $pid2) = runhttpserver($verbose);
+ ($pid, $pid2) = runhttpserver("http", $verbose, 0,
+ $HTTPPORT);
if($pid <= 0) {
return "failed starting HTTP server";
}
@@ -3282,7 +3295,8 @@ sub startservers {
}
elsif($what eq "http-ipv6") {
if(!$run{'http-ipv6'}) {
- ($pid, $pid2) = runhttpserver($verbose, "IPv6");
+ ($pid, $pid2) = runhttpserver("http", $verbose, "IPv6",
+ $HTTP6PORT);
if($pid <= 0) {
return "failed starting HTTP-IPv6 server";
}
@@ -3361,7 +3375,8 @@ sub startservers {
stopserver('https');
}
if(!$run{'http'}) {
- ($pid, $pid2) = runhttpserver($verbose);
+ ($pid, $pid2) = runhttpserver("http", $verbose, 0,
+ $HTTPPORT);
if($pid <= 0) {
return "failed starting HTTP server";
}