From 9561f6bd2beb0a165a713ace7a583760f38d154c Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Thu, 22 May 2008 23:14:05 -0700 Subject: [PATCH 01/12] Perl script to manage running of .px tests. --- tests/Makefile.am | 41 +----------------------------- tests/run-px | 65 +++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 66 insertions(+), 40 deletions(-) create mode 100755 tests/run-px diff --git a/tests/Makefile.am b/tests/Makefile.am index fefdbf1d..85369828 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -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/run-px b/tests/run-px new file mode 100755 index 00000000..e1b3be74 --- /dev/null +++ b/tests/run-px @@ -0,0 +1,65 @@ +#!/usr/bin/env perl +use warnings; + +die "Please specify the top source directory.\n" if (!@ARGV); +my $top_srcdir = shift @ARGV; + +my @tests = ( + 'Test-proxied-https-auth.px', + 'Test-proxy-auth-basic.px', + 'Test-auth-basic.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-HTTP-CD.px', + 'Test-N-current.px', + 'Test-N-HTTP-Content-Disposition.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-HTTP-Content-Disposition.px', + 'Test--spider--no-content-disposition.px', + 'Test--spider--no-content-disposition-trivial.px', + 'Test--spider.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"; +} From 3323ed3c171bc2c59ede9f499eb1ce50d48bde20 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Thu, 22 May 2008 23:40:56 -0700 Subject: [PATCH 02/12] Avoid re-forking. Fixes bug #20458. --- tests/ChangeLog | 4 ++++ tests/FTPServer.pm | 14 +++++++------- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index f485f93c..757ed339 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2008-05-22 Micah Cowan + + * FTPServer.pm (run): Avoid re-forking. Fixes bug #20458. + 2008-04-26 Micah Cowan * Makefile.am, Test-proxied-https-auth.px: Added a test for diff --git a/tests/FTPServer.pm b/tests/FTPServer.pm index 7c7f3e58..d8ad8b0c 100644 --- a/tests/FTPServer.pm +++ b/tests/FTPServer.pm @@ -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; - } + # my $pid = fork(); + # unless (defined $pid) { + # warn "fork: $!"; + # sleep 5; # Back off in case system is overloaded. + # next; + # } - if ($pid == 0) { # Child process. + if (1) { # Child process. # install signals $SIG{URG} = sub { From aaf50d9a0fd5f99ad96f439b303b05888dec48c0 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Thu, 22 May 2008 23:49:05 -0700 Subject: [PATCH 03/12] ChangeLog entry for new run-px script. --- tests/ChangeLog | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tests/ChangeLog b/tests/ChangeLog index 757ed339..93f2aa82 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,10 @@ 2008-05-22 Micah Cowan + * 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 From fb648cb8a622983fc2d06e90f7764a2da2905584 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Thu, 22 May 2008 23:59:28 -0700 Subject: [PATCH 04/12] Removing --spider--no-content... tests. --- ...-spider--no-content-disposition-trivial.px | 52 ------------------ tests/Test--spider--no-content-disposition.px | 53 ------------------- tests/Test-N-HTTP-Content-Disposition.px | 3 +- tests/run-px | 15 +++--- 4 files changed, 10 insertions(+), 113 deletions(-) delete mode 100755 tests/Test--spider--no-content-disposition-trivial.px delete mode 100755 tests/Test--spider--no-content-disposition.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 index 323db074..00000000 --- a/tests/Test--spider--no-content-disposition-trivial.px +++ /dev/null @@ -1,52 +0,0 @@ -#!/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 = $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 index acf73a79..00000000 --- a/tests/Test--spider--no-content-disposition.px +++ /dev/null @@ -1,53 +0,0 @@ -#!/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-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-N-HTTP-Content-Disposition.px b/tests/Test-N-HTTP-Content-Disposition.px index 8c5e4181..42aa39ad 100755 --- a/tests/Test-N-HTTP-Content-Disposition.px +++ b/tests/Test-N-HTTP-Content-Disposition.px @@ -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; diff --git a/tests/run-px b/tests/run-px index e1b3be74..76a69dd9 100755 --- a/tests/run-px +++ b/tests/run-px @@ -5,9 +5,11 @@ die "Please specify the top source directory.\n" if (!@ARGV); my $top_srcdir = shift @ARGV; my @tests = ( - 'Test-proxied-https-auth.px', - 'Test-proxy-auth-basic.px', 'Test-auth-basic.px', + 'Test-proxy-auth-basic.px', + 'Test-proxied-https-auth.px', + 'Test-N-HTTP-Content-Disposition.px', + 'Test-c-full.px', 'Test-c-partial.px', 'Test-c.px', @@ -17,9 +19,7 @@ my @tests = ( 'Test-HTTP-Content-Disposition-1.px', 'Test-HTTP-Content-Disposition-2.px', 'Test-HTTP-Content-Disposition.px', - 'Test-N-current-HTTP-CD.px', 'Test-N-current.px', - 'Test-N-HTTP-Content-Disposition.px', 'Test-N--no-content-disposition.px', 'Test-N--no-content-disposition-trivial.px', 'Test--no-content-disposition.px', @@ -38,13 +38,14 @@ my @tests = ( 'Test-Restrict-Uppercase.px', 'Test--spider-fail.px', 'Test--spider-HTTP-Content-Disposition.px', - 'Test--spider--no-content-disposition.px', - 'Test--spider--no-content-disposition-trivial.px', - 'Test--spider.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', +# FAILING: +# 'Test--spider--no-content-disposition.px', +# 'Test--spider--no-content-disposition-trivial.px', +# 'Test--spider.px', ); my @results; From 998ede3a8810a68c9ec7ea9626b9b5ab9fd8ad29 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Fri, 23 May 2008 00:00:55 -0700 Subject: [PATCH 05/12] Test--spider.px expect 0. --- tests/ChangeLog | 4 ++++ tests/Test--spider.px | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 93f2aa82..2f65fd34 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2008-05-23 Micah Cowan + + * Test--spider.px: Make test expect 0 return code. + 2008-05-22 Micah Cowan * Makefile.am (run-px-tests): Replaced ugly list of tests with diff --git a/tests/Test--spider.px b/tests/Test--spider.px index c2c1263e..f412c762 100755 --- a/tests/Test--spider.px +++ b/tests/Test--spider.px @@ -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 = ( ); From 6ed6093dfcdfbae6f74ef96763200e5523cfb0df Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Fri, 23 May 2008 00:04:09 -0700 Subject: [PATCH 06/12] Remove Test--spider-HTTP-Content-Disposition.px. --- .../Test--spider-HTTP-Content-Disposition.px | 53 ------------------- tests/run-px | 6 +-- 2 files changed, 1 insertion(+), 58 deletions(-) delete mode 100755 tests/Test--spider-HTTP-Content-Disposition.px diff --git a/tests/Test--spider-HTTP-Content-Disposition.px b/tests/Test--spider-HTTP-Content-Disposition.px deleted file mode 100755 index 79eaba5a..00000000 --- a/tests/Test--spider-HTTP-Content-Disposition.px +++ /dev/null @@ -1,53 +0,0 @@ -#!/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-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 - diff --git a/tests/run-px b/tests/run-px index 76a69dd9..fd1c40ac 100755 --- a/tests/run-px +++ b/tests/run-px @@ -9,6 +9,7 @@ my @tests = ( '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', @@ -37,15 +38,10 @@ my @tests = ( 'Test-Restrict-Lowercase.px', 'Test-Restrict-Uppercase.px', 'Test--spider-fail.px', - 'Test--spider-HTTP-Content-Disposition.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', -# FAILING: -# 'Test--spider--no-content-disposition.px', -# 'Test--spider--no-content-disposition-trivial.px', -# 'Test--spider.px', ); my @results; From 0273ca4988992ec12f0aa399466da5bbe2bebbe9 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 31 May 2008 12:48:23 -0700 Subject: [PATCH 07/12] Catch failures in Test-N-current.px. --- tests/ChangeLog | 4 ++++ tests/Test-N-current.px | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 2f65fd34..3a6b8052 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2008-05-31 Micah Cowan + + * Test-N-current.px: Ensure we catch failures. + 2008-05-23 Micah Cowan * Test--spider.px: Make test expect 0 return code. diff --git a/tests/Test-N-current.px b/tests/Test-N-current.px index 47003c7e..16086ae8 100755 --- a/tests/Test-N-current.px +++ b/tests/Test-N-current.px @@ -15,6 +15,11 @@ my $currentversion = < { @@ -24,7 +29,7 @@ my %urls = ( "Content-type" => "text/plain", "Last-Modified" => "Sat, 09 Oct 2004 08:30:00 GMT", }, - content => $currentversion, + content => $modifiedversion, }, ); From dafa700868765162f038c2fb2ae5ba299b4a8117 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 31 May 2008 12:56:12 -0700 Subject: [PATCH 08/12] Test just the timestamp, not length. --- tests/ChangeLog | 2 ++ tests/Test-N-old.px | 8 +++----- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 3a6b8052..6d381b4e 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,6 +1,8 @@ 2008-05-31 Micah Cowan * 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. 2008-05-23 Micah Cowan diff --git a/tests/Test-N-old.px b/tests/Test-N-old.px index 05383dbe..ee9a84e0 100755 --- a/tests/Test-N-old.px +++ b/tests/Test-N-old.px @@ -10,16 +10,14 @@ use HTTPTest; my $oldversion = < { From f6acc704426d67c8a5ae3715ce48b203fb7f756c Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 31 May 2008 13:22:15 -0700 Subject: [PATCH 09/12] Test-N-smaller.px. --- tests/ChangeLog | 2 ++ tests/Test-N-smaller.px | 66 +++++++++++++++++++++++++++++++++++++++++ tests/run-px | 2 +- 3 files changed, 69 insertions(+), 1 deletion(-) create mode 100755 tests/Test-N-smaller.px diff --git a/tests/ChangeLog b/tests/ChangeLog index 6d381b4e..8c40d082 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -3,6 +3,8 @@ * 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: added. + * run-px: Added Test-N-smaller.px. 2008-05-23 Micah Cowan diff --git a/tests/Test-N-smaller.px b/tests/Test-N-smaller.px new file mode 100755 index 00000000..9ad44c29 --- /dev/null +++ b/tests/Test-N-smaller.px @@ -0,0 +1,66 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $currentversion = < { + 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 + diff --git a/tests/run-px b/tests/run-px index fd1c40ac..7cab7531 100755 --- a/tests/run-px +++ b/tests/run-px @@ -10,7 +10,6 @@ my @tests = ( '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', @@ -21,6 +20,7 @@ my @tests = ( 'Test-HTTP-Content-Disposition-2.px', 'Test-HTTP-Content-Disposition.px', 'Test-N-current.px', + 'Test-N-smaller.px', 'Test-N--no-content-disposition.px', 'Test-N--no-content-disposition-trivial.px', 'Test--no-content-disposition.px', From e17633e99c3eff326ace71ed6970c491aa42845c Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 31 May 2008 13:31:05 -0700 Subject: [PATCH 10/12] Test-N-no-info.px --- tests/ChangeLog | 3 +- tests/Test-N-no-info.px | 63 +++++++++++++++++++++++++++++++++++++++++ tests/run-px | 1 + 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100755 tests/Test-N-no-info.px diff --git a/tests/ChangeLog b/tests/ChangeLog index 8c40d082..f076a274 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -4,7 +4,8 @@ * Test-N-old.px: Make it test only the timestamp, and not the content length in addition. * Test-N-smaller.px: added. - * run-px: Added Test-N-smaller.px. + * Test-N-no-info.px: added. + * run-px: Added Test-N-smaller.px, Test-N-no-info.px. 2008-05-23 Micah Cowan diff --git a/tests/Test-N-no-info.px b/tests/Test-N-no-info.px new file mode 100755 index 00000000..bd83f644 --- /dev/null +++ b/tests/Test-N-no-info.px @@ -0,0 +1,63 @@ +#!/usr/bin/perl -w + +use strict; + +use HTTPTest; + + +############################################################################### + +my $currentversion = < { + 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 + diff --git a/tests/run-px b/tests/run-px index 7cab7531..febb0de4 100755 --- a/tests/run-px +++ b/tests/run-px @@ -21,6 +21,7 @@ my @tests = ( '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', From 26df27352221bad3b8bcc539be55a2ad4221f9a7 Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 31 May 2008 17:38:58 -0700 Subject: [PATCH 11/12] Returh 416 for fully-retrieved resources. --- tests/ChangeLog | 7 +++++++ tests/HTTPServer.pm | 28 +++++++++++++++++++--------- 2 files changed, 26 insertions(+), 9 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index f076a274..eae26707 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,12 +1,19 @@ 2008-05-31 Micah Cowan * 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: added. + * Test-N-no-info.px: added. + * 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 * Test--spider.px: Make test expect 0 return code. diff --git a/tests/HTTPServer.pm b/tests/HTTPServer.pm index 97e91396..a307b737 100644 --- a/tests/HTTPServer.pm +++ b/tests/HTTPServer.pm @@ -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 From 6d88509ab55f54d9b76be4fcb7d2ac0da810b2bd Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Sat, 31 May 2008 18:17:45 -0700 Subject: [PATCH 12/12] Test-c-partial.px improvement. --- tests/ChangeLog | 5 +++-- tests/Test-c-partial.px | 15 ++++++++++----- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index eae26707..73d93a2f 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -5,9 +5,10 @@ * Test-N-old.px: Make it test only the timestamp, and not the content length in addition. - * Test-N-smaller.px: added. + * Test-N-smaller.px, Test-N-no-info.px: added. - * 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. diff --git a/tests/Test-c-partial.px b/tests/Test-c-partial.px index ee48cbf6..ddf1d4be 100755 --- a/tests/Test-c-partial.px +++ b/tests/Test-c-partial.px @@ -9,17 +9,22 @@ use HTTPTest; my $partiallydownloaded = < { @@ -44,7 +49,7 @@ my %existing_files = ( my %expected_downloaded_files = ( 'somefile.txt' => { - content => $wholefile, + content => $downloadedfile, }, );