~spuul/nginx/trunk

« back to all changes in this revision

Viewing changes to debian/modules/nginx-lua/t/081-bytecode.t

  • Committer: Package Import Robot
  • Author(s): Christos Trochalakis, Christos Trochalakis
  • Date: 2014-02-13 11:41:49 UTC
  • mfrom: (1.3.32)
  • mto: This revision was merged to the branch mainline in revision 72.
  • Revision ID: package-import@ubuntu.com-20140213114149-tkp78c45rzu3wr6y
Tags: 1.4.5-1
[ Christos Trochalakis ]
* New upstream release.
* debian/modules/nginx-lua:
  + Update nginx-lua to v0.9.4
* debian/nginx-naxsi-ui.preinst:
  + Fix exit status issue (Closes: #735152)
* debian/control:
  + Fix arch:all to arch:any dependencies
  + Make nginx depend on specific flavor version
* debian/nginx-*.postinst:
  + Make nginx start by default (Closes: #735551)
* debian/nginx-*.prerm:
  + No need to check for invoke-rc.d,
    correctly set the exit code on error
* debian/nginx-common.nginx.init:
  + Rewrite some parts of the initscript
  + Introduce rotate command
  + Introduce upgrade command

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();
10
10
repeat_each(2);
11
11
#repeat_each(1);
12
12
 
13
 
plan tests => repeat_each() * (blocks() * 2 + 2);
 
13
plan tests => repeat_each() * (blocks() * 3);
14
14
 
15
15
#no_diff();
16
16
#no_long_string();
27
27
            local b = ngx.req.get_body_data();
28
28
            f = io.open(ngx.var.realpath_root.."/test.lua", "w");
29
29
            -- luajit bytecode: sub(149,-1), lua bytecode: sub(1,147)
30
 
            if package.loaded["jit"] then
 
30
            if jit then
 
31
                if not string.find(jit.version, "LuaJIT 2.0") then
 
32
                    ngx.say("test skipped")
 
33
                    return
 
34
                end
31
35
                f:write(string.sub(b, 149));
32
36
            else
33
37
                f:write(string.sub(b, 1, 147));
43
47
"POST /save_call
44
48
\x1b\x4c\x75\x61\x51\x00\x01\x04\x08\x04\x08\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x40\x74\x65\x73\x74\x2e\x6c\x75\x61\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x05\x00\x00\x00\x05\x00\x00\x00\x06\x40\x40\x00\x41\x80\x00\x00\x1c\x40\x00\x01\x1e\x00\x80\x00\x03\x00\x00\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x6e\x67\x78\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x73\x61\x79\x00\x04\x06\x00\x00\x00\x00\x00\x00\x00\x68\x65\x6c\x6c\x6f\x00\x00\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
45
49
\x1b\x4c\x4a\x01\x02\x29\x02\x00\x02\x00\x03\x00\x05\x34\x00\x00\x00\x37\x00\x01\x00\x25\x01\x02\x00\x3e\x00\x02\x01\x47\x00\x01\x00\x0a\x68\x65\x6c\x6c\x6f\x08\x73\x61\x79\x08\x6e\x67\x78\x00"
46
 
--- response_body
47
 
hello
 
50
--- response_body_like chop
 
51
^(?:hello|test skipped)$
 
52
--- no_error_log
 
53
[error]
48
54
 
49
55
 
50
56
 
80
86
--- response_body
81
87
error
82
88
--- error_log
83
 
failed to load Lua inlined code: bad byte-code header in
 
89
failed to load external Lua file: bad byte-code header in
84
90
 
85
91
 
86
92
 
112
118
--- request eval
113
119
"POST /save_call
114
120
\x1b\x4c\x75\x61\x52\x00\x01\x04\x08\x04\x08\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x40\x74\x65\x73\x74\x2e\x6c\x75\x61\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x05\x00\x00\x00\x05\x00\x00\x00\x06\x40\x40\x00\x41\x80\x00\x00\x1c\x40\x00\x01\x1e\x00\x80\x00\x03\x00\x00\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x6e\x67\x78\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x73\x61\x79\x00\x04\x06\x00\x00\x00\x00\x00\x00\x00\x68\x65\x6c\x6c\x6f\x00\x00\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
115
 
\x1b\x4c\x4a\x02\x02\x29\x02\x00\x02\x00\x03\x00\x05\x34\x00\x00\x00\x37\x00\x01\x00\x25\x01\x02\x00\x3e\x00\x02\x01\x47\x00\x01\x00\x0a\x68\x65\x6c\x6c\x6f\x08\x73\x61\x79\x08\x6e\x67\x78\x00"
 
121
\x1b\x4c\x4a\x80\x02\x29\x02\x00\x02\x00\x03\x00\x05\x34\x00\x00\x00\x37\x00\x01\x00\x25\x01\x02\x00\x3e\x00\x02\x01\x47\x00\x01\x00\x0a\x68\x65\x6c\x6c\x6f\x08\x73\x61\x79\x08\x6e\x67\x78\x00"
116
122
--- response_body
117
123
error
118
124
--- error_log
119
 
bad byte-code header in
 
125
bytecode format version unsupported
120
126
 
121
127
 
122
128
 
129
135
            local b = ngx.req.get_body_data();
130
136
            f = io.open(ngx.var.realpath_root.."/test.lua", "w");
131
137
            -- luajit bytecode: sub(149,-1), lua bytecode: sub(1,147)
132
 
            local jit
133
 
            if package.loaded["jit"] then
134
 
                jit = true; f:write(string.sub(b, 149));
 
138
            local do_jit
 
139
            if jit then
 
140
                if not string.find(jit.version, "LuaJIT 2.0") then
 
141
                    ngx.say("test skipped")
 
142
                    return
 
143
                end
 
144
 
 
145
                do_jit = true; f:write(string.sub(b, 149));
135
146
            else
136
147
                f:write(string.sub(b, 1, 147));
137
148
            end
138
149
            f:close(); res = ngx.location.capture("/call");
139
 
            if jit and res.status == 200 then
 
150
            if do_jit and res.status == 200 then
140
151
                ngx.say("ok")
141
 
            elseif not jit and res.status == 500 then
 
152
            elseif not do_jit and res.status == 500 then
142
153
                ngx.say("ok")
143
154
            else
144
155
                ngx.say("error")
152
163
"POST /save_call
153
164
\x1b\x4c\x75\x61\x51\x00\x00\x04\x08\x04\x08\x00\x0a\x00\x00\x00\x00\x00\x00\x00\x40\x74\x65\x73\x74\x2e\x6c\x75\x61\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x05\x00\x00\x00\x05\x00\x00\x00\x06\x40\x40\x00\x41\x80\x00\x00\x1c\x40\x00\x01\x1e\x00\x80\x00\x03\x00\x00\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x6e\x67\x78\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x73\x61\x79\x00\x04\x06\x00\x00\x00\x00\x00\x00\x00\x68\x65\x6c\x6c\x6f\x00\x00\x00\x00\x00\x05\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
154
165
\x1b\x4c\x4a\x01\x03\x29\x02\x00\x02\x00\x03\x00\x05\x00\x00\x00\x34\x00\x01\x00\x37\x00\x02\x01\x25\x01\x02\x00\x3e\x00\x01\x00\x47\x0a\x68\x65\x6c\x6c\x6f\x08\x73\x61\x79\x08\x6e\x67\x78\x00"
155
 
--- response_body
156
 
ok
 
166
--- response_body_like chop
 
167
^(?:ok|test skipped)$
 
168
--- no_error_log
 
169
[error]
157
170
 
158
171
 
159
172
 
196
209
\x1b\x4c\x4a\x01\x02\x29\x02\x00\x02\x00\x03\x00\x05\xff\xff\xff\xff\x37\x00\x01\x00\x25\x01\x02\x00\x3e\x00\x02\x01\x47\x00\x01\x00\x0a\x68\x65\x6c\x6c\x6f\x08\x73\x61\x79\x08\x6e\x67\x78\x00"
197
210
--- response_body
198
211
error
 
212
--- no_error_log
 
213
[error]
199
214
 
200
215
 
201
216
 
208
223
            local b = ngx.req.get_body_data();
209
224
            f = io.open(ngx.var.realpath_root.."/test.lua", "w");
210
225
            -- luajit bytecode: sub(149,-1), lua bytecode: sub(1,147)
211
 
            if package.loaded["jit"] then
 
226
            if jit then
 
227
                if not string.find(jit.version, "LuaJIT 2.0") then
 
228
                    ngx.say("test skipped")
 
229
                    return
 
230
                end
 
231
 
212
232
                f:write(string.sub(b, 119));
213
233
            else
214
234
                f:write(string.sub(b, 1, 117));
224
244
"POST /save_call
225
245
\x1b\x4c\x75\x61\x51\x00\x01\x04\x08\x04\x08\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x02\x05\x00\x00\x00\x05\x00\x00\x00\x06\x40\x40\x00\x41\x80\x00\x00\x1c\x40\x00\x01\x1e\x00\x80\x00\x03\x00\x00\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x6e\x67\x78\x00\x04\x04\x00\x00\x00\x00\x00\x00\x00\x73\x61\x79\x00\x04\x06\x00\x00\x00\x00\x00\x00\x00\x68\x65\x6c\x6c\x6f\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00
226
246
\x1b\x4c\x4a\x01\x00\x09\x40\x74\x65\x73\x74\x2e\x6c\x75\x61\x32\x02\x00\x02\x00\x03\x00\x05\x06\x00\x02\x34\x00\x00\x00\x37\x00\x01\x00\x25\x01\x02\x00\x3e\x00\x02\x01\x47\x00\x01\x00\x0a\x68\x65\x6c\x6c\x6f\x08\x73\x61\x79\x08\x6e\x67\x78\x01\x01\x01\x01\x01\x00\x00"
227
 
--- response_body
228
 
hello
 
247
--- response_body_like chop
 
248
^(?:hello|test skipped)$
 
249
--- no_error_log
 
250
[error]
 
251
 
 
252
 
 
253
 
 
254
=== TEST 7: generate & load bytecode for LuaJIT (stripped)
 
255
--- config
 
256
    location = /t {
 
257
        content_by_lua '
 
258
            local bcsave = require "jit.bcsave"
 
259
            if jit then
 
260
                local prefix = ngx.config.prefix()
 
261
                local infile = prefix .. "html/a.lua"
 
262
                local outfile = prefix .. "html/a.luac"
 
263
                bcsave.start("-s", infile, outfile)
 
264
                return ngx.exec("/call")
 
265
            end
 
266
 
 
267
            ngx.say("test skipped!")
 
268
        ';
 
269
    }
 
270
    location = /call {
 
271
        content_by_lua_file html/a.luac;
 
272
    }
 
273
--- request
 
274
    GET /t
 
275
 
 
276
--- user_files
 
277
>>> a.lua
 
278
ngx.status = 201 ngx.say("hello from Lua!")
 
279
--- response_body_like chop
 
280
^(?:hello from Lua!|test skipped!)$
 
281
--- no_error_log
 
282
[error]
 
283
--- error_code: 201
 
284
 
 
285
 
 
286
 
 
287
=== TEST 8: generate & load bytecode for LuaJIT (not stripped)
 
288
--- config
 
289
    location = /t {
 
290
        content_by_lua '
 
291
            local bcsave = require "jit.bcsave"
 
292
            if jit then
 
293
                local prefix = ngx.config.prefix()
 
294
                local infile = prefix .. "html/a.lua"
 
295
                local outfile = prefix .. "html/a.luac"
 
296
                bcsave.start("-g", infile, outfile)
 
297
                return ngx.exec("/call")
 
298
            end
 
299
 
 
300
            ngx.say("test skipped!")
 
301
        ';
 
302
    }
 
303
    location = /call {
 
304
        content_by_lua_file html/a.luac;
 
305
    }
 
306
--- request
 
307
    GET /t
 
308
 
 
309
--- user_files
 
310
>>> a.lua
 
311
ngx.status = 201 ngx.say("hello from Lua!")
 
312
--- response_body_like chop
 
313
^(?:hello from Lua!|test skipped!)$
 
314
--- no_error_log
 
315
[error]
 
316
--- error_code: 201
229
317