From f0f56db5cb517a44199b3c9819240c8b0a39b4cd Mon Sep 17 00:00:00 2001 From: Micah Cowan Date: Thu, 12 Jun 2008 02:18:35 -0700 Subject: [PATCH] Don't use hardcoded ports. --- tests/ChangeLog | 25 +++++++++++++++++ tests/FTPServer.pm | 27 ++++++++++++------- tests/FTPTest.pm | 16 +++++++---- tests/HTTPServer.pm | 8 ++++++ tests/HTTPTest.pm | 19 +++++++++---- tests/Test--no-content-disposition-trivial.px | 2 +- tests/Test--no-content-disposition.px | 2 +- tests/Test--spider-fail.px | 2 +- ...pider-r--no-content-disposition-trivial.px | 14 +++++----- .../Test--spider-r--no-content-disposition.px | 14 +++++----- ...Test--spider-r-HTTP-Content-Disposition.px | 14 +++++----- tests/Test--spider-r.px | 14 +++++----- tests/Test--spider.px | 2 +- tests/Test-E-k-K.px | 4 +-- tests/Test-E-k.px | 4 +-- tests/Test-HTTP-Content-Disposition-1.px | 2 +- tests/Test-HTTP-Content-Disposition-2.px | 2 +- tests/Test-HTTP-Content-Disposition.px | 2 +- .../Test-N--no-content-disposition-trivial.px | 2 +- tests/Test-N--no-content-disposition.px | 2 +- tests/Test-N-HTTP-Content-Disposition.px | 2 +- tests/Test-N-current.px | 2 +- tests/Test-N-no-info.px | 2 +- tests/Test-N-old.px | 2 +- tests/Test-N-smaller.px | 2 +- tests/Test-N.px | 2 +- .../Test-O--no-content-disposition-trivial.px | 2 +- tests/Test-O--no-content-disposition.px | 2 +- tests/Test-O-HTTP-Content-Disposition.px | 2 +- tests/Test-O-nonexisting.px | 2 +- tests/Test-O.px | 2 +- tests/Test-Restrict-Lowercase.px | 2 +- tests/Test-Restrict-Uppercase.px | 2 +- tests/Test-auth-basic.px | 2 +- tests/Test-c-full.px | 2 +- tests/Test-c-partial.px | 2 +- tests/Test-c.px | 2 +- tests/Test-ftp.px | 2 +- tests/Test-nonexisting-quiet.px | 2 +- tests/Test-noop.px | 2 +- tests/Test-np.px | 10 +++---- tests/Test-proxied-https-auth.px | 2 +- tests/Test-proxy-auth-basic.px | 2 +- tests/WgetTest.pm.in | 14 ++++++---- 44 files changed, 152 insertions(+), 93 deletions(-) diff --git a/tests/ChangeLog b/tests/ChangeLog index 3ce03f98..9067fdfb 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,5 +1,30 @@ 2008-06-12 Micah Cowan + * FTPServer.pm, FTPTest.pm, HTTPServer.pm, HTTPTest.pm, + Test--no-content-disposition-trivial.px, + Test--no-content-disposition.px, Test--spider-fail.px, + Test--spider-r--no-content-disposition-trivial.px, + Test--spider-r--no-content-disposition.px, + Test--spider-r-HTTP-Content-Disposition.px, Test--spider-r.px, + Test--spider.px, Test-E-k-K.px, Test-E-k.px, + Test-HTTP-Content-Disposition-1.px, + Test-HTTP-Content-Disposition-2.px, + Test-HTTP-Content-Disposition.px, + Test-N--no-content-disposition-trivial.px, + Test-N--no-content-disposition.px, + Test-N-HTTP-Content-Disposition.px, Test-N-current.px, + Test-N-no-info.px, Test-N-old.px, Test-N-smaller.px, Test-N.px, + Test-O--no-content-disposition-trivial.px, + Test-O--no-content-disposition.px, + Test-O-HTTP-Content-Disposition.px, Test-O-nonexisting.px, + Test-O.px, Test-Restrict-Lowercase.px, + Test-Restrict-Uppercase.px, Test-auth-basic.px, Test-c-full.px, + Test-c-partial.px, Test-c.px, Test-ftp.px, + Test-nonexisting-quiet.px, Test-noop.px, Test-np.px, + Test-proxied-https-auth.px, Test-proxy-auth-basic.px, + WgetTest.pm.in: Use whatever ports are available, rather than + hard-coded ones. + * Test-proxied-https-auth.px: Better cleanup, so next test can open the port. diff --git a/tests/FTPServer.pm b/tests/FTPServer.pm index d8ad8b0c..8c7cada7 100644 --- a/tests/FTPServer.pm +++ b/tests/FTPServer.pm @@ -748,7 +748,7 @@ sub __wildcard_to_regex { my %_attr_data = ( # DEFAULT _localAddr => 'localhost', - _localPort => 8021, + _localPort => undef, _reuseAddr => 1, _rootDir => Cwd::getcwd(), ); @@ -781,6 +781,16 @@ sub new { $self->{$attrname} = $self->_default_for($attrname); } } + # create server socket + "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround. + $self->{_server_sock} + = IO::Socket::INET->new (LocalHost => $self->{_localAddr}, + LocalPort => $self->{_localPort}, + Listen => 1, + Reuse => $self->{_reuseAddr}, + Proto => 'tcp', + Type => SOCK_STREAM) + or die "bind: $!"; return $self; } @@ -803,21 +813,13 @@ sub run my $old_ils = $/; $/ = "\r\n"; - # create server socket - "0" =~ /(0)/; # Perl 5.7 / IO::Socket::INET bug workaround. - my $server_sock = IO::Socket::INET->new (LocalHost => $self->{_localAddr}, - LocalPort => $self->{_localPort}, - Listen => 1, - Reuse => $self->{_reuseAddr}, - Proto => 'tcp', - Type => SOCK_STREAM) or die "bind: $!"; - if (!$initialized) { $synch_callback->(); $initialized = 1; } $SIG{CHLD} = sub { wait }; + my $server_sock = $self->{_server_sock}; # the accept loop while (my $client_addr = accept (my $socket, $server_sock)) @@ -929,6 +931,11 @@ sub run $/ = $old_ils; } +sub sockport { + my $self = shift; + return $self->{_server_sock}->sockport; +} + 1; # vim: et ts=4 sw=4 diff --git a/tests/FTPTest.pm b/tests/FTPTest.pm index 0e9e0715..eed2eb89 100644 --- a/tests/FTPTest.pm +++ b/tests/FTPTest.pm @@ -44,18 +44,24 @@ sub _setup_server { close (FILE); } + + $self->{_server} = FTPServer->new (LocalAddr => 'localhost', + ReuseAddr => 1, + rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!"; } sub _launch_server { my $self = shift; my $synch_func = shift; + $self->{_server}->run ($synch_func); +} - my $server = FTPServer->new (LocalAddr => 'localhost', - LocalPort => '8021', - ReuseAddr => 1, - rootDir => "$self->{_workdir}/$self->{_name}/input") or die "Cannot create server!!!"; - $server->run ($synch_func); +sub _substitute_port { + my $self = shift; + my $ret = shift; + $ret =~ s/{{port}}/$self->{_server}->sockport/eg; + return $ret; } 1; diff --git a/tests/HTTPServer.pm b/tests/HTTPServer.pm index a307b737..dbfa3ef1 100644 --- a/tests/HTTPServer.pm +++ b/tests/HTTPServer.pm @@ -120,6 +120,7 @@ sub send_response { next; } # fill in content + $content = $self->_substitute_port($content); $resp->content($content); print STDERR "HTTP::Response with content: \n", $resp->as_string if $log; } @@ -207,6 +208,13 @@ sub verify_auth_basic { } } +sub _substitute_port { + my $self = shift; + my $ret = shift; + $ret =~ s/{{port}}/$self->sockport/eg; + return $ret; +} + 1; # vim: et ts=4 sw=4 diff --git a/tests/HTTPTest.pm b/tests/HTTPTest.pm index cd4fb2e2..0fdcb8f0 100644 --- a/tests/HTTPTest.pm +++ b/tests/HTTPTest.pm @@ -30,17 +30,26 @@ my $VERSION = 0.01; } -sub _setup_server {} +sub _setup_server { + my $self = shift; + $self->{_server} = HTTPServer->new (LocalAddr => 'localhost', + ReuseAddr => 1) + or die "Cannot create server!!!"; +} sub _launch_server { my $self = shift; my $synch_func = shift; - my $server = HTTPServer->new (LocalAddr => 'localhost', - LocalPort => '8080', - ReuseAddr => 1) or die "Cannot create server!!!"; - $server->run ($self->{_input}, $synch_func); + $self->{_server}->run ($self->{_input}, $synch_func); +} + +sub _substitute_port { + my $self = shift; + my $ret = shift; + $ret =~ s/{{port}}/$self->{_server}->sockport/eg; + return $ret; } 1; diff --git a/tests/Test--no-content-disposition-trivial.px b/tests/Test--no-content-disposition-trivial.px index 1d64125a..6a5b1def 100755 --- a/tests/Test--no-content-disposition-trivial.px +++ b/tests/Test--no-content-disposition-trivial.px @@ -32,7 +32,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html"; +my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html"; my $expected_error_code = 0; diff --git a/tests/Test--no-content-disposition.px b/tests/Test--no-content-disposition.px index d5433f00..4975913b 100755 --- a/tests/Test--no-content-disposition.px +++ b/tests/Test--no-content-disposition.px @@ -33,7 +33,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html"; +my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html"; my $expected_error_code = 0; diff --git a/tests/Test--spider-fail.px b/tests/Test--spider-fail.px index c5a299d1..b30ef755 100755 --- a/tests/Test--spider-fail.px +++ b/tests/Test--spider-fail.px @@ -32,7 +32,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/nonexistent"; +my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:{{port}}/nonexistent"; my $expected_error_code = 256; diff --git a/tests/Test--spider-r--no-content-disposition-trivial.px b/tests/Test--spider-r--no-content-disposition-trivial.px index 0e290c28..1e850d40 100755 --- a/tests/Test--spider-r--no-content-disposition-trivial.px +++ b/tests/Test--spider-r--no-content-disposition-trivial.px @@ -14,8 +14,8 @@ my $mainpage = <

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

