~spuul/nginx/trunk

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/t/047-match-jit.t

  • Committer: Package Import Robot
  • Author(s): Colin Watson
  • Date: 2014-02-15 03:05:42 UTC
  • mfrom: (4.3.10 sid)
  • Revision ID: package-import@ubuntu.com-20140215030542-71ubtowl24vf7nfn
Tags: 1.4.5-1ubuntu1
* Resynchronise with Debian (LP: #1280511).  Remaining changes:
  - debian/patches/ubuntu-branding.patch:
    + Add Ubuntu branding to server_tokens.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
# vim:set ft= ts=4 sw=4 et fdm=marker:
2
2
use lib 'lib';
3
 
use Test::Nginx::Socket;
 
3
use Test::Nginx::Socket::Lua;
4
4
 
5
5
#worker_connections(1014);
6
6
#master_on();
75
75
    GET /re
76
76
--- response_body
77
77
1234
78
 
--- error_log
79
 
pcre JIT compiling result: 1
 
78
 
 
79
--- grep_error_log eval
 
80
qr/pcre JIT compiling result: \d+/
 
81
 
 
82
--- grep_error_log_out eval
 
83
["pcre JIT compiling result: 1\n", ""]
80
84
 
81
85
 
82
86
 
96
100
    GET /re
97
101
--- response_body
98
102
not matched!
99
 
--- error_log
100
 
pcre JIT compiling result: 1
 
103
 
 
104
--- grep_error_log eval
 
105
qr/pcre JIT compiling result: \d+/
 
106
 
 
107
--- grep_error_log_out eval
 
108
["pcre JIT compiling result: 1\n", ""]
101
109
 
102
110
 
103
111
 
122
130
--- request
123
131
    GET /re
124
132
--- response_body
125
 
error: failed to compile regex "(abc": pcre_compile() failed: missing ) in "(abc"
 
133
error: pcre_compile() failed: missing ) in "(abc"
126
134
--- no_error_log
127
135
[error]
128
136
 
 
137
 
 
138
 
 
139
=== TEST 6: just hit match limit
 
140
--- http_config
 
141
    lua_regex_match_limit 2940;
 
142
--- config
 
143
    location /re {
 
144
        content_by_lua_file html/a.lua;
 
145
    }
 
146
 
 
147
--- user_files
 
148
>>> a.lua
 
149
local re = [==[(?i:([\s'\"`´’‘\(\)]*)?([\d\w]+)([\s'\"`´’‘\(\)]*)?(?:=|<=>|r?like|sounds\s+like|regexp)([\s'\"`´’‘\(\)]*)?\2|([\s'\"`´’‘\(\)]*)?([\d\w]+)([\s'\"`´’‘\(\)]*)?(?:!=|<=|>=|<>|<|>|\^|is\s+not|not\s+like|not\s+regexp)([\s'\"`´’‘\(\)]*)?(?!\6)([\d\w]+))]==]
 
150
 
 
151
s = string.rep([[ABCDEFG]], 21)
 
152
 
 
153
local start = ngx.now()
 
154
 
 
155
local res, err = ngx.re.match(s, re, "jo")
 
156
 
 
157
--[[
 
158
ngx.update_time()
 
159
local elapsed = ngx.now() - start
 
160
ngx.say(elapsed, " sec elapsed.")
 
161
]]
 
162
 
 
163
if not res then
 
164
    if err then
 
165
        ngx.say("error: ", err)
 
166
        return
 
167
    end
 
168
    ngx.say("failed to match")
 
169
    return
 
170
end
 
171
 
 
172
--- request
 
173
    GET /re
 
174
--- response_body
 
175
error: pcre_exec() failed: -8
 
176
 
 
177
 
 
178
 
 
179
=== TEST 7: just not hit match limit
 
180
--- http_config
 
181
    lua_regex_match_limit 2950;
 
182
--- config
 
183
    location /re {
 
184
        content_by_lua_file html/a.lua;
 
185
    }
 
186
 
 
187
--- user_files
 
188
>>> a.lua
 
189
local re = [==[(?i:([\s'\"`´’‘\(\)]*)?([\d\w]+)([\s'\"`´’‘\(\)]*)?(?:=|<=>|r?like|sounds\s+like|regexp)([\s'\"`´’‘\(\)]*)?\2|([\s'\"`´’‘\(\)]*)?([\d\w]+)([\s'\"`´’‘\(\)]*)?(?:!=|<=|>=|<>|<|>|\^|is\s+not|not\s+like|not\s+regexp)([\s'\"`´’‘\(\)]*)?(?!\6)([\d\w]+))]==]
 
190
 
 
191
s = string.rep([[ABCDEFG]], 21)
 
192
 
 
193
local start = ngx.now()
 
194
 
 
195
local res, err = ngx.re.match(s, re, "jo")
 
196
 
 
197
--[[
 
198
ngx.update_time()
 
199
local elapsed = ngx.now() - start
 
200
ngx.say(elapsed, " sec elapsed.")
 
201
]]
 
202
 
 
203
if not res then
 
204
    if err then
 
205
        ngx.say("error: ", err)
 
206
        return
 
207
    end
 
208
    ngx.say("failed to match")
 
209
    return
 
210
end
 
211
 
 
212
--- request
 
213
    GET /re
 
214
--- response_body
 
215
failed to match
 
216