tests: provide FTP directory contents in the test file

Instead of providing a fixed single synthetic response in the test
server itself. To allow us to better use *different* directory listings
in different test cases. In this change, most listings remain the same
as before.

The wildcard match tests still use synthetic responses but we should fix
that as well.

Updated numerous test cases to use this.

Closes #14295
This commit is contained in:
Daniel Stenberg 2024-07-29 10:17:08 +02:00
parent ae0b08ae6e
commit 14f630ecf6
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
42 changed files with 103 additions and 213 deletions

View file

@ -2071,7 +2071,8 @@ sub CWD_ftp {
my ($folder, $fullcommand) = $_[0];
switch_directory($folder);
if($ftptargetdir =~ /^\/fully_simulated/) {
$ftplistparserstate = "enabled";
$ftplistparserstate = "enabled";
logmsg "enabled FTP list parser mode\n";
}
else {
undef $ftplistparserstate;
@ -2091,19 +2092,6 @@ sub PWD_ftp {
sub LIST_ftp {
# print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n";
# this is a built-in fake-dir ;-)
my @ftpdir=("total 20\r\n",
"drwxr-xr-x 8 98 98 512 Oct 22 13:06 .\r\n",
"drwxr-xr-x 8 98 98 512 Oct 22 13:06 ..\r\n",
"drwxr-xr-x 2 98 98 512 May 2 1996 .NeXT\r\n",
"-r--r--r-- 1 0 1 35 Jul 16 1996 README\r\n",
"lrwxrwxrwx 1 0 1 7 Dec 9 1999 bin -> usr/bin\r\n",
"dr-xr-xr-x 2 0 1 512 Oct 1 1997 dev\r\n",
"drwxrwxrwx 2 98 98 512 May 29 16:04 download.html\r\n",
"dr-xr-xr-x 2 0 1 512 Nov 30 1995 etc\r\n",
"drwxrwxrwx 2 98 1 512 Oct 30 14:33 pub\r\n",
"dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr\r\n");
if($datasockf_conn eq 'no') {
if($nodataconn425) {
sendcontrol "150 Opening data connection\r\n";
@ -2123,15 +2111,17 @@ my @ftpdir=("total 20\r\n",
return 0;
}
if($ftplistparserstate) {
@ftpdir = ftp_contentlist($ftptargetdir);
}
logmsg "pass LIST data on data connection\n";
if($cwd_testno) {
loadtest("$logdir/test$cwd_testno");
if($ftplistparserstate) {
# provide a synthetic response
my @ftpdir = ftp_contentlist($ftptargetdir);
# old hard-coded style
for(@ftpdir) {
senddata $_;
}
}
else {
my @data = getpart("reply", "data");
for(@data) {
my $send = $_;
@ -2141,13 +2131,6 @@ my @ftpdir=("total 20\r\n",
logmsg "send $send as data\n";
senddata $send;
}
$cwd_testno = 0; # forget it again
}
else {
# old hard-coded style
for(@ftpdir) {
senddata $_;
}
}
close_dataconn(0);
sendcontrol "226 ASCII transfer complete\r\n";
@ -2214,6 +2197,7 @@ sub MDTM_ftp {
sub SIZE_ftp {
my $testno = $_[0];
if($ftplistparserstate) {
my $size = wildcard_filesize($ftptargetdir, $testno);
if($size == -1) {
@ -2374,7 +2358,7 @@ sub RETR_ftp {
$sz = "($retrsize bytes)";
}
sendcontrol "150 Binary data connection for $testno () $sz.\r\n";
sendcontrol "150 Binary data connection for $testno ($testpart) $sz.\r\n";
for(@data) {
my $send = $_;