Mercurial > hg > nginx-tests
comparison access_log.t @ 900:257de77879e8
Tests: added access_log test with binary data.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Mon, 18 Apr 2016 13:56:35 +0300 |
parents | c0c2fc0e7208 |
children | adf5671391ac |
comparison
equal
deleted
inserted
replaced
899:c0c2fc0e7208 | 900:257de77879e8 |
---|---|
19 ############################################################################### | 19 ############################################################################### |
20 | 20 |
21 select STDERR; $| = 1; | 21 select STDERR; $| = 1; |
22 select STDOUT; $| = 1; | 22 select STDOUT; $| = 1; |
23 | 23 |
24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(9) | 24 my $t = Test::Nginx->new()->has(qw/http rewrite/)->plan(10) |
25 ->write_file_expand('nginx.conf', <<'EOF'); | 25 ->write_file_expand('nginx.conf', <<'EOF'); |
26 | 26 |
27 %%TEST_GLOBALS%% | 27 %%TEST_GLOBALS%% |
28 | 28 |
29 daemon off; | 29 daemon off; |
33 | 33 |
34 http { | 34 http { |
35 %%TEST_GLOBALS_HTTP%% | 35 %%TEST_GLOBALS_HTTP%% |
36 | 36 |
37 log_format test "$uri:$status"; | 37 log_format test "$uri:$status"; |
38 log_format binary $binary_remote_addr; | |
38 | 39 |
39 server { | 40 server { |
40 listen 127.0.0.1:8080; | 41 listen 127.0.0.1:8080; |
41 server_name localhost; | 42 server_name localhost; |
42 | 43 |
83 } | 84 } |
84 | 85 |
85 location /varlog { | 86 location /varlog { |
86 access_log %%TESTDIR%%/varlog_${arg_logname} test; | 87 access_log %%TESTDIR%%/varlog_${arg_logname} test; |
87 return 200 OK; | 88 return 200 OK; |
89 } | |
90 | |
91 location /binary { | |
92 access_log %%TESTDIR%%/binary.log binary; | |
88 } | 93 } |
89 } | 94 } |
90 } | 95 } |
91 | 96 |
92 EOF | 97 EOF |
125 http_get('/varlog'); | 130 http_get('/varlog'); |
126 http_get('/varlog?logname='); | 131 http_get('/varlog?logname='); |
127 http_get('/varlog?logname=0'); | 132 http_get('/varlog?logname=0'); |
128 http_get('/varlog?logname=filename'); | 133 http_get('/varlog?logname=filename'); |
129 | 134 |
135 http_get('/binary'); | |
136 | |
130 # wait for file to appear with nonzero size thanks to the flush parameter | 137 # wait for file to appear with nonzero size thanks to the flush parameter |
131 | 138 |
132 for (1 .. 10) { | 139 for (1 .. 10) { |
133 last if -s $t->testdir() . '/compressed.log'; | 140 last if -s $t->testdir() . '/compressed.log'; |
134 select undef, undef, undef, 0.1; | 141 select undef, undef, undef, 0.1; |
196 # test log destinations with variables | 203 # test log destinations with variables |
197 | 204 |
198 is($t->read_file('varlog_0'), "/varlog:200\n", 'varlog literal zero name'); | 205 is($t->read_file('varlog_0'), "/varlog:200\n", 'varlog literal zero name'); |
199 is($t->read_file('varlog_filename'), "/varlog:200\n", 'varlog good name'); | 206 is($t->read_file('varlog_filename'), "/varlog:200\n", 'varlog good name'); |
200 | 207 |
201 ############################################################################### | 208 # binary data is escaped |
209 | |
210 is($t->read_file('binary.log'), "\\x7F\\x00\\x00\\x01\n", 'binary'); | |
211 | |
212 ############################################################################### |