From f0b4f352bfedd1ac5b639db801445261f19a73ff Mon Sep 17 00:00:00 2001 From: mtortonesi Date: Thu, 12 Oct 2006 09:18:57 -0700 Subject: [PATCH] [svn] Major testsuite update. --- tests/ChangeLog | 62 ++++++++++ tests/Test--spider-fail.px | 52 +++++++++ tests/Test--spider-r.px | 109 ++++++++++++++++++ tests/Test--spider.px | 52 +++++++++ tests/Test-E-k-K.px | 89 ++++++++++++++ tests/{Test8.px => Test-E-k.px} | 29 ++++- ....px => Test-HTTP-Content-Disposition-1.px} | 0 ....px => Test-HTTP-Content-Disposition-2.px} | 0 ...t5.px => Test-HTTP-Content-Disposition.px} | 0 tests/Test-N-current.px | 57 +++++++++ tests/Test-N-old.px | 65 +++++++++++ tests/{Test2.px => Test-N.px} | 10 +- tests/{Test4.px => Test-O-nonexisting.px} | 2 +- tests/{Test1.px => Test-O.px} | 10 +- .../{Test9.px => Test-Restrict-Lowercase.px} | 0 .../{Test10.px => Test-Restrict-Uppercase.px} | 0 tests/Test-c-full.px | 57 +++++++++ tests/Test-c-partial.px | 62 ++++++++++ tests/Test-c.px | 54 +++++++++ tests/{Test3.px => Test-nonexisting-quiet.px} | 2 +- tests/Test-noop.px | 56 +++++++++ 21 files changed, 750 insertions(+), 18 deletions(-) create mode 100755 tests/Test--spider-fail.px create mode 100755 tests/Test--spider-r.px create mode 100755 tests/Test--spider.px create mode 100755 tests/Test-E-k-K.px rename tests/{Test8.px => Test-E-k.px} (67%) rename tests/{Test6.px => Test-HTTP-Content-Disposition-1.px} (100%) rename tests/{Test7.px => Test-HTTP-Content-Disposition-2.px} (100%) rename tests/{Test5.px => Test-HTTP-Content-Disposition.px} (100%) create mode 100755 tests/Test-N-current.px create mode 100755 tests/Test-N-old.px rename tests/{Test2.px => Test-N.px} (82%) rename tests/{Test4.px => Test-O-nonexisting.px} (95%) rename tests/{Test1.px => Test-O.px} (83%) rename tests/{Test9.px => Test-Restrict-Lowercase.px} (100%) rename tests/{Test10.px => Test-Restrict-Uppercase.px} (100%) create mode 100755 tests/Test-c-full.px create mode 100755 tests/Test-c-partial.px create mode 100755 tests/Test-c.px rename tests/{Test3.px => Test-nonexisting-quiet.px} (93%) create mode 100755 tests/Test-noop.px diff --git a/tests/ChangeLog b/tests/ChangeLog index 6cba557a..daaa10fc 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,65 @@ +2006-10-12 Mauro Tortonesi + + * 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 * HTTPServer.pm: Added support for Range header. diff --git a/tests/Test--spider-fail.px b/tests/Test--spider-fail.px new file mode 100755 index 00000000..9682681b --- /dev/null +++ b/tests/Test--spider-fail.px @@ -0,0 +1,52 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text. +

+ + +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 + diff --git a/tests/Test--spider-r.px b/tests/Test--spider-r.px new file mode 100755 index 00000000..94ca2c7a --- /dev/null +++ b/tests/Test--spider-r.px @@ -0,0 +1,109 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text and a link to a second page. + Also, a broken link. +

+ + +EOF + +my $secondpage = < + + Second Page + + +

+ Some text and a link to a third page. + Also, a broken link. +

+ + +EOF + +my $thirdpage = < + + Third Page + + +

+ Some text and a link to a text file. + Also, another broken link. +