@@ -28,8 +28,8 @@ my $secondpage = <

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

@@ -42,8 +42,8 @@ my $thirdpage = <

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

@@ -89,7 +89,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:8080/"; +my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:{{port}}/"; my $expected_error_code = 0; diff --git a/tests/Test--spider-r--no-content-disposition.px b/tests/Test--spider-r--no-content-disposition.px index 0e3c00ed..4eba8579 100755 --- a/tests/Test--spider-r--no-content-disposition.px +++ b/tests/Test--spider-r--no-content-disposition.px @@ -14,8 +14,8 @@ my $mainpage = <

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

@@ -28,8 +28,8 @@ my $secondpage = <

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

@@ -42,8 +42,8 @@ my $thirdpage = <

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

@@ -90,7 +90,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:8080/"; +my $cmdline = $WgetTest::WGETPATH . " --spider -r --no-content-disposition http://localhost:{{port}}/"; my $expected_error_code = 0; diff --git a/tests/Test--spider-r-HTTP-Content-Disposition.px b/tests/Test--spider-r-HTTP-Content-Disposition.px index e70f6b40..09f93fa3 100755 --- a/tests/Test--spider-r-HTTP-Content-Disposition.px +++ b/tests/Test--spider-r-HTTP-Content-Disposition.px @@ -14,8 +14,8 @@ my $mainpage = <

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

