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

[svn] Major testsuite update.

This commit is contained in:
mtortonesi 2006-10-12 09:18:57 -07:00
parent 2367fb27ac
commit f0b4f352bf
21 changed files with 750 additions and 18 deletions

View File

@ -1,3 +1,65 @@
2006-10-12 Mauro Tortonesi <mauro@ferrara.linux.it>
* Test1.px: Renamed to Test-noop.px.
* Test-noop.px: Ditto.
* Test2.px: Renamed to Test-N.px.
* Test-N.px: Ditto.
* Test3.px: Renamed to Test-nonexisting-quiet.px.
* Test-nonexisting-quiet.px: Ditto.
* Test4.px: Renamed to Test-O-nonexisting.px.
* Test-O-nonexisting.px: Ditto.
* Test5.px: Renamed to Test-HTTP-Content-Disposition.px.
* Test-HTTP-Content-Disposition.px: Ditto.
* Test6.px: Renamed to Test-HTTP-Content-Disposition-1.px.
* Test-HTTP-Content-Disposition-1.px: Ditto.
* Test7.px: Renamed to Test-HTTP-Content-Disposition-2.px.
* Test-HTTP-Content-Disposition-2.px: Ditto.
* Test8.px: Replaced by Test--spider-r.px.
* Test9.px: Renamed to Test-Restrict-Lowercase.px.
* Test-Restrict-Lowercase.px: Ditto.
* Test10.px: Renamed to Test-Restrict-Uppercase.px.
* Test-Restrict-Uppercase.px: Ditto.
* Test--spider.px: Added test for spider mode.
* Test--spider-fail.px: Added failing test for spider mode.
* Test--spider-r.px: Added test for recursive spider mode.
* Test-c.px: Added test for --continue mode.
* Test-c-full.px: Added test for --continue mode.
* Test-c-partial.px: Added test for --continue mode.
* Test-O.px: Added test for -O.
* Test-N-current.px: Added test for -N.
* Test-N-old.px: Added test for -N.
* Test-E-k.px: Added test for -E -k.
* Test-E-k-K.px: Added test for -E -k -K.
2006-08-17 Mauro Tortonesi <mauro@ferrara.linux.it>
* HTTPServer.pm: Added support for Range header.

52
tests/Test--spider-fail.px Executable file
View File

