mirror of
https://github.com/moparisthebest/curl
synced 2024-12-21 23:58:49 -05:00
gopher tests: use sws and adjusted to more standard style
This commit is contained in:
parent
6ed72fd7fa
commit
ecb3fe63d7
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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>
|
||||
|
@ -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\"";
|
||||
|
@ -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";
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user