@@ -28,8 +28,8 @@ my $secondpage = <

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

@@ -42,8 +42,8 @@ my $thirdpage = <

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

@@ -90,7 +90,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:8080/"; +my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:{{port}}/"; my $expected_error_code = 0; diff --git a/tests/Test--spider-r.px b/tests/Test--spider-r.px index 7b8d460f..a315d974 100755 --- a/tests/Test--spider-r.px +++ b/tests/Test--spider-r.px @@ -14,8 +14,8 @@ my $mainpage = <

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

@@ -28,8 +28,8 @@ my $secondpage = <

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

@@ -42,8 +42,8 @@ my $thirdpage = <

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

@@ -89,7 +89,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:8080/"; +my $cmdline = $WgetTest::WGETPATH . " --spider -r http://localhost:{{port}}/"; my $expected_error_code = 0; diff --git a/tests/Test--spider.px b/tests/Test--spider.px index f412c762..dbc97135 100755 --- a/tests/Test--spider.px +++ b/tests/Test--spider.px @@ -32,7 +32,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:8080/index.html"; +my $cmdline = $WgetTest::WGETPATH . " --spider http://localhost:{{port}}/index.html"; my $expected_error_code = 0; diff --git a/tests/Test-E-k-K.px b/tests/Test-E-k-K.px index 71d51ea1..d71c39e5 100755 --- a/tests/Test-E-k-K.px +++ b/tests/Test-E-k-K.px @@ -13,7 +13,7 @@ my $mainpage = <Main Page Title - Secondary Page + Secondary Page EOF @@ -60,7 +60,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -d -r -nd -E -k -K http://localhost:8080/index.php"; +my $cmdline = $WgetTest::WGETPATH . " -d -r -nd -E -k -K http://localhost:{{port}}/index.php"; my $expected_error_code = 0; diff --git a/tests/Test-E-k.px b/tests/Test-E-k.px index 3bf441df..4581ed71 100755 --- a/tests/Test-E-k.px +++ b/tests/Test-E-k.px @@ -13,7 +13,7 @@ my $mainpage = <Main Page Title - Secondary Page + Secondary Page EOF @@ -60,7 +60,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -r -nd -E -k http://localhost:8080/index.php"; +my $cmdline = $WgetTest::WGETPATH . " -r -nd -E -k http://localhost:{{port}}/index.php"; my $expected_error_code = 0; diff --git a/tests/Test-HTTP-Content-Disposition-1.px b/tests/Test-HTTP-Content-Disposition-1.px index ffc9eb25..01fb0901 100755 --- a/tests/Test-HTTP-Content-Disposition-1.px +++ b/tests/Test-HTTP-Content-Disposition-1.px @@ -37,7 +37,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:8080/dummy.html"; +my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:{{port}}/dummy.html"; my $expected_error_code = 0; diff --git a/tests/Test-HTTP-Content-Disposition-2.px b/tests/Test-HTTP-Content-Disposition-2.px index 03eb2bee..46c16a17 100755 --- a/tests/Test-HTTP-Content-Disposition-2.px +++ b/tests/Test-HTTP-Content-Disposition-2.px @@ -37,7 +37,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:8080/dummy.html"; +my $cmdline = $WgetTest::WGETPATH . " --no-content-disposition http://localhost:{{port}}/dummy.html"; my $expected_error_code = 0; diff --git a/tests/Test-HTTP-Content-Disposition.px b/tests/Test-HTTP-Content-Disposition.px index 0f4b285b..3b6eb2c9 100755 --- a/tests/Test-HTTP-Content-Disposition.px +++ b/tests/Test-HTTP-Content-Disposition.px @@ -33,7 +33,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:8080/dummy.html"; +my $cmdline = $WgetTest::WGETPATH . " -e contentdisposition=on http://localhost:{{port}}/dummy.html"; my $expected_error_code = 0; diff --git a/tests/Test-N--no-content-disposition-trivial.px b/tests/Test-N--no-content-disposition-trivial.px index 390d369b..c58f451a 100755 --- a/tests/Test-N--no-content-disposition-trivial.px +++ b/tests/Test-N--no-content-disposition-trivial.px @@ -24,7 +24,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N--no-content-disposition.px b/tests/Test-N--no-content-disposition.px index dbec7c67..78fe522f 100755 --- a/tests/Test-N--no-content-disposition.px +++ b/tests/Test-N--no-content-disposition.px @@ -25,7 +25,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N --no-content-disposition http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N-HTTP-Content-Disposition.px b/tests/Test-N-HTTP-Content-Disposition.px index 42aa39ad..32f87710 100755 --- a/tests/Test-N-HTTP-Content-Disposition.px +++ b/tests/Test-N-HTTP-Content-Disposition.px @@ -26,7 +26,7 @@ my %urls = ( ); my $cmdline = $WgetTest::WGETPATH . " -N --content-disposition " - . "http://localhost:8080/dummy.txt"; + . "http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N-current.px b/tests/Test-N-current.px index 16086ae8..b8e05a94 100755 --- a/tests/Test-N-current.px +++ b/tests/Test-N-current.px @@ -33,7 +33,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N-no-info.px b/tests/Test-N-no-info.px index bd83f644..301a9101 100755 --- a/tests/Test-N-no-info.px +++ b/tests/Test-N-no-info.px @@ -32,7 +32,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N-old.px b/tests/Test-N-old.px index ee9a84e0..6ae116e5 100755 --- a/tests/Test-N-old.px +++ b/tests/Test-N-old.px @@ -31,7 +31,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N-smaller.px b/tests/Test-N-smaller.px index 9ad44c29..71e34d96 100755 --- a/tests/Test-N-smaller.px +++ b/tests/Test-N-smaller.px @@ -34,7 +34,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-N.px b/tests/Test-N.px index 61069875..2e235e08 100755 --- a/tests/Test-N.px +++ b/tests/Test-N.px @@ -24,7 +24,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -N http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-O--no-content-disposition-trivial.px b/tests/Test-O--no-content-disposition-trivial.px index be25960c..501fd44d 100755 --- a/tests/Test-O--no-content-disposition-trivial.px +++ b/tests/Test-O--no-content-disposition-trivial.px @@ -23,7 +23,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-O--no-content-disposition.px b/tests/Test-O--no-content-disposition.px index 47cab071..592f0fec 100755 --- a/tests/Test-O--no-content-disposition.px +++ b/tests/Test-O--no-content-disposition.px @@ -24,7 +24,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -O out --no-content-disposition http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-O-HTTP-Content-Disposition.px b/tests/Test-O-HTTP-Content-Disposition.px index b0a5aa40..934f54aa 100755 --- a/tests/Test-O-HTTP-Content-Disposition.px +++ b/tests/Test-O-HTTP-Content-Disposition.px @@ -24,7 +24,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-O-nonexisting.px b/tests/Test-O-nonexisting.px index 347dc38e..89744fc8 100755 --- a/tests/Test-O-nonexisting.px +++ b/tests/Test-O-nonexisting.px @@ -23,7 +23,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --quiet -O out http://localhost:8080/nonexistent"; +my $cmdline = $WgetTest::WGETPATH . " --quiet -O out http://localhost:{{port}}/nonexistent"; my $expected_error_code = 256; diff --git a/tests/Test-O.px b/tests/Test-O.px index e584d060..1f4e8efe 100755 --- a/tests/Test-O.px +++ b/tests/Test-O.px @@ -23,7 +23,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:8080/dummy.txt"; +my $cmdline = $WgetTest::WGETPATH . " -O out http://localhost:{{port}}/dummy.txt"; my $expected_error_code = 0; diff --git a/tests/Test-Restrict-Lowercase.px b/tests/Test-Restrict-Lowercase.px index fab08d43..2b35f1e4 100755 --- a/tests/Test-Restrict-Lowercase.px +++ b/tests/Test-Restrict-Lowercase.px @@ -32,7 +32,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=lowercase http://localhost:8080/SomePage.html"; +my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=lowercase http://localhost:{{port}}/SomePage.html"; my $expected_error_code = 0; diff --git a/tests/Test-Restrict-Uppercase.px b/tests/Test-Restrict-Uppercase.px index cefa1722..14fa81f4 100755 --- a/tests/Test-Restrict-Uppercase.px +++ b/tests/Test-Restrict-Uppercase.px @@ -32,7 +32,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=uppercase http://localhost:8080/SomePage.html"; +my $cmdline = $WgetTest::WGETPATH . " --restrict-file-names=uppercase http://localhost:{{port}}/SomePage.html"; my $expected_error_code = 0; diff --git a/tests/Test-auth-basic.px b/tests/Test-auth-basic.px index 527d4200..75013609 100755 --- a/tests/Test-auth-basic.px +++ b/tests/Test-auth-basic.px @@ -25,7 +25,7 @@ my %urls = ( ); my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee --password=Dodgson" - . " http://localhost:8080/needs-auth.txt"; + . " http://localhost:{{port}}/needs-auth.txt"; my $expected_error_code = 0; diff --git a/tests/Test-c-full.px b/tests/Test-c-full.px index bb9304b9..f277a023 100755 --- a/tests/Test-c-full.px +++ b/tests/Test-c-full.px @@ -27,7 +27,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-c-partial.px b/tests/Test-c-partial.px index ddf1d4be..02234242 100755 --- a/tests/Test-c-partial.px +++ b/tests/Test-c-partial.px @@ -37,7 +37,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-c.px b/tests/Test-c.px index 58b45f72..8c61eb06 100755 --- a/tests/Test-c.px +++ b/tests/Test-c.px @@ -27,7 +27,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:8080/somefile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-ftp.px b/tests/Test-ftp.px index 5925e38b..8cef5a55 100755 --- a/tests/Test-ftp.px +++ b/tests/Test-ftp.px @@ -21,7 +21,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:8021/afile.txt"; +my $cmdline = $WgetTest::WGETPATH . " -S ftp://localhost:{{port}}/afile.txt"; my $expected_error_code = 0; diff --git a/tests/Test-nonexisting-quiet.px b/tests/Test-nonexisting-quiet.px index 45f24390..2766b5c5 100755 --- a/tests/Test-nonexisting-quiet.px +++ b/tests/Test-nonexisting-quiet.px @@ -23,7 +23,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " --quiet http://localhost:8080/nonexistent"; +my $cmdline = $WgetTest::WGETPATH . " --quiet http://localhost:{{port}}/nonexistent"; my $expected_error_code = 256; diff --git a/tests/Test-noop.px b/tests/Test-noop.px index e45c8af3..14bd851c 100755 --- a/tests/Test-noop.px +++ b/tests/Test-noop.px @@ -33,7 +33,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " http://localhost:8080/"; +my $cmdline = $WgetTest::WGETPATH . " http://localhost:{{port}}/"; my $expected_error_code = 0; diff --git a/tests/Test-np.px b/tests/Test-np.px index 8a14b32d..28d13eec 100755 --- a/tests/Test-np.px +++ b/tests/Test-np.px @@ -14,7 +14,7 @@ my $mainpage = <

