]> sjero.net Git - wget/commitdiff
Automated merge.
authorMicah Cowan <micah@cowan.name>
Sun, 1 Jun 2008 01:17:55 +0000 (18:17 -0700)
committerMicah Cowan <micah@cowan.name>
Sun, 1 Jun 2008 01:17:55 +0000 (18:17 -0700)
15 files changed:
tests/ChangeLog
tests/FTPServer.pm
tests/HTTPServer.pm
tests/Makefile.am
tests/Test--spider--no-content-disposition-trivial.px [deleted file]
tests/Test--spider--no-content-disposition.px [deleted file]
tests/Test--spider-HTTP-Content-Disposition.px [deleted file]
tests/Test--spider.px
tests/Test-N-HTTP-Content-Disposition.px
tests/Test-N-current.px
tests/Test-N-no-info.px [new file with mode: 0755]
tests/Test-N-old.px
tests/Test-N-smaller.px [new file with mode: 0755]
tests/Test-c-partial.px
tests/run-px [new file with mode: 0755]

index f485f93c20cdb0b147cada02e93c2a05c8940bae..73d93a2f9304182121a399ab7668cc25170afd6d 100644 (file)
@@ -1,3 +1,33 @@
+2008-05-31  Micah Cowan  <micah@cowan.name>
+
+       * Test-N-current.px: Ensure we catch failures.
+
+       * Test-N-old.px: Make it test only the timestamp, and not the
+       content length in addition.
+
+       * Test-N-smaller.px, Test-N-no-info.px: added.
+
+       * Test-c-partial.px: Improve checking that the file was
+       partially retrieved, rather than overwritten.
+
+       * run-px: Added Test-N-smaller.px, Test-N-no-info.px.
+
+       * HTTPServer.pm: Return 416 for fully-retrieved content, rather
+       than 206 with a zero content-length.
+
+2008-05-23  Micah Cowan  <micah@cowan.name>
+
+       * Test--spider.px: Make test expect 0 return code.
+
+2008-05-22  Micah Cowan  <micah@cowan.name>
+
+       * Makefile.am (run-px-tests): Replaced ugly list of tests with
+       run-px Perl script to manage running them.
+       
+       * run-px: Added.
+
+       * FTPServer.pm (run): Avoid re-forking. Fixes bug #20458.
+
 2008-04-26  Micah Cowan  <micah@cowan.name>
 
        * Makefile.am, Test-proxied-https-auth.px: Added a test for
index 7c7f3e584b4f0ed0c774013b314aa1113a319f3a..d8ad8b0c919a049f80d9e530237c095c99259153 100644 (file)
@@ -833,14 +833,14 @@ sub run
         print STDERR "got a connection from: $client_ipnum\n" if $log;
 
         # fork off a process to handle this connection.