@ -0,0 +1,52 @@
#!/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 = "wget --spider http://localhost:8080/nonexistent";
my $expected_error_code = 256;
my %expected_downloaded_files = (
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test--spider-fail",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

109
tests/Test--spider-r.px Executable file
View File

@ -0,0 +1,109 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $mainpage = <<EOF;
<html>
<head>
<title>Main Page</title>
</head>
<body>
<p>
Some text and a link to a <a href="http://localhost:8080/secondpage.html">second page</a>.
Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
</p>
</body>
</html>
EOF
my $secondpage = <<EOF;
<html>
<head>
<title>Second Page</title>
</head>
<body>
<p>
Some text and a link to a <a href="http://localhost:8080/thirdpage.html">third page</a>.
Also, a <a href="http://localhost:8080/nonexistent">broken link</a>.
</p>
</body>
</html>
EOF
my $thirdpage = <<EOF;
<html>
<head>
<title>Third Page</title>
</head>
<body>
<p>
Some text and a link to a <a href="http://localhost:8080/dummy.txt">text file</a>.
Also, another <a href="http://localhost:8080/againnonexistent">broken link</a>.
</p>
</body>
</html>
EOF
my $dummyfile = <<EOF;
Don't care.
EOF
# code, msg, headers, content
my %urls = (
'/index.html' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
},
content => $mainpage,
},
'/secondpage.html' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
},
content => $secondpage,
},
'/thirdpage.html' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
},
content => $thirdpage,
},
'/dummy.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
},
content => $dummyfile
},
);
my $cmdline = "wget --spider -r http://localhost:8080/";
my $expected_error_code = 0;
my %expected_downloaded_files = (
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test--spider-r",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

52
tests/Test--spider.px Executable file
View File

@ -0,0 +1,52 @@
#!/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 = "wget --spider http://localhost:8080/index.html";
my $expected_error_code = 256;
my %expected_downloaded_files = (
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test--spider",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

89
tests/Test-E-k-K.px Executable file
View File

@ -0,0 +1,89 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $mainpage = <<EOF;
<html>
<head>
<title>Main Page Title</title>
</head>
<body>
<a href="http://localhost:8080/subpage.php">Secondary Page</a>
</body>
</html>
EOF
my $mainpagemangled = <<EOF;
<html>
<head>
<title>Main Page Title</title>
</head>
<body>
<a href="subpage.php.html">Secondary Page</a>
</body>
</html>
EOF
my $subpage = <<EOF;
<html>
<head>
<title>Secondary Page Title</title>
</head>
<body>
<p>Some text</p>
</body>
</html>
EOF
# code, msg, headers, content
my %urls = (
'/index.php' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
},
content => $mainpage,
},
'/subpage.php' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
},
content => $subpage,
},
);
my $cmdline = "wget -d -r -nd -E -k -K http://localhost:8080/index.php";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'index.php.orig' => {
content => $mainpage,
},
'index.php.html' => {
content => $mainpagemangled,
},
'subpage.php.html' => {
content => $subpage,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-E-k-K",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

View File

@ -13,7 +13,18 @@ my $mainpage = <<EOF;
<title>Main Page Title</title>
</head>
<body>
<a href="http://localhost:8080/subpage.html">Secondary Page</a>
<a href="http://localhost:8080/subpage.php">Secondary Page</a>
</body>
</html>
EOF
my $mainpagemangled = <<EOF;
<html>
<head>
<title>Main Page Title</title>
</head>
<body>
<a href="subpage.php.html">Secondary Page</a>
</body>
</html>
EOF
@ -24,14 +35,14 @@ my $subpage = <<EOF;
<title>Secondary Page Title</title>
</head>
<body>
<a href="http://localhost:8080/nonexistent">Broken Link</a>
<p>Some text</p>
</body>
</html>
EOF
# code, msg, headers, content
my %urls = (
'/index.html' => {
'/index.php' => {
code => "200",
msg => "Dontcare",
headers => {
@ -39,7 +50,7 @@ my %urls = (
},
content => $mainpage,
},
'/subpage.html' => {
'/subpage.php' => {
code => "200",
msg => "Dontcare",
headers => {
@ -49,16 +60,22 @@ my %urls = (
},
);
my $cmdline = "wget --spider -r http://localhost:8080/";
my $cmdline = "wget -r -nd -E -k http://localhost:8080/index.php";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'index.php.html' => {
content => $mainpagemangled,
},
'subpage.php.html' => {
content => $subpage,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test8",
my $the_test = HTTPTest->new (name => "Test-E-k",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,

57
tests/Test-N-current.px Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $wholefile = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555
EOF
# code, msg, headers, content
my %urls = (
'/somefile.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = "wget -c http://localhost:8080/somefile.txt";
my $expected_error_code = 0;
my %existing_files = (
'somefile.txt' => {
content => $wholefile,
},
);
my %expected_downloaded_files = (
'somefile.txt' => {
content => $wholefile,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-N-current",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
existing => \%existing_files,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

65
tests/Test-N-old.px Executable file
View File

@ -0,0 +1,65 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $oldversion = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
EOF
my $newversion = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555
EOF
# code, msg, headers, content
my %urls = (
'/somefile.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
"Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
},
content => $newversion,
},
);
my $cmdline = "wget -N http://localhost:8080/somefile.txt";
my $expected_error_code = 0;
my %existing_files = (
'somefile.txt' => {
content => $oldversion,
timestamp => 1097310000, # Earlier timestamp
},
);
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-old",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
existing => \%existing_files,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

View File

@ -13,23 +13,23 @@ EOF
# code, msg, headers, content
my %urls = (
'/dummy.html' => {
'/dummy.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
"Content-type" => "text/plain",
"Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT",
},
content => $dummyfile
},
);
my $cmdline = "wget -N http://localhost:8080/dummy.html";
my $cmdline = "wget -N http://localhost:8080/dummy.txt";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'dummy.html' => {
'dummy.txt' => {
content => $dummyfile,
timestamp => 1097310600, # "Sat, 09 Oct 2004 08:30:00 GMT"
}
@ -37,7 +37,7 @@ my %expected_downloaded_files = (
###############################################################################
my $the_test = HTTPTest->new (name => "Test2",
my $the_test = HTTPTest->new (name => "Test-N",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,

View File

@ -17,7 +17,7 @@ my %urls = (
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
"Content-type" => "text/html",
},
content => $dummyfile
},

View File

@ -8,12 +8,12 @@ use HTTPTest;
###############################################################################
my $dummyfile = <<EOF;
Content
Don't care.
EOF
# code, msg, headers, content
my %urls = (
'/dummy.html' => {
'/dummy.txt' => {
code => "200",
msg => "Dontcare",
headers => {
@ -23,19 +23,19 @@ my %urls = (
},
);
my $cmdline = "wget http://localhost:8080/dummy.html";
my $cmdline = "wget -O out http://localhost:8080/dummy.txt";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'dummy.html' => {
'out' => {
content => $dummyfile,
}
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test1",
my $the_test = HTTPTest->new (name => "Test-O",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,

57
tests/Test-c-full.px Executable file
View File

@ -0,0 +1,57 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $wholefile = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555
EOF
# code, msg, headers, content
my %urls = (
'/somefile.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = "wget -c http://localhost:8080/somefile.txt";
my $expected_error_code = 0;
my %existing_files = (
'somefile.txt' => {
content => $wholefile,
},
);
my %expected_downloaded_files = (
'somefile.txt' => {
content => $wholefile,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-c-full",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
existing => \%existing_files,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

62
tests/Test-c-partial.px Executable file
View File

@ -0,0 +1,62 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $partiallydownloaded = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
EOF
my $wholefile = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555
EOF
# code, msg, headers, content
my %urls = (
'/somefile.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = "wget -c http://localhost:8080/somefile.txt";
my $expected_error_code = 0;
my %existing_files = (
'somefile.txt' => {
content => $partiallydownloaded,
},
);
my %expected_downloaded_files = (
'somefile.txt' => {
content => $wholefile,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-c-partial",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
existing => \%existing_files,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

54
tests/Test-c.px Executable file
View File

@ -0,0 +1,54 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $wholefile = <<EOF;
11111111111111111111111111111111111111111111111111
222222222222222222222222222222222222222222222222222222222222
3333333333333333333333333333333333333333333333333333333333333333333333
444444444444444444444444444444444444444444444444444444444444
55555555555555555555555555555555555555555555555555
EOF
# code, msg, headers, content
my %urls = (
'/somefile.txt' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/plain",
},
content => $wholefile,
},
);
my $cmdline = "wget -c http://localhost:8080/somefile.txt";
my $expected_error_code = 0;
my %existing_files = (
);
my %expected_downloaded_files = (
'somefile.txt' => {
content => $wholefile,
},
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-c",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
existing => \%existing_files,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4

View File

@ -32,7 +32,7 @@ my %expected_downloaded_files = (
###############################################################################
my $the_test = HTTPTest->new (name => "Test3",
my $the_test = HTTPTest->new (name => "Test-nonexisting-quiet",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,

56
tests/Test-noop.px Executable file
View File

@ -0,0 +1,56 @@
#!/usr/bin/perl -w
use strict;
use HTTPTest;
###############################################################################
my $index = <<EOF;
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>Page Title</h1>
<p>
Some text here.
</p>
</body>
</html>
EOF
# code, msg, headers, content
my %urls = (
'/index.html' => {
code => "200",
msg => "Dontcare",
headers => {
"Content-type" => "text/html",
},
content => $index
},
);
my $cmdline = "wget http://localhost:8080/";
my $expected_error_code = 0;
my %expected_downloaded_files = (
'index.html' => {
content => $index,
}
);
###############################################################################
my $the_test = HTTPTest->new (name => "Test-noop",
input => \%urls,
cmdline => $cmdline,
errcode => $expected_error_code,
output => \%expected_downloaded_files);
$the_test->run();
# vim: et ts=4 sw=4