1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Automated merge.

This commit is contained in:
Micah Cowan 2008-05-31 18:17:55 -07:00
commit b4077ab56a
15 changed files with 271 additions and 227 deletions

View 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> 2008-04-26 Micah Cowan <micah@cowan.name>
* Makefile.am, Test-proxied-https-auth.px: Added a test for * Makefile.am, Test-proxied-https-auth.px: Added a test for

View File

@ -833,14 +833,14 @@ sub run
print STDERR "got a connection from: $client_ipnum\n" if $log; print STDERR "got a connection from: $client_ipnum\n" if $log;
# fork off a process to handle this connection. # fork off a process to handle this connection.
my $pid = fork(); # my $pid = fork();
unless (defined $pid) { # unless (defined $pid) {
warn "fork: $!"; # warn "fork: $!";
sleep 5; # Back off in case system is overloaded. # sleep 5; # Back off in case system is overloaded.
next; # next;
} # }
if ($pid == 0) { # Child process. if (1) { # Child process.
# install signals # install signals
$SIG{URG} = sub { $SIG{URG} = sub {

View File

@ -98,15 +98,25 @@ sub send_response {
my $start = $1 ? $1 : 0; my $start = $1 ? $1 : 0;
my $end = $2 ? $2 : ($content_len - 1); my $end = $2 ? $2 : ($content_len - 1);
my $len = $2 ? ($2 - $start) : ($content_len - $start); my $len = $2 ? ($2 - $start) : ($content_len - $start);
if ($len) {
$resp->header("Accept-Ranges" => "bytes"); $resp->header("Accept-Ranges" => "bytes");
$resp->header("Content-Length" => $len); $resp->header("Content-Length" => $len);
$resp->header("Content-Range" => "bytes $start-$end/$content_len"); $resp->header("Content-Range"
=> "bytes $start-$end/$content_len");
$resp->header("Keep-Alive" => "timeout=15, max=100"); $resp->header("Keep-Alive" => "timeout=15, max=100");
$resp->header("Connection" => "Keep-Alive"); $resp->header("Connection" => "Keep-Alive");
$con->send_basic_header(206, "Partial Content", $resp->protocol); $con->send_basic_header(206,
"Partial Content", $resp->protocol);
print $con $resp->headers_as_string($CRLF); print $con $resp->headers_as_string($CRLF);
print $con $CRLF; print $con $CRLF;
print $con substr($content, $start, $len); 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; next;
} }
# fill in content # fill in content

View File

@ -46,46 +46,7 @@ run-unit-tests: unit-tests$(EXEEXT)
./unit-tests$(EXEEXT) ./unit-tests$(EXEEXT)
run-px-tests: WgetTest.pm run-px-tests: WgetTest.pm
$(PERLRUN) $(srcdir)/Test-proxied-https-auth.px && echo && echo ./run-px $(top_srcdir)
$(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
EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \ EXTRA_DIST = FTPServer.pm FTPTest.pm HTTPServer.pm HTTPTest.pm \
Test-auth-basic.px Test-c-full.px Test-c-partial.px \ Test-auth-basic.px Test-c-full.px Test-c-partial.px \

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -34,7 +34,7 @@ my %urls = (
my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/index.html"; my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/index.html";
my $expected_error_code = 256; my $expected_error_code = 0;
my %expected_downloaded_files = ( my %expected_downloaded_files = (
); );

View File

@ -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; my $expected_error_code = 0;

View File

@ -15,6 +15,11 @@ my $currentversion = <<EOF;
55555555555555555555555555555555555555555555555555 55555555555555555555555555555555555555555555555555
EOF 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 # code, msg, headers, content
my %urls = ( my %urls = (
'/somefile.txt' => { '/somefile.txt' => {
@ -24,7 +29,7 @@ my %urls = (
"Content-type" => "text/plain", "Content-type" => "text/plain",
"Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT", "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
}, },
content => $currentversion, content => $modifiedversion,
}, },
); );

63
tests/Test-N-no-info.px Executable file
View File

@ -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

View File

@ -10,16 +10,14 @@ use HTTPTest;
my $oldversion = <<EOF; my $oldversion = <<EOF;
11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222 222222222222222222222222222222222222222222222222222222222222
EOF
my $newversion = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333 3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444 444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555 55555555555555555555555555555555555555555555555555
EOF EOF
my $newversion = $oldversion;
$newversion =~ s/^(.{20}).(.*)$/$1x$2/s;
# code, msg, headers, content # code, msg, headers, content
my %urls = ( my %urls = (
'/somefile.txt' => { '/somefile.txt' => {

66
tests/Test-N-smaller.px Executable file
View File

@ -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

View File

@ -9,17 +9,22 @@ use HTTPTest;
my $partiallydownloaded = <<EOF; my $partiallydownloaded = <<EOF;
11111111111111111111111111111111111111111111111111 11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222 22222222x222222222222222222222222222222222222222222222222222
EOF EOF
my $wholefile = <<EOF; my $rest = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333 3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444 444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555 55555555555555555555555555555555555555555555555555
EOF EOF
my $wholefile = <<EOF . $rest;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
EOF
my $downloadedfile = $partiallydownloaded . $rest;
# code, msg, headers, content # code, msg, headers, content
my %urls = ( my %urls = (
'/somefile.txt' => { '/somefile.txt' => {
@ -44,7 +49,7 @@ my %existing_files = (
my %expected_downloaded_files = ( my %expected_downloaded_files = (
'somefile.txt' => { 'somefile.txt' => {
content => $wholefile, content => $downloadedfile,
}, },
); );

63
tests/run-px Executable file
View File

@ -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";
}