+ + +EOF + +my $dummyfile = < { + 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 + diff --git a/tests/Test--spider.px b/tests/Test--spider.px new file mode 100755 index 00000000..2c58cebd --- /dev/null +++ b/tests/Test--spider.px @@ -0,0 +1,52 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page + + +

+ Some text. +

+ + +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 + diff --git a/tests/Test-E-k-K.px b/tests/Test-E-k-K.px new file mode 100755 index 00000000..854d47ad --- /dev/null +++ b/tests/Test-E-k-K.px @@ -0,0 +1,89 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $mainpage = < + + Main Page Title + + + Secondary Page + + +EOF + +my $mainpagemangled = < + + Main Page Title + + + Secondary Page + + +EOF + +my $subpage = < + + Secondary Page Title + + +

Some text

+ + +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 + diff --git a/tests/Test8.px b/tests/Test-E-k.px similarity index 67% rename from tests/Test8.px rename to tests/Test-E-k.px index 9d4a3081..86e2dcf6 100755 --- a/tests/Test8.px +++ b/tests/Test-E-k.px @@ -13,7 +13,18 @@ my $mainpage = <Main Page Title - Secondary Page + Secondary Page + + +EOF + +my $mainpagemangled = < + + Main Page Title + + + Secondary Page EOF @@ -24,14 +35,14 @@ my $subpage = <Secondary Page Title - Broken Link +

Some text

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, diff --git a/tests/Test6.px b/tests/Test-HTTP-Content-Disposition-1.px similarity index 100% rename from tests/Test6.px rename to tests/Test-HTTP-Content-Disposition-1.px diff --git a/tests/Test7.px b/tests/Test-HTTP-Content-Disposition-2.px similarity index 100% rename from tests/Test7.px rename to tests/Test-HTTP-Content-Disposition-2.px diff --git a/tests/Test5.px b/tests/Test-HTTP-Content-Disposition.px similarity index 100% rename from tests/Test5.px rename to tests/Test-HTTP-Content-Disposition.px diff --git a/tests/Test-N-current.px b/tests/Test-N-current.px new file mode 100755 index 00000000..9343d179 --- /dev/null +++ b/tests/Test-N-current.px @@ -0,0 +1,57 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $wholefile = < { + 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 + diff --git a/tests/Test-N-old.px b/tests/Test-N-old.px new file mode 100755 index 00000000..7cdc3a0b --- /dev/null +++ b/tests/Test-N-old.px @@ -0,0 +1,65 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $oldversion = < { + 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 + diff --git a/tests/Test2.px b/tests/Test-N.px similarity index 82% rename from tests/Test2.px rename to tests/Test-N.px index 20ece7d2..d70171db 100755 --- a/tests/Test2.px +++ b/tests/Test-N.px @@ -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, diff --git a/tests/Test4.px b/tests/Test-O-nonexisting.px similarity index 95% rename from tests/Test4.px rename to tests/Test-O-nonexisting.px index d0bc67c1..676bd5f4 100755 --- a/tests/Test4.px +++ b/tests/Test-O-nonexisting.px @@ -17,7 +17,7 @@ my %urls = ( code => "200", msg => "Dontcare", headers => { - "Content-type" => "text/plain", + "Content-type" => "text/html", }, content => $dummyfile }, diff --git a/tests/Test1.px b/tests/Test-O.px similarity index 83% rename from tests/Test1.px rename to tests/Test-O.px index 2da6cdae..722ff39c 100755 --- a/tests/Test1.px +++ b/tests/Test-O.px @@ -8,12 +8,12 @@ use HTTPTest; ############################################################################### my $dummyfile = < { + '/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, diff --git a/tests/Test9.px b/tests/Test-Restrict-Lowercase.px similarity index 100% rename from tests/Test9.px rename to tests/Test-Restrict-Lowercase.px diff --git a/tests/Test10.px b/tests/Test-Restrict-Uppercase.px similarity index 100% rename from tests/Test10.px rename to tests/Test-Restrict-Uppercase.px diff --git a/tests/Test-c-full.px b/tests/Test-c-full.px new file mode 100755 index 00000000..c57182ef --- /dev/null +++ b/tests/Test-c-full.px @@ -0,0 +1,57 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $wholefile = < { + 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 + diff --git a/tests/Test-c-partial.px b/tests/Test-c-partial.px new file mode 100755 index 00000000..8661cfa6 --- /dev/null +++ b/tests/Test-c-partial.px @@ -0,0 +1,62 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $partiallydownloaded = < { + 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 + diff --git a/tests/Test-c.px b/tests/Test-c.px new file mode 100755 index 00000000..4306cab6 --- /dev/null +++ b/tests/Test-c.px @@ -0,0 +1,54 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $wholefile = < { + 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 + diff --git a/tests/Test3.px b/tests/Test-nonexisting-quiet.px similarity index 93% rename from tests/Test3.px rename to tests/Test-nonexisting-quiet.px index d10f8ea9..97ee275e 100755 --- a/tests/Test3.px +++ b/tests/Test-nonexisting-quiet.px @@ -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, diff --git a/tests/Test-noop.px b/tests/Test-noop.px new file mode 100755 index 00000000..296e845a --- /dev/null +++ b/tests/Test-noop.px @@ -0,0 +1,56 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $index = < + + Page Title + + +

Page Title

+

+ Some text here. +

+ + +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 + -- 2.39.2