diff options
-rw-r--r-- | tests/FILEFORMAT | 6 | ||||
-rw-r--r-- | tests/data/test100 | 9 | ||||
-rwxr-xr-x | tests/ftpserver.pl | 32 |
3 files changed, 36 insertions, 11 deletions
diff --git a/tests/FILEFORMAT b/tests/FILEFORMAT index 0815556b1..4f05e3900 100644 --- a/tests/FILEFORMAT +++ b/tests/FILEFORMAT @@ -59,6 +59,12 @@ transfers. of data encoded with base64. It is the only way a test case can contain binary data. (This attribute can in fact be used on any section, but it doesn't make much sense for other sections than "data"). + +For FTP file listings, the <data> section will be used *only* if you make sure +that there has been a CWD done first to a directory named 'test-[num]' where +[num] is the test case number. Otherwise the ftp server can't know from which +test file to load the list content. + </data> <dataNUM> Send back this contents instead of the <data> one. The num is set by: diff --git a/tests/data/test100 b/tests/data/test100 index 6127163b2..6e0f734ac 100644 --- a/tests/data/test100 +++ b/tests/data/test100 @@ -11,11 +11,11 @@ LIST <reply> # When doing LIST, we get the default list output hard-coded in the test # FTP server -<datacheck> +<data> total 20 drwxr-xr-x 8 98 98 512 Oct 22 13:06 . drwxr-xr-x 8 98 98 512 Oct 22 13:06 .. -drwxr-xr-x 2 98 98 512 May 2 1996 .NeXT +drwxr-xr-x 2 98 98 512 May 2 1996 curl-releases -r--r--r-- 1 0 1 35 Jul 16 1996 README lrwxrwxrwx 1 0 1 7 Dec 9 1999 bin -> usr/bin dr-xr-xr-x 2 0 1 512 Oct 1 1997 dev @@ -23,7 +23,7 @@ drwxrwxrwx 2 98 98 512 May 29 16:04 download.html dr-xr-xr-x 2 0 1 512 Nov 30 1995 etc drwxrwxrwx 2 98 1 512 Oct 30 14:33 pub dr-xr-xr-x 5 0 1 512 Oct 1 1997 usr -</datacheck> +</data> </reply> # @@ -36,7 +36,7 @@ ftp FTP dir list PASV </name> <command> -ftp://%HOSTIP:%FTPPORT/ +ftp://%HOSTIP:%FTPPORT/test-100/ </command> </client> @@ -47,6 +47,7 @@ ftp://%HOSTIP:%FTPPORT/ USER anonymous
PASS ftp@example.com
PWD
+CWD test-100
EPSV
TYPE A
LIST
diff --git a/tests/ftpserver.pl b/tests/ftpserver.pl index cb0c7a859..c97524425 100755 --- a/tests/ftpserver.pl +++ b/tests/ftpserver.pl @@ -6,7 +6,7 @@ # | (__| |_| | _ <| |___ # \___|\___/|_| \_\_____| # -# Copyright (C) 1998 - 2013, Daniel Stenberg, <daniel@haxx.se>, et al. +# Copyright (C) 1998 - 2014, Daniel Stenberg, <daniel@haxx.se>, et al. # # This software is licensed as described in the file COPYING, which # you should have received as part of this distribution. The terms @@ -78,7 +78,7 @@ my $ipvnum = 4; # server IPv number (4 or 6) 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 $path = '.'; my $logdir = $path .'/log'; @@ -152,7 +152,7 @@ my %delayreply; # # $ftptargetdir is keeping the fake "name" of LIST directory. # my $ftplistparserstate; -my $ftptargetdir; +my $ftptargetdir=""; #********************************************************************** # global variables used when running a ftp server to keep state info @@ -2078,7 +2078,10 @@ sub switch_directory_goto { sub switch_directory { my $target_dir = $_[0]; - if($target_dir eq "/") { + if($target_dir =~ /^test-(\d+)/) { + $cwd_testno = $1; + } + elsif($target_dir eq "/") { $ftptargetdir = "/"; } else { @@ -2111,7 +2114,7 @@ sub PWD_ftp { } sub LIST_ftp { - # print "150 ASCII data connection for /bin/ls (193.15.23.1,59196) (0 bytes)\r\n"; + # 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", @@ -2150,8 +2153,23 @@ my @ftpdir=("total 20\r\n", } logmsg "pass LIST data on data connection\n"; - for(@ftpdir) { - senddata $_; + + if($cwd_testno) { + loadtest("$srcdir/data/test$cwd_testno"); + + my @data = getpart("reply", "data"); + for(@data) { + my $send = $_; + 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"; |