Mercurial > hg > nginx-tests
changeset 908:adf5671391ac
Tests: use read_file subroutine in several tests.
author | Andrey Zelenkov <zelenkov@nginx.com> |
---|---|
date | Mon, 18 Apr 2016 19:29:57 +0300 |
parents | 44f37197181f |
children | 9045591d4304 |
files | access_log.t http_variables.t image_filter.t proxy_protocol.t ssl_proxy_protocol.t |
diffstat | 5 files changed, 7 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/access_log.t +++ b/access_log.t @@ -188,7 +188,7 @@ is($t->read_file('complex.log'), $exp_co # buffer created with false "if" is not reused among multiple access_log -$log = $t->read_file('/noreuse.log'); +$log = $t->read_file('noreuse.log'); is($log, "/filtered/noreuse1/good:200\n/filtered/noreuse2/good:200\n", 'log filtering with buffering');
--- a/http_variables.t +++ b/http_variables.t @@ -74,16 +74,7 @@ http_get('/redefine'); $t->stop(); -my $log; - -{ - open LOG, $t->testdir() . '/cc.log' - or die("Can't open nginx access log file.\n"); - local $/; - $log = <LOG>; - close LOG; -} - +my $log = $t->read_file('cc.log'); like($log, qr!^: -$!m, 'no uri'); like($log, qr!^/: -$!m, 'no header'); like($log, qr!^/set: max-age=3600[,;] private[,;] must-revalidate$!m,
--- a/image_filter.t +++ b/image_filter.t @@ -176,7 +176,7 @@ my $black = $im->colorAllocate(0, 0, 0); $t->write_file('png', $im->png); $t->write_file('txt', 'SEE-THIS'); -$t->run_daemon(\&http_daemon, $t->testdir()); +$t->run_daemon(\&http_daemon, $t); $t->run()->waitforsocket('127.0.0.1:8081'); ############################################################################### @@ -298,7 +298,7 @@ sub has_gdversion { # serve static files without Content-Length sub http_daemon { - my ($root) = @_; + my ($t) = @_; my $server = IO::Socket::INET->new( Proto => 'tcp', @@ -324,11 +324,7 @@ sub http_daemon { next if $headers eq ''; $uri = $1 if $headers =~ /^\S+\s+([^ ]+)\s+HTTP/i; - - open my $fh, '<', $root . $uri or next; - local $/; - my $data = <$fh>; - close $fh; + my $data = $t->read_file($uri); print $client <<EOF; HTTP/1.1 200 OK
--- a/proxy_protocol.t +++ b/proxy_protocol.t @@ -115,16 +115,7 @@ like($r, qr/403 Forbidden/, 'tcp6 access $t->stop(); -my $log; - -{ - open LOG, $t->testdir() . '/pp.log' - or die("Can't open nginx access log file.\n"); - local $/; - $log = <LOG>; - close LOG; -} - +my $log = $t->read_file('pp.log'); like($log, qr!^192\.0\.2\.1 GET /pp_4!m, 'tcp4 access log'); like($log, qr!^2001:DB8::1 GET /pp_6!mi, 'tcp6 access log');
--- a/ssl_proxy_protocol.t +++ b/ssl_proxy_protocol.t @@ -142,16 +142,7 @@ like($r, qr/403 Forbidden/, 'tcp6 access $t->stop(); -my $log; - -{ - open LOG, $t->testdir() . '/pp.log' - or die("Can't open nginx access log file.\n"); - local $/; - $log = <LOG>; - close LOG; -} - +my $log = $t->read_file('pp.log'); like($log, qr!^192\.0\.2\.1 GET /pp_4!m, 'tcp4 access log'); like($log, qr!^2001:DB8::1 GET /pp_6!mi, 'tcp6 access log');