diff options
author | Daniel Stenberg <daniel@haxx.se> | 2020-08-04 13:56:12 +0200 |
---|---|---|
committer | Daniel Stenberg <daniel@haxx.se> | 2020-08-04 18:12:42 +0200 |
commit | 424092e70f4c83e32d16bdbb1316526c10e57139 (patch) | |
tree | 043648770106b672ab1c27b885a240e7994448f0 /tests/ftpserver.pl | |
parent | ca222824f36be93effd56528f7590bfb05a829f0 (diff) | |
download | curl-424092e70f4c83e32d16bdbb1316526c10e57139.tar.gz |
runtests: support dynamicly base64 encoded sections in tests
This allows us to make test cases to use base64 at run-time and still
use and verify information determined at run-time, such as the IMAP test
server's port number in test 842.
This change makes 12 tests run again that basically never ran since we
moved to dynamic port numbers.
ftpserver.pl is adjusted to load test instructions and test number from
the preprocessed test file.
FILEFORMAT.md now documents the new base64 encoding syntax.
Reported-by: Marcel Raad
Fixes #5761
Closes #5775
Diffstat (limited to 'tests/ftpserver.pl')
-rwxr-xr-x | tests/ftpserver.pl | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index a0b36e5de..d587f453e 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -83,6 +83,7 @@ my $proto = 'ftp'; # default server protocol my $srcdir; # directory where ftpserver.pl is located my $srvrname; # server name for presentation purposes my $cwd_testno; # test case numbers extracted from CWD command +my $testno = 0; # test case number (read from ftpserver.cmd) my $path = '.'; my $logdir = $path .'/log'; @@ -449,17 +450,14 @@ sub startsf { # Returns the given test's reply data # sub getreplydata { - my ($testno) = @_; + my ($num) = @_; my $testpart = ""; - $testno =~ s/^([^0-9]*)//; - if($testno > 10000) { - $testpart = $testno % 10000; - $testno = int($testno / 10000); + $num =~ s/^([^0-9]*)//; + if($num > 10000) { + $testpart = $num % 10000; } - loadtest("$srcdir/data/test$testno"); - my @data = getpart("reply", "data$testpart"); if((!@data) && ($testpart ne "")) { @data = getpart("reply", "data"); @@ -2093,7 +2091,8 @@ my @ftpdir=("total 20\r\n", logmsg "pass LIST data on data connection\n"; if($cwd_testno) { - loadtest("$srcdir/data/test$cwd_testno"); + loadtest("$logdir/test$cwd_testno") || + loadtest("$srcdir/data/test$cwd_testno"); my @data = getpart("reply", "data"); for(@data) { @@ -2156,7 +2155,8 @@ sub MDTM_ftp { $testno = int($testno / 10000); } - loadtest("$srcdir/data/test$testno"); + loadtest("$logdir/test$testno") || + loadtest("$srcdir/data/test$testno"); my @data = getpart("reply", "mdtm"); @@ -2209,7 +2209,8 @@ sub SIZE_ftp { $testno = int($testno / 10000); } - loadtest("$srcdir/data/test$testno"); + loadtest("$logdir/test$testno") || + loadtest("$srcdir/data/test$testno"); my @data = getpart("reply", "size"); @@ -2298,7 +2299,8 @@ sub RETR_ftp { $testno = int($testno / 10000); } - loadtest("$srcdir/data/test$testno"); + loadtest("$logdir/test$testno") || + loadtest("$srcdir/data/test$testno"); my @data = getpart("reply", "data$testpart"); @@ -2881,6 +2883,10 @@ sub customize { $nosave = 1; logmsg "FTPD: NOSAVE prevents saving of uploaded data\n"; } + elsif($_ =~ /^Testnum (\d+)/){ + $testno = $1; + logmsg "FTPD: run test case number: $testno\n"; + } } close(CUSTOM); } @@ -3069,6 +3075,8 @@ while(1) { $| = 1; &customize(); # read test control instructions + loadtest("$logdir/test$testno") || + loadtest("$srcdir/data/test$testno"); my $welcome = $commandreply{"welcome"}; if(!$welcome) { |