Mercurial > hg > nginx-tests
annotate error_log.t @ 1990:85d88cd5091c
Tests: SSI include stub tests.
author | Maxim Dounin <mdounin@mdounin.ru> |
---|---|
date | Thu, 04 Jul 2024 17:42:55 +0300 |
parents | 38f1fd9ca3e6 |
children |
rev | line source |
---|---|
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
1 #!/usr/bin/perl |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
2 |
303
ad51e58c2d7a
Tests: fixed typo in copyright.
Sergey Kandaurov <pluknet@nginx.com>
parents:
300
diff
changeset
|
3 # (C) Nginx, Inc. |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
4 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
5 # Tests for error_log. |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
6 # Various log levels emitted with limit_req_log_level. |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
7 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
8 ############################################################################### |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
9 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
10 use warnings; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
11 use strict; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
12 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
13 use Test::More; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
14 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
15 BEGIN { use FindBin; chdir($FindBin::Bin); } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
16 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
17 use lib 'lib'; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
18 use Test::Nginx; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
19 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
20 ############################################################################### |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
21 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
22 select STDERR; $| = 1; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
23 select STDOUT; $| = 1; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
24 |
334
c0bd624db067
Tests: disable error_log.t on win32 as it uses shared memory.
Maxim Dounin <mdounin@mdounin.ru>
parents:
303
diff
changeset
|
25 plan(skip_all => 'win32') if $^O eq 'MSWin32'; |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
26 |
623
b70df6924290
Tests: removed unnecessary imports, lifted up skip condition.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
503
diff
changeset
|
27 my $t = Test::Nginx->new()->has(qw/http limit_req/) |
b70df6924290
Tests: removed unnecessary imports, lifted up skip condition.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
503
diff
changeset
|
28 ->plan(25)->write_file_expand('nginx.conf', <<'EOF'); |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
29 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
30 %%TEST_GLOBALS%% |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
31 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
32 daemon off; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
33 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
34 events { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
35 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
36 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
37 http { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
38 %%TEST_GLOBALS_HTTP%% |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
39 |
503
071e8941e3bf
Tests: reduce shared memory zone sizes.
Maxim Dounin <mdounin@mdounin.ru>
parents:
397
diff
changeset
|
40 limit_req_zone $binary_remote_addr zone=one:1m rate=1r/m; |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
41 limit_req zone=one; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
42 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
43 server { |
974
882267679006
Tests: simplified parallel modifications in tests.
Andrey Zelenkov <zelenkov@nginx.com>
parents:
952
diff
changeset
|
44 listen 127.0.0.1:8080; |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
45 server_name localhost; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
46 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
47 location /debug { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
48 error_log %%TESTDIR%%/e_debug_debug.log debug; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
49 error_log %%TESTDIR%%/e_debug_info.log info; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
50 error_log stderr debug; |
343
e7dc8f4d0a4b
Tests: whitespace and spelling fixes.
Sergey Kandaurov <pluknet@nginx.com>
parents:
334
diff
changeset
|
51 } |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
52 location /info { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
53 limit_req_log_level info; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
54 error_log %%TESTDIR%%/e_info_debug.log debug; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
55 error_log %%TESTDIR%%/e_info_info.log info; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
56 error_log %%TESTDIR%%/e_info_notice.log notice; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
57 error_log stderr info; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
58 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
59 location /notice { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
60 limit_req_log_level notice; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
61 error_log %%TESTDIR%%/e_notice_info.log info; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
62 error_log %%TESTDIR%%/e_notice_notice.log notice; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
63 error_log %%TESTDIR%%/e_notice_warn.log warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
64 error_log stderr notice; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
65 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
66 location /warn { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
67 limit_req_log_level warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
68 error_log %%TESTDIR%%/e_warn_notice.log notice; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
69 error_log %%TESTDIR%%/e_warn_warn.log warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
70 error_log %%TESTDIR%%/e_warn_error.log error; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
71 error_log stderr warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
72 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
73 location /error { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
74 error_log %%TESTDIR%%/e_error_warn.log warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
75 error_log %%TESTDIR%%/e_error_error.log; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
76 error_log %%TESTDIR%%/e_error_alert.log alert; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
77 error_log stderr; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
78 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
79 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
80 location /file_low { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
81 error_log %%TESTDIR%%/e_multi_low.log warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
82 error_log %%TESTDIR%%/e_multi_low.log; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
83 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
84 location /file_dup { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
85 error_log %%TESTDIR%%/e_multi.log; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
86 error_log %%TESTDIR%%/e_multi.log; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
87 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
88 location /file_high { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
89 error_log %%TESTDIR%%/e_multi_high.log emerg; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
90 error_log %%TESTDIR%%/e_multi_high.log; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
91 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
92 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
93 location /stderr_low { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
94 error_log stderr warn; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
95 error_log stderr; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
96 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
97 location /stderr_dup { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
98 error_log stderr; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
99 error_log stderr; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
100 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
101 location /stderr_high { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
102 error_log stderr emerg; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
103 error_log stderr; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
104 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
105 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
106 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
107 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
108 EOF |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
109 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
110 open OLDERR, ">&", \*STDERR; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
111 open STDERR, '>', $t->testdir() . '/stderr' or die "Can't reopen STDERR: $!"; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
112 open my $stderr, '<', $t->testdir() . '/stderr' |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
113 or die "Can't open stderr file: $!"; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
114 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
115 $t->run(); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
116 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
117 open STDERR, ">&", \*OLDERR; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
118 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
119 ############################################################################### |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
120 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
121 # charge limit_req |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
122 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
123 http_get('/'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
124 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
125 SKIP: { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
126 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
127 skip "no --with-debug", 3 unless $t->has_module('--with-debug'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
128 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
129 http_get('/debug'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
130 isnt(lines($t, 'e_debug_debug.log', '[debug]'), 0, 'file debug debug'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
131 is(lines($t, 'e_debug_info.log', '[debug]'), 0, 'file debug info'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
132 isnt(lines($t, 'stderr', '[debug]'), 0, 'stderr debug'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
133 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
134 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
135 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
136 http_get('/info'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
137 is(lines($t, 'e_info_debug.log', '[info]'), 1, 'file info debug'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
138 is(lines($t, 'e_info_info.log', '[info]'), 1, 'file info info'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
139 is(lines($t, 'e_info_notice.log', '[info]'), 0, 'file info notice'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
140 is(lines($t, 'stderr', '[info]'), 1, 'stderr info'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
141 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
142 http_get('/notice'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
143 is(lines($t, 'e_notice_info.log', '[notice]'), 1, 'file notice info'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
144 is(lines($t, 'e_notice_notice.log', '[notice]'), 1, 'file notice notice'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
145 is(lines($t, 'e_notice_warn.log', '[notice]'), 0, 'file notice warn'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
146 is(lines($t, 'stderr', '[notice]'), 1, 'stderr notice'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
147 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
148 http_get('/warn'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
149 is(lines($t, 'e_warn_notice.log', '[warn]'), 1, 'file warn notice'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
150 is(lines($t, 'e_warn_warn.log', '[warn]'), 1, 'file warn warn'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
151 is(lines($t, 'e_warn_error.log', '[warn]'), 0, 'file warn error'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
152 is(lines($t, 'stderr', '[warn]'), 1, 'stderr warn'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
153 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
154 http_get('/error'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
155 is(lines($t, 'e_error_warn.log', '[error]'), 1, 'file error warn'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
156 is(lines($t, 'e_error_error.log', '[error]'), 1, 'file error error'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
157 is(lines($t, 'e_error_alert.log', '[error]'), 0, 'file error alert'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
158 is(lines($t, 'stderr', '[error]'), 1, 'stderr error'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
159 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
160 # count log messages emitted with various error_log levels |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
161 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
162 http_get('/file_low'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
163 is(lines($t, 'e_multi_low.log', '[error]'), 2, 'file low'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
164 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
165 http_get('/file_dup'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
166 is(lines($t, 'e_multi.log', '[error]'), 2, 'file dup'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
167 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
168 http_get('/file_high'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
169 is(lines($t, 'e_multi_high.log', '[error]'), 1, 'file high'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
170 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
171 http_get('/stderr_low'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
172 is(lines($t, 'stderr', '[error]'), 2, 'stderr low'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
173 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
174 http_get('/stderr_dup'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
175 is(lines($t, 'stderr', '[error]'), 2, 'stderr dup'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
176 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
177 http_get('/stderr_high'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
178 is(lines($t, 'stderr', '[error]'), 1, 'stderr high'); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
179 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
180 ############################################################################### |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
181 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
182 sub lines { |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
183 my ($t, $file, $pattern) = @_; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
184 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
185 if ($file eq 'stderr') { |
1897
38f1fd9ca3e6
Tests: unbreak reading new stderr data after eof.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
186 my $value = map { $_ =~ /\Q$pattern\E/ } (<$stderr>); |
38f1fd9ca3e6
Tests: unbreak reading new stderr data after eof.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
187 $stderr->clearerr(); |
38f1fd9ca3e6
Tests: unbreak reading new stderr data after eof.
Sergey Kandaurov <pluknet@nginx.com>
parents:
974
diff
changeset
|
188 return $value; |
300
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
189 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
190 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
191 my $path = $t->testdir() . '/' . $file; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
192 open my $fh, '<', $path or return "$!"; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
193 my $value = map { $_ =~ /\Q$pattern\E/ } (<$fh>); |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
194 close $fh; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
195 return $value; |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
196 } |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
197 |
d753dfcaa419
Tests: added tests for error_log.
Sergey Kandaurov <pluknet@nginx.com>
parents:
diff
changeset
|
198 ############################################################################### |