-        my $pid = fork();
-        unless (defined $pid) {
-            warn "fork: $!";
-            sleep 5; # Back off in case system is overloaded.
-            next;
-        }
-
-        if ($pid == 0) { # Child process.
+        my $pid = fork();
+        unless (defined $pid) {
+            warn "fork: $!";
+            sleep 5; # Back off in case system is overloaded.
+            next;
+        }
+
+        if (1) { # Child process.
 
             # install signals
             $SIG{URG}  = sub { 
index 97e91396dcf6e5b6f5ed0105e8cf1cd2fc1ba5ff..a307b737310cb644abb489d1132d06211d02e38f 100644 (file)
@@ -98,15 +98,25 @@ sub send_response {
             my $start = $1 ? $1 : 0;
             my $end = $2 ? $2 : ($content_len - 1);
             my $len = $2 ? ($2 - $start) : ($content_len - $start);
-            $resp->header("Accept-Ranges" => "bytes");
-            $resp->header("Content-Length" => $len);
-            $resp->header("Content-Range" => "bytes $start-$end/$content_len");
-            $resp->header("Keep-Alive" => "timeout=15, max=100");
-            $resp->header("Connection" => "Keep-Alive");
-            $con->send_basic_header(206, "Partial Content", $resp->protocol);
-            print $con $resp->headers_as_string($CRLF);
-            print $con $CRLF;
-            print $con substr($content, $start, $len);
+            if ($len) {
+                $resp->header("Accept-Ranges" => "bytes");
+                $resp->header("Content-Length" => $len);
+                $resp->header("Content-Range"
+                    => "bytes $start-$end/$content_len");
+                $resp->header("Keep-Alive" => "timeout=15, max=100");
+                $resp->header("Connection" => "Keep-Alive");
+                $con->send_basic_header(206,
+                    "Partial Content", $resp->protocol);
+                print $con $resp->headers_as_string($CRLF);
+                print $con $CRLF;
+                print $con substr($content, $start, $len);
+            } else {
+                $con->send_basic_header(416, "Range Not Satisfiable",
+                    $resp->protocol);
+                $resp->header("Keep-Alive" => "timeout=15, max=100");
+                $resp->header("Connection" => "Keep-Alive");
+                print $con $CRLF;
+            }
             next;
         }
         # fill in content
index fefdbf1d1d590169e7826a923181e25ad37e0391..853698285a7cf6ba7eb8b293056bf1fbf3f168e9 100644 (file)
@@ -46,46 +46,7 @@ run-unit-tests: unit-tests$(EXEEXT)
        ./unit-tests$(EXEEXT)
 
 run-px-tests: WgetTest.pm
-       $(PERLRUN) $(srcdir)/Test-proxied-https-auth.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-proxy-auth-basic.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-auth-basic.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-c-full.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-c-partial.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-c.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-E-k-K.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-E-k.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-ftp.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-HTTP-Content-Disposition-1.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-HTTP-Content-Disposition-2.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-HTTP-Content-Disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N-current-HTTP-CD.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N-current.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N-HTTP-Content-Disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N--no-content-disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N--no-content-disposition-trivial.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--no-content-disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--no-content-disposition-trivial.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N-old.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-nonexisting-quiet.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-noop.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-np.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-N.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-O-HTTP-Content-Disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-O--no-content-disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-O--no-content-disposition-trivial.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-O-nonexisting.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-O.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-Restrict-Lowercase.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test-Restrict-Uppercase.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider-fail.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider-HTTP-Content-Disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider--no-content-disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider--no-content-disposition-trivial.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider-r-HTTP-Content-Disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider-r--no-content-disposition.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider-r--no-content-disposition-trivial.px && echo && echo
-       $(PERLRUN) $(srcdir)/Test--spider-r.px && echo && echo
+       ./run-px $(top_srcdir)
 
 EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
             Test-auth-basic.px Test-c-full.px Test-c-partial.px \
diff --git a/tests/Test--spider--no-content-disposition-trivial.px b/tests/Test--spider--no-content-disposition-trivial.px
deleted file mode 100755 (executable)
index 323db07..0000000
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-use HTTPTest;
-
-
-###############################################################################
-
-my $mainpage = <<EOF;
-<html>
-<head>
-  <title>Main Page</title>
-</head>
-<body>
-  <p>
-    Some text.
-  </p>
-</body>
-</html>
-EOF
-
-# code, msg, headers, content
-my %urls = (
-    '/index.html' => {
-        code => "200",
-        msg => "Dontcare",
-        headers => {
-            "Content-type" => "text/html",
-        },
-        content => $mainpage,
-    },
-);
-
-my $cmdline = $WgetTest::WGETPATH . " --spider --no-content-disposition http://localhost:8080/index.html";
-
-my $expected_error_code = 256;
-
-my %expected_downloaded_files = (
-);
-
-###############################################################################
-
-my $the_test = HTTPTest->new (name => "Test--spider--no-content-disposition-trivial",
-                              input => \%urls, 
-                              cmdline => $cmdline, 
-                              errcode => $expected_error_code, 
-                              output => \%expected_downloaded_files);
-exit $the_test->run();
-
-# vim: et ts=4 sw=4
-
diff --git a/tests/Test--spider--no-content-disposition.px b/tests/Test--spider--no-content-disposition.px
deleted file mode 100755 (executable)
index acf73a7..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-use HTTPTest;
-
-
-###############################################################################
-
-my $mainpage = <<EOF;
-<html>
-<head>
-  <title>Main Page</title>
-</head>
-<body>
-  <p>
-    Some text.
-  </p>
-</body>
-</html>
-EOF
-
-# code, msg, headers, content
-my %urls = (
-    '/index.html' => {
-        code => "200",
-        msg => "Dontcare",
-        headers => {
-            "Content-type" => "text/html",
-            "Content-Disposition" => "attachment; filename=\"filename.html\"",
-        },
-        content => $mainpage,
-    },
-);
-
-my $cmdline = $WgetTest::WGETPATH . " --spider --no-content-disposition http://localhost:8080/index.html";
-
-my $expected_error_code = 256;
-
-my %expected_downloaded_files = (
-);
-
-###############################################################################
-
-my $the_test = HTTPTest->new (name => "Test--spider--no-content-disposition",
-                              input => \%urls, 
-                              cmdline => $cmdline, 
-                              errcode => $expected_error_code, 
-                              output => \%expected_downloaded_files);
-exit $the_test->run();
-
-# vim: et ts=4 sw=4
-
diff --git a/tests/Test--spider-HTTP-Content-Disposition.px b/tests/Test--spider-HTTP-Content-Disposition.px
deleted file mode 100755 (executable)
index 79eaba5..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-#!/usr/bin/perl -w
-
-use strict;
-
-use HTTPTest;
-
-
-###############################################################################
-
-my $mainpage = <<EOF;
-<html>
-<head>
-  <title>Main Page</title>
-</head>
-<body>
-  <p>
-    Some text.
-  </p>
-</body>
-</html>
-EOF
-
-# code, msg, headers, content
-my %urls = (
-    '/index.html' => {
-        code => "200",
-        msg => "Dontcare",
-        headers => {
-            "Content-type" => "text/html",
-            "Content-Disposition" => "attachment; filename=\"filename.html\"",
-        },
-        content => $mainpage,
-    },
-);
-
-my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/index.html";
-
-my $expected_error_code = 256;
-
-my %expected_downloaded_files = (
-);
-
-###############################################################################
-
-my $the_test = HTTPTest->new (name => "Test--spider-HTTP-Content-Disposition",
-                              input => \%urls, 
-                              cmdline => $cmdline, 
-                              errcode => $expected_error_code, 
-                              output => \%expected_downloaded_files);
-exit $the_test->run();
-
-# vim: et ts=4 sw=4
-
index c2c1263e01bf9aa125647a9cf627bff8f64b0aa1..f412c762afcd759d61af80fa9185ac98f0330667 100755 (executable)
@@ -34,7 +34,7 @@ my %urls = (
 
 my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/index.html";
 
-my $expected_error_code = 256;
+my $expected_error_code = 0;
 
 my %expected_downloaded_files = (
 );
index 8c5e4181ef7abd344d952a9e0dfee2256f84f329..42aa39ad8c6f0ac2691b0de0ab9b3288c2df7c52 100755 (executable)
@@ -25,7 +25,8 @@ my %urls = (
     },
 );
 
-my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/dummy.txt";
+my $cmdline = $WgetTest::WGETPATH . " -N --content-disposition "
+              . "http://localhost:8080/dummy.txt";
 
 my $expected_error_code = 0;
 
index 47003c7ee2cd085ff3f3310391339aa1359c3f58..16086ae8a8e62bde6a046bec5dccef05c4bd765a 100755 (executable)
@@ -15,6 +15,11 @@ my $currentversion = <<EOF;
 55555555555555555555555555555555555555555555555555
 EOF
 
+# The server should serve a slightly different content, but with the
+# same length, so we can test which version was downloaded.
+my $modifiedversion = $currentversion;
+$modifiedversion =~ s/^(.{20}).(.*)$/$1x$2/s;
+
 # code, msg, headers, content
 my %urls = (
     '/somefile.txt' => {
@@ -24,7 +29,7 @@ my %urls = (
             "Content-type" => "text/plain",
             "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
         },
-        content => $currentversion,
+        content => $modifiedversion,
     },
 );
 
diff --git a/tests/Test-N-no-info.px b/tests/Test-N-no-info.px
new file mode 100755 (executable)
index 0000000..bd83f64
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $currentversion = <<EOF;
+11111111111111111111111111111111111111111111111111
+222222222222222222222222222222222222222222222222222222222222
+3333333333333333333333333333333333333333333333333333333333333333333333
+444444444444444444444444444444444444444444444444444444444444
+55555555555555555555555555555555555555555555555555
+EOF
+
+my $newversion = <<EOF;
+11111111111111111111111111111111111111111111111111
+222222222222222222222222222222222222222222222222222222222222
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/somefile.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+        },
+        content => $newversion,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt";
+
+my $expected_error_code = 0;
+
+my %existing_files = (
+    'somefile.txt' => {
+        content => $currentversion,
+        timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
+    },
+);
+
+my %expected_downloaded_files = (
+    'somefile.txt' => {
+        content => $newversion,
+    },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-N-current",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              existing => \%existing_files,
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
index 05383dbef8d127fe23ec150c3f604a1f719aa060..ee9a84e09e12630f60c1028f5b0cfc6241e19bfe 100755 (executable)
@@ -10,16 +10,14 @@ use HTTPTest;
 my $oldversion = <<EOF;
 11111111111111111111111111111111111111111111111111
 222222222222222222222222222222222222222222222222222222222222
-EOF
-
-my $newversion = <<EOF;
-11111111111111111111111111111111111111111111111111
-222222222222222222222222222222222222222222222222222222222222
 3333333333333333333333333333333333333333333333333333333333333333333333
 444444444444444444444444444444444444444444444444444444444444
 55555555555555555555555555555555555555555555555555
 EOF
 
+my $newversion = $oldversion;
+$newversion =~ s/^(.{20}).(.*)$/$1x$2/s;
+
 # code, msg, headers, content
 my %urls = (
     '/somefile.txt' => {
diff --git a/tests/Test-N-smaller.px b/tests/Test-N-smaller.px
new file mode 100755 (executable)
index 0000000..9ad44c2
--- /dev/null
@@ -0,0 +1,66 @@
+#!/usr/bin/perl -w
+
+use strict;
+
+use HTTPTest;
+
+
+###############################################################################
+
+my $currentversion = <<EOF;
+11111111111111111111111111111111111111111111111111
+222222222222222222222222222222222222222222222222222222222222
+3333333333333333333333333333333333333333333333333333333333333333333333
+444444444444444444444444444444444444444444444444444444444444
+55555555555555555555555555555555555555555555555555
+EOF
+
+my $newversion = <<EOF;
+11111111111111111111111111111111111111111111111111
+222222222222222222222222222222222222222222222222222222222222
+EOF
+
+# code, msg, headers, content
+my %urls = (
+    '/somefile.txt' => {
+        code => "200",
+        msg => "Dontcare",
+        headers => {
+            "Content-type" => "text/plain",
+            "Content-Length" => length $newversion,
+            "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
+        },
+        content => $newversion,
+    },
+);
+
+my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt";
+
+my $expected_error_code = 0;
+
+my %existing_files = (
+    'somefile.txt' => {
+        content => $currentversion,
+        timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
+    },
+);
+
+my %expected_downloaded_files = (
+    'somefile.txt' => {
+        content => $newversion,
+        timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
+    },
+);
+
+###############################################################################
+
+my $the_test = HTTPTest->new (name => "Test-N-current",
+                              input => \%urls, 
+                              cmdline => $cmdline, 
+                              errcode => $expected_error_code, 
+                              existing => \%existing_files,
+                              output => \%expected_downloaded_files);
+exit $the_test->run();
+
+# vim: et ts=4 sw=4
+
index ee48cbf621ba2ee82becac724eb6c8ab2b4375f1..ddf1d4be19b96db31da0b6f318a797110b3d553b 100755 (executable)
@@ -9,17 +9,22 @@ use HTTPTest;
 
 my $partiallydownloaded = <<EOF;
 11111111111111111111111111111111111111111111111111
-222222222222222222222222222222222222222222222222222222222222
+22222222x222222222222222222222222222222222222222222222222222
 EOF
 
-my $wholefile = <<EOF;
-11111111111111111111111111111111111111111111111111
-222222222222222222222222222222222222222222222222222222222222
+my $rest = <<EOF;
 3333333333333333333333333333333333333333333333333333333333333333333333
 444444444444444444444444444444444444444444444444444444444444
 55555555555555555555555555555555555555555555555555
 EOF
 
+my $wholefile = <<EOF . $rest;
+11111111111111111111111111111111111111111111111111
+222222222222222222222222222222222222222222222222222222222222
+EOF
+
+my $downloadedfile = $partiallydownloaded . $rest;
+
 # code, msg, headers, content
 my %urls = (
     '/somefile.txt' => {
@@ -44,7 +49,7 @@ my %existing_files = (
 
 my %expected_downloaded_files = (
     'somefile.txt' => {
-        content => $wholefile,
+        content => $downloadedfile,
     },
 );
 
diff --git a/tests/run-px b/tests/run-px
new file mode 100755 (executable)
index 0000000..febb0de
--- /dev/null
@@ -0,0 +1,63 @@
+#!/usr/bin/env perl
+use warnings;
+
+die "Please specify the top source directory.\n" if (!@ARGV);
+my $top_srcdir = shift @ARGV;
+
+my @tests = (
+    'Test-auth-basic.px',
+    'Test-proxy-auth-basic.px',
+    'Test-proxied-https-auth.px',
+    'Test-N-HTTP-Content-Disposition.px',
+    'Test--spider.px',
+    'Test-c-full.px',
+    'Test-c-partial.px',
+    'Test-c.px',
+    'Test-E-k-K.px',
+    'Test-E-k.px',
+    'Test-ftp.px',
+    'Test-HTTP-Content-Disposition-1.px',
+    'Test-HTTP-Content-Disposition-2.px',
+    'Test-HTTP-Content-Disposition.px',
+    'Test-N-current.px',
+    'Test-N-smaller.px',
+    'Test-N-no-info.px',
+    'Test-N--no-content-disposition.px',
+    'Test-N--no-content-disposition-trivial.px',
+    'Test--no-content-disposition.px',
+    'Test--no-content-disposition-trivial.px',
+    'Test-N-old.px',
+    'Test-nonexisting-quiet.px',
+    'Test-noop.px',
+    'Test-np.px',
+    'Test-N.px',
+    'Test-O-HTTP-Content-Disposition.px',
+    'Test-O--no-content-disposition.px',
+    'Test-O--no-content-disposition-trivial.px',
+    'Test-O-nonexisting.px',
+    'Test-O.px',
+    'Test-Restrict-Lowercase.px',
+    'Test-Restrict-Uppercase.px',
+    'Test--spider-fail.px',
+    'Test--spider-r-HTTP-Content-Disposition.px',
+    'Test--spider-r--no-content-disposition.px',
+    'Test--spider-r--no-content-disposition-trivial.px',
+    'Test--spider-r.px',
+);
+
+my @results;
+
+for my $test (@tests) {
+    print "Running $test\n\n";
+    system("$top_srcdir/tests/$test");
+    push @results, $?;
+}
+
+for (my $i=0; $i != @tests; ++$i) {
+    if ($results[$i] == 0) {
+        print "pass: ";
+    } else {
+        print "FAIL: ";
+    }
+    print "$tests[$i]\n";
+}