Mercurial > hg > nginx-tests
annotate access_log_escape.t @ 1240:f7eb2875ed45
Tests: avoid interleaved output in Upgrade handling tests.
When the testing script is run in verbose mode by prove that redirects stdout,
a garbled verbose mode line from backend can be produced that incorporates TAP
output of an individual test result, which eventually breaks the testing plan.
Notably, this happens when testing sending multiple frames if backend started
to respond before all frames were received. This is possible due to the line
boundary used as an indicator of last bytes to receive before starting to send.
The fix is to amend the only last frame of many specially, for that purpose.
author | Sergey Kandaurov <pluknet@nginx.com> |
---|---|
date | Wed, 15 Nov 2017 20:16:09 +0300 |
parents | a5f9c878c3ab |
children | 766bcbb632ee |
rev | line source |
---|---|
1097
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
3 # (C) Sergey Kandaurov |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 # (C) Nginx, Inc. |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Tests for access_log with escape parameter. |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
25 my $t = Test::Nginx->new()->has(qw/http/)->plan(2) |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 ->write_file_expand('nginx.conf', <<'EOF'); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
27 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
28 %%TEST_GLOBALS%% |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 daemon off; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 events { |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 } |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 http { |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 %%TEST_GLOBALS_HTTP%% |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 log_format json escape=json $arg_a$arg_b$arg_c; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 log_format default escape=default $arg_a$arg_b$arg_c; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
40 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 server { |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 listen 127.0.0.1:8080; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server_name localhost; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
44 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 access_log %%TESTDIR%%/json.log json; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 access_log %%TESTDIR%%/test.log default; |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 } |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 } |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 EOF |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
51 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 $t->run(); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 ############################################################################### |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 http_get('/?a="1 \\ ' . pack("n", 0x1b1c) . ' "&c=2'); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 $t->stop(); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 TODO: { |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 local $TODO = 'not yet' unless $t->has_version('1.11.8'); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 is($t->read_file('json.log'), '\"1 \\\\ \u001B\u001C \"2' . "\n", 'json'); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 is($t->read_file('test.log'), '\x221 \x5C \x1B\x1C \x22-2' . "\n", 'default'); |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 } |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 |
a5f9c878c3ab
Tests: basic access_log escape tests.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 ############################################################################### |