]> sjero.net Git - wget/commitdiff
Attempted, but failed, to reproduce bug 22403.
authorMicah Cowan <micah@cowan.name>
Tue, 8 Sep 2009 05:40:25 +0000 (22:40 -0700)
committerMicah Cowan <micah@cowan.name>
Tue, 8 Sep 2009 05:40:25 +0000 (22:40 -0700)
tests/ChangeLog
tests/FTPServer.pm
tests/Makefile.am
tests/Test-ftp-bad-list.px [new file with mode: 0755]
tests/run-px

index a0f5185ae5086ae6b157e6e2e4633ddea4cb91f1..7c8eb7108e019d5bc3534bbc6defae30dae65e84 100644 (file)
@@ -1,3 +1,14 @@
+2009-09-07  Micah Cowan  <micah@cowan.name>
+
+       * FTPServer.pm (FTPServer::run): Pass "server behavior" information to
+       newly-constructed FTPPaths object.
+       (FTPPaths::initialize): Accept "server behavior" hash.
+       (FTPPaths::_format_for_list): If server behavior has "bad_list"
+       set, then always report 0 for the size.
+       * Test-ftp-bad-list.px: Added. Attempts to reproduce bug
+       22403... but doesn't.
+       * run-px, Makefile.am (EXTRA_DIST): Added Test-ftp-bad-list.px.
+
 2009-09-06  Micah Cowan  <micah@cowan.name>
 
        * WgetTest.pm.in (_setup): Don't expect error codes from
index 981ddea63d21e680e7934bdfcf6bc6aabd3ac0f3..dd06538749fd83b6045af2c531380972455bf5d1 100644 (file)
@@ -563,7 +563,8 @@ sub run
             print STDERR "in child\n" if $log;
 
             my $conn = { 
-                'paths'           => FTPPaths->new($self->{'_input'}),
+                'paths'           => FTPPaths->new($self->{'_input'},
+                                        $self->{'_server_behavior'}),
                 'socket'          => $socket, 
                 'state'           => $_connection_states{NEWCONN},
                 'dir'             => '/',
@@ -693,7 +694,7 @@ sub new {
 }
 
 sub initialize {
-    my ($self, $urls) = @_;
+    my ($self, $urls, $behavior) = @_;
     my $paths = {_type => 'd'};
 
     # From a path like '/foo/bar/baz.txt', construct $paths such that
@@ -714,6 +715,7 @@ sub initialize {
     }
 
     $self->{'_paths'} = $paths;
+    $self->{'_behavior'} = $behavior;
 }
 
 sub get_info {
@@ -763,6 +765,9 @@ sub _format_for_list {
     my $size = 0;
     if ($info->{'_type'} eq 'f') {
         $size = length  $info->{'content'};
+        if ($self->{'_behavior'}{'bad_list'}) {
+            $size = 0;
+        }
     }
     my $date = strftime ("%b %e %H:%M", localtime);
     return "$mode_str 1  0  0  $size $date $name";
index 768bd084aeea42ae38fd700322ebfbaac9945544..cd6df8d826b3fde735efca5b3b273a5c490e8df8 100644 (file)
@@ -74,6 +74,7 @@ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
              Test-E-k.px \
              Test-ftp.px \
             Test-ftp-pasv-fail.px \
+            Test-ftp-bad-list.px \
              Test-ftp-recursive.px \
              Test-ftp-iri.px \
              Test-ftp-iri-fallback.px \
diff --git a/tests/Test-ftp-bad-list.px b/tests/Test-ftp-bad-list.px
new file mode 100755 (executable)
index 0000000..11a973f
--- /dev/null
@@ -0,0 +1,69 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use FTPTest;
+
+
+###############################################################################
+
+my $afile = <<EOF;
+Some text.
+EOF
+
+my $bfile = <<EOF;
+Some more text.
+EOF
+
+$afile =~ s/\n/\r\n/g;
+$bfile =~ s/\n/\r\n/g;
+
+# code, msg, headers, content
+my %urls = (
+    '/afile.txt' => {
+        content => $afile,
+    },
+    '/bfile.txt' => {
+        content => $bfile,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -d -nH -Nc -r ftp://localhost:{{port}}/";
+
+my $expected_error_code = 0;
+
+# Don't need to worry about timestamps, the "bad_list" setting will
+# ensure the sizes don't match expectations, and so they'll always be
+# re-downloaded.
+my %expected_downloaded_files = (
+    'afile.txt' => {
+        content => $afile,
+    },
+    'bfile.txt' => {
+        content => $bfile,
+    },
+);
+
+my %preexisting_files = (
+    'afile.txt' => {
+        content => $afile,
+    },
+    'bfile.txt' => {
+        content => $bfile,
+    },
+);
+
+###############################################################################
+
+my $the_test = FTPTest->new (name => "Test-ftp-bad-list",
+                             input => \%urls, 
+                             cmdline => $cmdline, 
+                             errcode => $expected_error_code, 
+                             output => \%expected_downloaded_files,
+                             existing => \%preexisting_files,
+                             server_behavior => {bad_list => 1});
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
index 52101fc6720bc2f7eddbb63f1914f70840e3159f..1a441c7b843836ae41c72249c6e3860f2c016b70 100755 (executable)
@@ -27,6 +27,7 @@ my @tests = (
     'Test-E-k.px',
     'Test-ftp.px',
     'Test-ftp-pasv-fail.px',
+    'Test-ftp-bad-list.px',
     'Test-ftp-recursive.px',
     'Test-ftp-iri.px',
     'Test-ftp-iri-fallback.px',