- Some text and a link to a second page. + Some text and a link to a second page.

@@ -27,7 +27,7 @@ my $secondpage = <

- Some text and a link to a third page. + Some text and a link to a third page.

@@ -40,7 +40,7 @@ my $thirdpage = <

- Some text and a link to a higher level page. + Some text and a link to a higher level page.

@@ -69,7 +69,7 @@ my $higherlevelpage = < This page is on a higher level in the URL path hierarchy. Therefore, it should not be downloaded. Wget should not visit the following link to a - fourth page. + fourth page.

@@ -119,7 +119,7 @@ my %urls = ( }, ); -my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:8080/firstlevel/"; +my $cmdline = $WgetTest::WGETPATH . " -np -nH -r http://localhost:{{port}}/firstlevel/"; my $expected_error_code = 0; diff --git a/tests/Test-proxied-https-auth.px b/tests/Test-proxied-https-auth.px index b1de60b9..b732d553 100755 --- a/tests/Test-proxied-https-auth.px +++ b/tests/Test-proxied-https-auth.px @@ -91,7 +91,7 @@ my $pid = &fork_server; sleep 1; my $cmdline = $WgetTest::WGETPATH . " --user=fiddle-dee-dee" - . " --password=Dodgson -e https_proxy=localhost:8080" + . " --password=Dodgson -e https_proxy=localhost:{{port}}" . " --no-check-certificate" . " https://no.such.domain/needs-auth.txt"; diff --git a/tests/Test-proxy-auth-basic.px b/tests/Test-proxy-auth-basic.px index 5566e22f..e440a392 100755 --- a/tests/Test-proxy-auth-basic.px +++ b/tests/Test-proxy-auth-basic.px @@ -25,7 +25,7 @@ my %urls = ( ); my $cmdline = $WgetTest::WGETPATH . " --debug --user=fiddle-dee-dee --password=Dodgson" - . " -e http_proxy=localhost:8080 http://no.such.domain/needs-auth.txt"; + . " -e http_proxy=localhost:{{port}} http://no.such.domain/needs-auth.txt"; my $expected_error_code = 0; diff --git a/tests/WgetTest.pm.in b/tests/WgetTest.pm.in index 915759df..357babe1 100644 --- a/tests/WgetTest.pm.in +++ b/tests/WgetTest.pm.in @@ -78,11 +78,13 @@ sub run { # Call wget chdir ("$self->{_workdir}/$self->{_name}/output"); - # print "Calling $self->{_cmdline}\n"; + my $cmdline = $self->{_cmdline}; + $cmdline = $self->_substitute_port($cmdline); + print "Calling $cmdline\n"; my $errcode = - ($self->{_cmdline} =~ m{^/.*}) - ? system ($self->{_cmdline}) - : system ("$self->{_workdir}/../src/$self->{_cmdline}"); + ($cmdline =~ m{^/.*}) + ? system ($cmdline) + : system ("$self->{_workdir}/../src/$cmdline"); # Shutdown server # if we didn't explicitely kill the server, we would have to call @@ -166,7 +168,9 @@ sub _verify_download { or return "Test failed: file $filename not downloaded\n"; my $content = ; - $content eq $filedata->{'content'} + my $expected_content = $filedata->{'content'}; + $expected_content = $self->_substitute_port($expected_content); + $content eq $expected_content or return "Test failed: wrong content for file $filename\n"; if (exists($filedata->{'timestamp'})) { -- 2.39.2