mirror of
https://github.com/curl/curl.git
synced 2026-08-25 16:23:36 +03:00
tests: introduce preprocessed test cases
The runtests script now always performs variable replacement on the entire test source file before the test gets executed, and saves the updated version in a temporary file (log/test[num]) so that all test case readers/servers can use that version (if present) and thus enjoy the powers of test case variable substitution. This is necessary to allow complete port number freedom. Test 309 is updated to work with a non-fixed port number thanks to this.
This commit is contained in:
parent
5e2f4a33fe
commit
d009bc2e56
10 changed files with 171 additions and 177 deletions
|
|
@ -14,7 +14,7 @@ followlocation
|
||||||
HTTP/1.1 301 This is a weirdo text message swsclose
|
HTTP/1.1 301 This is a weirdo text message swsclose
|
||||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
Server: test-server/fake
|
Server: test-server/fake
|
||||||
Location: https://127.0.0.1:8991/data/3090002.txt?coolsite=yes
|
Location: https://127.0.0.1:%HTTPSPORT/data/3090002.txt?coolsite=yes
|
||||||
Connection: close
|
Connection: close
|
||||||
|
|
||||||
This server reply is for testing a simple Location: following to HTTPS URL
|
This server reply is for testing a simple Location: following to HTTPS URL
|
||||||
|
|
@ -33,7 +33,7 @@ If this is received, the location following worked
|
||||||
HTTP/1.1 301 This is a weirdo text message swsclose
|
HTTP/1.1 301 This is a weirdo text message swsclose
|
||||||
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
Date: Thu, 09 Nov 2010 14:49:00 GMT
|
||||||
Server: test-server/fake
|
Server: test-server/fake
|
||||||
Location: https://127.0.0.1:8991/data/3090002.txt?coolsite=yes
|
Location: https://127.0.0.1:%HTTPSPORT/data/3090002.txt?coolsite=yes
|
||||||
Connection: close
|
Connection: close
|
||||||
|
|
||||||
HTTP/1.1 200 Followed here fine swsclose
|
HTTP/1.1 200 Followed here fine swsclose
|
||||||
|
|
@ -61,10 +61,6 @@ HTTP Location: redirect to HTTPS URL
|
||||||
<command>
|
<command>
|
||||||
-k http://%HOSTIP:%HTTPPORT/want/309 -L
|
-k http://%HOSTIP:%HTTPPORT/want/309 -L
|
||||||
</command>
|
</command>
|
||||||
# The data section doesn't do variable substitution, so we must assert this
|
|
||||||
<precheck>
|
|
||||||
perl -e "print 'Test requires default test server host and port' if ( '%HOSTIP' ne '127.0.0.1' || '%HTTPSPORT' ne '8991' );"
|
|
||||||
</precheck>
|
|
||||||
</client>
|
</client>
|
||||||
|
|
||||||
# Verify data after the test has been "shot"
|
# Verify data after the test has been "shot"
|
||||||
|
|
|
||||||
|
|
@ -209,6 +209,31 @@ sub loadtest {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub fulltest {
|
||||||
|
return @xml;
|
||||||
|
}
|
||||||
|
|
||||||
|
# write the test to the given file
|
||||||
|
sub savetest {
|
||||||
|
my ($file)=@_;
|
||||||
|
|
||||||
|
if(open(XML, ">$file")) {
|
||||||
|
binmode XML; # for crapage systems, use binary
|
||||||
|
for(@xml) {
|
||||||
|
print XML $_;
|
||||||
|
}
|
||||||
|
close(XML);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
# failure
|
||||||
|
if($warning) {
|
||||||
|
print STDERR "file $file wouldn't open!\n";
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Strip off all lines that match the specified pattern and return
|
# Strip off all lines that match the specified pattern and return
|
||||||
# the new array.
|
# the new array.
|
||||||
|
|
|
||||||
|
|
@ -156,7 +156,7 @@ my $SMBPORT; # SMB server port
|
||||||
my $SMBSPORT; # SMBS server port
|
my $SMBSPORT; # SMBS server port
|
||||||
my $NEGTELNETPORT; # TELNET server port with negotiation
|
my $NEGTELNETPORT; # TELNET server port with negotiation
|
||||||
|
|
||||||
my $SSHSRVMD5; # MD5 of ssh server public key
|
my $SSHSRVMD5 = "[uninitialized]"; # MD5 of ssh server public key
|
||||||
|
|
||||||
my $srcdir = $ENV{'srcdir'} || '.';
|
my $srcdir = $ENV{'srcdir'} || '.';
|
||||||
my $CURL="../src/curl".exe_ext('TOOL'); # what curl executable to run on the tests
|
my $CURL="../src/curl".exe_ext('TOOL'); # what curl executable to run on the tests
|
||||||
|
|
@ -1559,7 +1559,7 @@ sub runhttpserver {
|
||||||
$pid2 = $pid3;
|
$pid2 = $pid3;
|
||||||
|
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
logmsg "RUN: $srvrname server is now running PID $httppid\n";
|
logmsg "RUN: $srvrname server is on PID $httppid port $port\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
|
|
@ -3119,9 +3119,7 @@ sub checksystem {
|
||||||
logmsg ("* Port range: $minport-$maxport\n");
|
logmsg ("* Port range: $minport-$maxport\n");
|
||||||
|
|
||||||
if($verbose) {
|
if($verbose) {
|
||||||
logmsg "* Ports:\n";
|
logmsg "* Ports: ";
|
||||||
|
|
||||||
logmsg sprintf("* HTTP/%d ", $HTTPPORT);
|
|
||||||
logmsg sprintf("FTP/%d ", $FTPPORT);
|
logmsg sprintf("FTP/%d ", $FTPPORT);
|
||||||
logmsg sprintf("FTP2/%d ", $FTP2PORT);
|
logmsg sprintf("FTP2/%d ", $FTP2PORT);
|
||||||
logmsg sprintf("RTSP/%d ", $RTSPPORT);
|
logmsg sprintf("RTSP/%d ", $RTSPPORT);
|
||||||
|
|
@ -3131,7 +3129,6 @@ sub checksystem {
|
||||||
}
|
}
|
||||||
logmsg sprintf("\n* TFTP/%d ", $TFTPPORT);
|
logmsg sprintf("\n* TFTP/%d ", $TFTPPORT);
|
||||||
if($http_ipv6) {
|
if($http_ipv6) {
|
||||||
logmsg sprintf("HTTP-IPv6/%d ", $HTTP6PORT);
|
|
||||||
logmsg sprintf("RTSP-IPv6/%d ", $RTSP6PORT);
|
logmsg sprintf("RTSP-IPv6/%d ", $RTSP6PORT);
|
||||||
}
|
}
|
||||||
if($ftp_ipv6) {
|
if($ftp_ipv6) {
|
||||||
|
|
@ -3140,10 +3137,6 @@ sub checksystem {
|
||||||
if($tftp_ipv6) {
|
if($tftp_ipv6) {
|
||||||
logmsg sprintf("TFTP-IPv6/%d ", $TFTP6PORT);
|
logmsg sprintf("TFTP-IPv6/%d ", $TFTP6PORT);
|
||||||
}
|
}
|
||||||
logmsg sprintf("\n* GOPHER/%d ", $GOPHERPORT);
|
|
||||||
if($gopher_ipv6) {
|
|
||||||
logmsg sprintf("GOPHER-IPv6/%d", $GOPHER6PORT);
|
|
||||||
}
|
|
||||||
logmsg sprintf("\n* SSH/%d ", $SSHPORT);
|
logmsg sprintf("\n* SSH/%d ", $SSHPORT);
|
||||||
logmsg sprintf("SOCKS/%d ", $SOCKSPORT);
|
logmsg sprintf("SOCKS/%d ", $SOCKSPORT);
|
||||||
logmsg sprintf("POP3/%d ", $POP3PORT);
|
logmsg sprintf("POP3/%d ", $POP3PORT);
|
||||||
|
|
@ -3184,105 +3177,83 @@ sub checksystem {
|
||||||
# a command, in either case passed by reference
|
# a command, in either case passed by reference
|
||||||
#
|
#
|
||||||
sub subVariables {
|
sub subVariables {
|
||||||
my ($thing) = @_;
|
my ($thing, $prefix) = @_;
|
||||||
|
|
||||||
# ports
|
if(!$prefix) {
|
||||||
|
$prefix = "%";
|
||||||
|
}
|
||||||
|
|
||||||
$$thing =~ s/%FTP6PORT/$FTP6PORT/g;
|
# test server ports
|
||||||
$$thing =~ s/%FTP2PORT/$FTP2PORT/g;
|
$$thing =~ s/${prefix}FTP6PORT/$FTP6PORT/g;
|
||||||
$$thing =~ s/%FTPSPORT/$FTPSPORT/g;
|
$$thing =~ s/${prefix}FTP2PORT/$FTP2PORT/g;
|
||||||
$$thing =~ s/%FTPPORT/$FTPPORT/g;
|
$$thing =~ s/${prefix}FTPSPORT/$FTPSPORT/g;
|
||||||
|
$$thing =~ s/${prefix}FTPPORT/$FTPPORT/g;
|
||||||
|
$$thing =~ s/${prefix}GOPHER6PORT/$GOPHER6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}GOPHERPORT/$GOPHERPORT/g;
|
||||||
|
$$thing =~ s/${prefix}HTTPTLS6PORT/$HTTPTLS6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}HTTPTLSPORT/$HTTPTLSPORT/g;
|
||||||
|
$$thing =~ s/${prefix}HTTP6PORT/$HTTP6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}HTTPSPORT/$HTTPSPORT/g;
|
||||||
|
$$thing =~ s/${prefix}HTTP2PORT/$HTTP2PORT/g;
|
||||||
|
$$thing =~ s/${prefix}HTTPPORT/$HTTPPORT/g;
|
||||||
|
$$thing =~ s/${prefix}PROXYPORT/$HTTPPROXYPORT/g;
|
||||||
|
$$thing =~ s/${prefix}MQTTPORT/$MQTTPORT/g;
|
||||||
|
$$thing =~ s/${prefix}IMAP6PORT/$IMAP6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}IMAPPORT/$IMAPPORT/g;
|
||||||
|
$$thing =~ s/${prefix}POP36PORT/$POP36PORT/g;
|
||||||
|
$$thing =~ s/${prefix}POP3PORT/$POP3PORT/g;
|
||||||
|
$$thing =~ s/${prefix}RTSP6PORT/$RTSP6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}RTSPPORT/$RTSPPORT/g;
|
||||||
|
$$thing =~ s/${prefix}SMTP6PORT/$SMTP6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}SMTPPORT/$SMTPPORT/g;
|
||||||
|
$$thing =~ s/${prefix}SOCKSPORT/$SOCKSPORT/g;
|
||||||
|
$$thing =~ s/${prefix}SSHPORT/$SSHPORT/g;
|
||||||
|
$$thing =~ s/${prefix}TFTP6PORT/$TFTP6PORT/g;
|
||||||
|
$$thing =~ s/${prefix}TFTPPORT/$TFTPPORT/g;
|
||||||
|
$$thing =~ s/${prefix}DICTPORT/$DICTPORT/g;
|
||||||
|
$$thing =~ s/${prefix}SMBPORT/$SMBPORT/g;
|
||||||
|
$$thing =~ s/${prefix}SMBSPORT/$SMBSPORT/g;
|
||||||
|
$$thing =~ s/${prefix}NEGTELNETPORT/$NEGTELNETPORT/g;
|
||||||
|
|
||||||
$$thing =~ s/%GOPHER6PORT/$GOPHER6PORT/g;
|
# server Unix domain socket paths
|
||||||
$$thing =~ s/%GOPHERPORT/$GOPHERPORT/g;
|
$$thing =~ s/${prefix}HTTPUNIXPATH/$HTTPUNIXPATH/g;
|
||||||
|
|
||||||
$$thing =~ s/%HTTPTLS6PORT/$HTTPTLS6PORT/g;
|
# client IP addresses
|
||||||
$$thing =~ s/%HTTPTLSPORT/$HTTPTLSPORT/g;
|
$$thing =~ s/${prefix}CLIENT6IP/$CLIENT6IP/g;
|
||||||
$$thing =~ s/%HTTP6PORT/$HTTP6PORT/g;
|
$$thing =~ s/${prefix}CLIENTIP/$CLIENTIP/g;
|
||||||
$$thing =~ s/%HTTPSPORT/$HTTPSPORT/g;
|
|
||||||
$$thing =~ s/%HTTP2PORT/$HTTP2PORT/g;
|
|
||||||
$$thing =~ s/%HTTPPORT/$HTTPPORT/g;
|
|
||||||
$$thing =~ s/%PROXYPORT/$HTTPPROXYPORT/g;
|
|
||||||
$$thing =~ s/%MQTTPORT/$MQTTPORT/g;
|
|
||||||
|
|
||||||
$$thing =~ s/%IMAP6PORT/$IMAP6PORT/g;
|
# server IP addresses
|
||||||
$$thing =~ s/%IMAPPORT/$IMAPPORT/g;
|
$$thing =~ s/${prefix}HOST6IP/$HOST6IP/g;
|
||||||
|
$$thing =~ s/${prefix}HOSTIP/$HOSTIP/g;
|
||||||
|
|
||||||
$$thing =~ s/%POP36PORT/$POP36PORT/g;
|
# misc
|
||||||
$$thing =~ s/%POP3PORT/$POP3PORT/g;
|
$$thing =~ s/${prefix}CURL/$CURL/g;
|
||||||
|
$$thing =~ s/${prefix}PWD/$pwd/g;
|
||||||
|
$$thing =~ s/${prefix}POSIX_PWD/$posix_pwd/g;
|
||||||
|
|
||||||
$$thing =~ s/%RTSP6PORT/$RTSP6PORT/g;
|
my $file_pwd = $pwd;
|
||||||
$$thing =~ s/%RTSPPORT/$RTSPPORT/g;
|
if($file_pwd !~ /^\//) {
|
||||||
|
$file_pwd = "/$file_pwd";
|
||||||
|
}
|
||||||
|
|
||||||
$$thing =~ s/%SMTP6PORT/$SMTP6PORT/g;
|
$$thing =~ s/${prefix}FILE_PWD/$file_pwd/g;
|
||||||
$$thing =~ s/%SMTPPORT/$SMTPPORT/g;
|
$$thing =~ s/${prefix}SRCDIR/$srcdir/g;
|
||||||
|
$$thing =~ s/${prefix}USER/$USER/g;
|
||||||
|
|
||||||
$$thing =~ s/%SOCKSPORT/$SOCKSPORT/g;
|
$$thing =~ s/${prefix}SSHSRVMD5/$SSHSRVMD5/g;
|
||||||
$$thing =~ s/%SSHPORT/$SSHPORT/g;
|
|
||||||
|
|
||||||
$$thing =~ s/%TFTP6PORT/$TFTP6PORT/g;
|
# The purpose of FTPTIME2 and FTPTIME3 is to provide times that can be
|
||||||
$$thing =~ s/%TFTPPORT/$TFTPPORT/g;
|
# used for time-out tests and that would work on most hosts as these
|
||||||
|
# adjust for the startup/check time for this particular host. We needed to
|
||||||
|
# do this to make the test suite run better on very slow hosts.
|
||||||
|
my $ftp2 = $ftpchecktime * 2;
|
||||||
|
my $ftp3 = $ftpchecktime * 3;
|
||||||
|
|
||||||
$$thing =~ s/%DICTPORT/$DICTPORT/g;
|
$$thing =~ s/${prefix}FTPTIME2/$ftp2/g;
|
||||||
|
$$thing =~ s/${prefix}FTPTIME3/$ftp3/g;
|
||||||
|
|
||||||
$$thing =~ s/%SMBPORT/$SMBPORT/g;
|
# HTTP2
|
||||||
$$thing =~ s/%SMBSPORT/$SMBSPORT/g;
|
$$thing =~ s/${prefix}H2CVER/$h2cver/g;
|
||||||
|
|
||||||
$$thing =~ s/%NEGTELNETPORT/$NEGTELNETPORT/g;
|
|
||||||
|
|
||||||
# server Unix domain socket paths
|
|
||||||
|
|
||||||
$$thing =~ s/%HTTPUNIXPATH/$HTTPUNIXPATH/g;
|
|
||||||
|
|
||||||
# client IP addresses
|
|
||||||
|
|
||||||
$$thing =~ s/%CLIENT6IP/$CLIENT6IP/g;
|
|
||||||
$$thing =~ s/%CLIENTIP/$CLIENTIP/g;
|
|
||||||
|
|
||||||
# server IP addresses
|
|
||||||
|
|
||||||
$$thing =~ s/%HOST6IP/$HOST6IP/g;
|
|
||||||
$$thing =~ s/%HOSTIP/$HOSTIP/g;
|
|
||||||
|
|
||||||
# misc
|
|
||||||
|
|
||||||
$$thing =~ s/%CURL/$CURL/g;
|
|
||||||
$$thing =~ s/%PWD/$pwd/g;
|
|
||||||
$$thing =~ s/%POSIX_PWD/$posix_pwd/g;
|
|
||||||
|
|
||||||
my $file_pwd = $pwd;
|
|
||||||
if($file_pwd !~ /^\//) {
|
|
||||||
$file_pwd = "/$file_pwd";
|
|
||||||
}
|
|
||||||
|
|
||||||
$$thing =~ s/%FILE_PWD/$file_pwd/g;
|
|
||||||
$$thing =~ s/%SRCDIR/$srcdir/g;
|
|
||||||
$$thing =~ s/%USER/$USER/g;
|
|
||||||
|
|
||||||
if($$thing =~ /%SSHSRVMD5/) {
|
|
||||||
if(!$SSHSRVMD5) {
|
|
||||||
my $msg = "Fatal: Missing SSH server pubkey MD5. Is server running?";
|
|
||||||
logmsg "$msg\n";
|
|
||||||
stopservers($verbose);
|
|
||||||
die $msg;
|
|
||||||
}
|
|
||||||
$$thing =~ s/%SSHSRVMD5/$SSHSRVMD5/g;
|
|
||||||
}
|
|
||||||
|
|
||||||
# The purpose of FTPTIME2 and FTPTIME3 is to provide times that can be
|
|
||||||
# used for time-out tests and that would work on most hosts as these
|
|
||||||
# adjust for the startup/check time for this particular host. We needed
|
|
||||||
# to do this to make the test suite run better on very slow hosts.
|
|
||||||
|
|
||||||
my $ftp2 = $ftpchecktime * 2;
|
|
||||||
my $ftp3 = $ftpchecktime * 3;
|
|
||||||
|
|
||||||
$$thing =~ s/%FTPTIME2/$ftp2/g;
|
|
||||||
$$thing =~ s/%FTPTIME3/$ftp3/g;
|
|
||||||
|
|
||||||
# HTTP2
|
|
||||||
|
|
||||||
$$thing =~ s/%H2CVER/$h2cver/g;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
sub fixarray {
|
sub fixarray {
|
||||||
|
|
@ -3498,6 +3469,25 @@ sub singletest {
|
||||||
$why = serverfortest($testnum);
|
$why = serverfortest($testnum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Save a preprocessed version of the entire test file. This allows more
|
||||||
|
# "basic" test case readers to enjoy variable replacements.
|
||||||
|
my @entiretest = fulltest();
|
||||||
|
my $otest = "log/test$testnum";
|
||||||
|
open(D, ">$otest");
|
||||||
|
my $diff;
|
||||||
|
for my $s (@entiretest) {
|
||||||
|
my $f = $s;
|
||||||
|
subVariables(\$s, "%");
|
||||||
|
if($f ne $s) {
|
||||||
|
$diff++;
|
||||||
|
}
|
||||||
|
print D $s;
|
||||||
|
}
|
||||||
|
close(D);
|
||||||
|
# remove the separate test file again if nothing was updated to keep
|
||||||
|
# things simpler
|
||||||
|
unlink($otest) if(!$diff);
|
||||||
|
|
||||||
# timestamp required servers verification end
|
# timestamp required servers verification end
|
||||||
$timesrvrend{$testnum} = Time::HiRes::time();
|
$timesrvrend{$testnum} = Time::HiRes::time();
|
||||||
|
|
||||||
|
|
@ -3616,6 +3606,9 @@ sub singletest {
|
||||||
map s/\n/\r\n/g, @reply;
|
map s/\n/\r\n/g, @reply;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
for my $r (@reply) {
|
||||||
|
subVariables(\$r);
|
||||||
|
}
|
||||||
|
|
||||||
# this is the valid protocol blurb curl should generate
|
# this is the valid protocol blurb curl should generate
|
||||||
my @protocol= fixarray ( getpart("verify", "protocol") );
|
my @protocol= fixarray ( getpart("verify", "protocol") );
|
||||||
|
|
@ -4462,7 +4455,7 @@ sub singletest {
|
||||||
$ok .= "v";
|
$ok .= "v";
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if(!$short && !$disablevalgrind) {
|
if($verbose && !$disablevalgrind) {
|
||||||
logmsg " valgrind SKIPPED\n";
|
logmsg " valgrind SKIPPED\n";
|
||||||
}
|
}
|
||||||
$ok .= "-"; # skipped
|
$ok .= "-"; # skipped
|
||||||
|
|
@ -5662,6 +5655,9 @@ sub displaylogs {
|
||||||
if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(\..*|)$/)) {
|
if(($log =~ /^valgrind\d+/) && ($log !~ /^valgrind$testnum(\..*|)$/)) {
|
||||||
next; # skip valgrindNnn of other tests
|
next; # skip valgrindNnn of other tests
|
||||||
}
|
}
|
||||||
|
if(($log =~ /^test$testnum$/)) {
|
||||||
|
next; # skip test$testnum since it can be very big
|
||||||
|
}
|
||||||
logmsg "=== Start of file $log\n";
|
logmsg "=== Start of file $log\n";
|
||||||
displaylogcontent("$LOGDIR/$log");
|
displaylogcontent("$LOGDIR/$log");
|
||||||
logmsg "=== End of file $log\n";
|
logmsg "=== End of file $log\n";
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,7 @@
|
||||||
* \___|\___/|_| \_\_____|
|
* \___|\___/|_| \_\_____|
|
||||||
*
|
*
|
||||||
* Copyright (C) 2010, Mandy Wu, <mandy.wu@intel.com>
|
* Copyright (C) 2010, Mandy Wu, <mandy.wu@intel.com>
|
||||||
* Copyright (C) 2011 - 2018, Daniel Stenberg, <daniel@haxx.se>, et al.
|
* Copyright (C) 2011 - 2020, Daniel Stenberg, <daniel@haxx.se>, et al.
|
||||||
*
|
*
|
||||||
* This software is licensed as described in the file COPYING, which
|
* This software is licensed as described in the file COPYING, which
|
||||||
* you should have received as part of this distribution. The terms
|
* you should have received as part of this distribution. The terms
|
||||||
|
|
@ -112,7 +112,6 @@ int main(int argc, char *argv[])
|
||||||
char buf[1024];
|
char buf[1024];
|
||||||
char logfilename[256];
|
char logfilename[256];
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *filename;
|
|
||||||
int error;
|
int error;
|
||||||
char *type1_input = NULL, *type3_input = NULL;
|
char *type1_input = NULL, *type3_input = NULL;
|
||||||
char *type1_output = NULL, *type3_output = NULL;
|
char *type1_output = NULL, *type3_output = NULL;
|
||||||
|
|
@ -186,12 +185,10 @@ int main(int argc, char *argv[])
|
||||||
path = env;
|
path = env;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = test2file(testnum);
|
stream = test2fopen(testnum);
|
||||||
stream = fopen(filename, "rb");
|
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file %ld", testnum);
|
logmsg("Couldn't open test file %ld", testnum);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -205,13 +202,11 @@ int main(int argc, char *argv[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
stream = test2fopen(testnum);
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file %ld", testnum);
|
logmsg("Couldn't open test file %ld", testnum);
|
||||||
exit(1);
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
size = 0;
|
size = 0;
|
||||||
|
|
@ -225,11 +220,10 @@ int main(int argc, char *argv[])
|
||||||
|
|
||||||
while(fgets(buf, sizeof(buf), stdin)) {
|
while(fgets(buf, sizeof(buf), stdin)) {
|
||||||
if(strcmp(buf, type1_input) == 0) {
|
if(strcmp(buf, type1_input) == 0) {
|
||||||
stream = fopen(filename, "rb");
|
stream = test2fopen(testnum);
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file %ld", testnum);
|
logmsg("Couldn't open test file %ld", testnum);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
@ -247,11 +241,10 @@ int main(int argc, char *argv[])
|
||||||
fflush(stdout);
|
fflush(stdout);
|
||||||
}
|
}
|
||||||
else if(strncmp(buf, type3_input, strlen(type3_input)) == 0) {
|
else if(strncmp(buf, type3_input, strlen(type3_input)) == 0) {
|
||||||
stream = fopen(filename, "rb");
|
stream = test2fopen(testnum);
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file %ld", testnum);
|
logmsg("Couldn't open test file %ld", testnum);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -446,7 +446,6 @@ static curl_socket_t mqttit(curl_socket_t fd)
|
||||||
size_t remaining_length = 0;
|
size_t remaining_length = 0;
|
||||||
size_t bytes = 0; /* remaining length field size in bytes */
|
size_t bytes = 0; /* remaining length field size in bytes */
|
||||||
char client_id[MAX_CLIENT_ID_LENGTH];
|
char client_id[MAX_CLIENT_ID_LENGTH];
|
||||||
char *filename;
|
|
||||||
long testno;
|
long testno;
|
||||||
|
|
||||||
static const char protocol[7] = {
|
static const char protocol[7] = {
|
||||||
|
|
@ -550,8 +549,7 @@ static curl_socket_t mqttit(curl_socket_t fd)
|
||||||
char *data;
|
char *data;
|
||||||
size_t datalen;
|
size_t datalen;
|
||||||
logmsg("Found test number %ld", testno);
|
logmsg("Found test number %ld", testno);
|
||||||
filename = test2file(testno);
|
stream = test2fopen(testno);
|
||||||
stream = fopen(filename, "rb");
|
|
||||||
error = getpart(&data, &datalen, "reply", "data", stream);
|
error = getpart(&data, &datalen, "reply", "data", stream);
|
||||||
if(!error)
|
if(!error)
|
||||||
publish(dump, fd, packet_id, topic, data, datalen);
|
publish(dump, fd, packet_id, topic, data, datalen);
|
||||||
|
|
|
||||||
|
|
@ -247,8 +247,6 @@ static int ProcessRequest(struct httprequest *req)
|
||||||
/* get the number after it */
|
/* get the number after it */
|
||||||
if(ptr) {
|
if(ptr) {
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *filename;
|
|
||||||
|
|
||||||
if((strlen(doc) + strlen(request)) < 200)
|
if((strlen(doc) + strlen(request)) < 200)
|
||||||
msnprintf(logbuf, sizeof(logbuf), "Got request: %s %s %s/%d.%d",
|
msnprintf(logbuf, sizeof(logbuf), "Got request: %s %s %s/%d.%d",
|
||||||
request, doc, prot_str, prot_major, prot_minor);
|
request, doc, prot_str, prot_major, prot_minor);
|
||||||
|
|
@ -288,13 +286,11 @@ static int ProcessRequest(struct httprequest *req)
|
||||||
req->testno, req->partno);
|
req->testno, req->partno);
|
||||||
logmsg("%s", logbuf);
|
logmsg("%s", logbuf);
|
||||||
|
|
||||||
filename = test2file(req->testno);
|
stream = test2fopen(req->testno);
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
int error = errno;
|
int error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file %ld", req->testno);
|
logmsg("Couldn't open test file %ld", req->testno);
|
||||||
req->open = FALSE; /* closes connection */
|
req->open = FALSE; /* closes connection */
|
||||||
return 1; /* done */
|
return 1; /* done */
|
||||||
|
|
@ -849,17 +845,13 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||||
count = strlen(buffer);
|
count = strlen(buffer);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char *filename = test2file(req->testno);
|
FILE *stream = test2fopen(req->testno);
|
||||||
char partbuf[80]="data";
|
char partbuf[80]="data";
|
||||||
FILE *stream;
|
|
||||||
if(0 != req->partno)
|
if(0 != req->partno)
|
||||||
msnprintf(partbuf, sizeof(partbuf), "data%ld", req->partno);
|
msnprintf(partbuf, sizeof(partbuf), "data%ld", req->partno);
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file");
|
logmsg("Couldn't open test file");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
@ -879,11 +871,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-open the same file again */
|
/* re-open the same file again */
|
||||||
stream = fopen(filename, "rb");
|
stream = test2fopen(req->testno);
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg("Error opening file: %s", filename);
|
|
||||||
logmsg("Couldn't open test file");
|
logmsg("Couldn't open test file");
|
||||||
free(ptr);
|
free(ptr);
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -235,18 +235,15 @@ static bool socket_domain_is_ip(void)
|
||||||
static int parse_servercmd(struct httprequest *req)
|
static int parse_servercmd(struct httprequest *req)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *filename;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
filename = test2file(req->testno);
|
stream = test2fopen(req->testno);
|
||||||
req->close = FALSE;
|
req->close = FALSE;
|
||||||
req->connmon = FALSE;
|
req->connmon = FALSE;
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg(" [1] Error opening file: %s", filename);
|
|
||||||
logmsg(" Couldn't open test file %ld", req->testno);
|
logmsg(" Couldn't open test file %ld", req->testno);
|
||||||
req->open = FALSE; /* closes connection */
|
req->open = FALSE; /* closes connection */
|
||||||
return 1; /* done */
|
return 1; /* done */
|
||||||
|
|
@ -991,7 +988,6 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
char partbuf[80];
|
char partbuf[80];
|
||||||
char *filename = test2file(req->testno);
|
|
||||||
|
|
||||||
/* select the <data> tag for "normal" requests and the <connect> one
|
/* select the <data> tag for "normal" requests and the <connect> one
|
||||||
for CONNECT requests (within the <reply> section) */
|
for CONNECT requests (within the <reply> section) */
|
||||||
|
|
@ -1004,11 +1000,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||||
|
|
||||||
logmsg("Send response test%ld section <%s>", req->testno, partbuf);
|
logmsg("Send response test%ld section <%s>", req->testno, partbuf);
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
stream = test2fopen(req->testno);
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg(" [3] Error opening file: %s", filename);
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -1027,11 +1022,10 @@ static int send_doc(curl_socket_t sock, struct httprequest *req)
|
||||||
}
|
}
|
||||||
|
|
||||||
/* re-open the same file again */
|
/* re-open the same file again */
|
||||||
stream = fopen(filename, "rb");
|
stream = test2fopen(req->testno);
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg(" [4] Error opening file: %s", filename);
|
|
||||||
free(ptr);
|
free(ptr);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -944,16 +944,12 @@ static int do_tftp(struct testcase *test, struct tftphdr *tp, ssize_t size)
|
||||||
static int parse_servercmd(struct testcase *req)
|
static int parse_servercmd(struct testcase *req)
|
||||||
{
|
{
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
char *filename;
|
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
filename = test2file(req->testno);
|
stream = test2fopen(req->testno);
|
||||||
|
|
||||||
stream = fopen(filename, "rb");
|
|
||||||
if(!stream) {
|
if(!stream) {
|
||||||
error = errno;
|
error = errno;
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
logmsg(" [1] Error opening file: %s", filename);
|
|
||||||
logmsg(" Couldn't open test file %ld", req->testno);
|
logmsg(" Couldn't open test file %ld", req->testno);
|
||||||
return 1; /* done */
|
return 1; /* done */
|
||||||
}
|
}
|
||||||
|
|
@ -1036,7 +1032,7 @@ static int validate_access(struct testcase *test,
|
||||||
char partbuf[80]="data";
|
char partbuf[80]="data";
|
||||||
long partno;
|
long partno;
|
||||||
long testno;
|
long testno;
|
||||||
char *file;
|
FILE *stream;
|
||||||
|
|
||||||
ptr++; /* skip the slash */
|
ptr++; /* skip the slash */
|
||||||
|
|
||||||
|
|
@ -1061,40 +1057,33 @@ static int validate_access(struct testcase *test,
|
||||||
|
|
||||||
(void)parse_servercmd(test);
|
(void)parse_servercmd(test);
|
||||||
|
|
||||||
file = test2file(testno);
|
stream = test2fopen(testno);
|
||||||
|
|
||||||
if(0 != partno)
|
if(0 != partno)
|
||||||
msnprintf(partbuf, sizeof(partbuf), "data%ld", partno);
|
msnprintf(partbuf, sizeof(partbuf), "data%ld", partno);
|
||||||
|
|
||||||
if(file) {
|
if(!stream) {
|
||||||
FILE *stream = fopen(file, "rb");
|
int error = errno;
|
||||||
if(!stream) {
|
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
||||||
int error = errno;
|
logmsg("Couldn't open test file for test : %d", testno);
|
||||||
logmsg("fopen() failed with error: %d %s", error, strerror(error));
|
return EACCESS;
|
||||||
logmsg("Error opening file: %s", file);
|
}
|
||||||
logmsg("Couldn't open test file: %s", file);
|
else {
|
||||||
|
size_t count;
|
||||||
|
int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
|
||||||
|
fclose(stream);
|
||||||
|
if(error) {
|
||||||
|
logmsg("getpart() failed with error: %d", error);
|
||||||
return EACCESS;
|
return EACCESS;
|
||||||
}
|
}
|
||||||
else {
|
if(test->buffer) {
|
||||||
size_t count;
|
test->rptr = test->buffer; /* set read pointer */
|
||||||
int error = getpart(&test->buffer, &count, "reply", partbuf, stream);
|
test->bufsize = count; /* set total count */
|
||||||
fclose(stream);
|
test->rcount = count; /* set data left to read */
|
||||||
if(error) {
|
|
||||||
logmsg("getpart() failed with error: %d", error);
|
|
||||||
return EACCESS;
|
|
||||||
}
|
|
||||||
if(test->buffer) {
|
|
||||||
test->rptr = test->buffer; /* set read pointer */
|
|
||||||
test->bufsize = count; /* set total count */
|
|
||||||
test->rcount = count; /* set data left to read */
|
|
||||||
}
|
|
||||||
else
|
|
||||||
return EACCESS;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return EACCESS;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return EACCESS;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
logmsg("no slash found in path");
|
logmsg("no slash found in path");
|
||||||
|
|
|
||||||
|
|
@ -194,11 +194,21 @@ void win32_cleanup(void)
|
||||||
/* set by the main code to point to where the test dir is */
|
/* set by the main code to point to where the test dir is */
|
||||||
const char *path = ".";
|
const char *path = ".";
|
||||||
|
|
||||||
char *test2file(long testno)
|
FILE *test2fopen(long testno)
|
||||||
{
|
{
|
||||||
static char filename[256];
|
FILE *stream;
|
||||||
|
char filename[256];
|
||||||
|
/* first try the alternative, preprocessed, file */
|
||||||
|
msnprintf(filename, sizeof(filename), ALTTEST_DATA_PATH, path, testno);
|
||||||
|
stream = fopen(filename, "rb");
|
||||||
|
if(stream)
|
||||||
|
return stream;
|
||||||
|
|
||||||
|
/* then try the source version */
|
||||||
msnprintf(filename, sizeof(filename), TEST_DATA_PATH, path, testno);
|
msnprintf(filename, sizeof(filename), TEST_DATA_PATH, path, testno);
|
||||||
return filename;
|
stream = fopen(filename, "rb");
|
||||||
|
|
||||||
|
return stream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
||||||
|
|
@ -28,6 +28,7 @@ void logmsg(const char *msg, ...);
|
||||||
long timediff(struct timeval newer, struct timeval older);
|
long timediff(struct timeval newer, struct timeval older);
|
||||||
|
|
||||||
#define TEST_DATA_PATH "%s/data/test%ld"
|
#define TEST_DATA_PATH "%s/data/test%ld"
|
||||||
|
#define ALTTEST_DATA_PATH "%s/log/test%ld"
|
||||||
|
|
||||||
#define SERVERLOGS_LOCK "log/serverlogs.lock"
|
#define SERVERLOGS_LOCK "log/serverlogs.lock"
|
||||||
|
|
||||||
|
|
@ -53,8 +54,9 @@ void win32_init(void);
|
||||||
void win32_cleanup(void);
|
void win32_cleanup(void);
|
||||||
#endif /* USE_WINSOCK */
|
#endif /* USE_WINSOCK */
|
||||||
|
|
||||||
/* returns the path name to the test case file */
|
/* fopens the test case file */
|
||||||
char *test2file(long testno);
|
FILE *test2fopen(long testno);
|
||||||
|
|
||||||
int wait_ms(int timeout_ms);
|
int wait_ms(int timeout_ms);
|
||||||
int write_pidfile(const char *filename);
|
int write_pidfile(const char *filename);
|
||||||
int write_portfile(const char *filename, int port);
|
int write_portfile(const char *filename, int port);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue