Skip to content

Commit 68ca9d5

Browse files
committed
added tests to excercise a bug in table.new() on i386 in LuaJIT v2.1 that has just been fixed.
1 parent 502c7ec commit 68ca9d5

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

t/world.t

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# vim:set ft= ts=4 sw=4 et:
2+
3+
use Test::Nginx::Socket::Lua;
4+
use Cwd qw(cwd);
5+
6+
repeat_each(2);
7+
8+
plan tests => repeat_each() * (3 * blocks());
9+
10+
my $pwd = cwd();
11+
12+
our $HttpConfig = qq{
13+
resolver \$TEST_NGINX_RESOLVER;
14+
lua_package_path "$pwd/lib/?.lua;$pwd/t/lib/?.lua;;";
15+
lua_package_cpath "/usr/local/openresty-debug/lualib/?.so;/usr/local/openresty/lualib/?.so;;";
16+
};
17+
18+
$ENV{TEST_NGINX_RESOLVER} = '8.8.8.8';
19+
$ENV{TEST_NGINX_MYSQL_PORT} ||= 3306;
20+
$ENV{TEST_NGINX_MYSQL_HOST} ||= '127.0.0.1';
21+
$ENV{TEST_NGINX_MYSQL_PATH} ||= '/var/run/mysql/mysql.sock';
22+
23+
#log_level 'warn';
24+
25+
no_long_string();
26+
no_shuffle();
27+
check_accum_error_log();
28+
29+
run_tests();
30+
31+
__DATA__
32+
33+
=== TEST 1: test an old bug in table.new() on i386 in luajit v2.1
34+
--- http_config eval: $::HttpConfig
35+
--- config
36+
location /t {
37+
access_log off;
38+
content_by_lua '
39+
-- jit.off()
40+
local mysql = require "resty.mysql"
41+
local db = mysql:new()
42+
43+
local ok, err, errno, sqlstate = db:connect({
44+
host = "$TEST_NGINX_MYSQL_HOST",
45+
port = $TEST_NGINX_MYSQL_PORT,
46+
database = "world",
47+
user = "ngx_test",
48+
password = "ngx_test"})
49+
50+
local res, err, errno, sqlstate
51+
for j = 1, 10 do
52+
res, err, errno, sqlstate = db:query("select * from City order by ID limit 50", 50)
53+
if not res then
54+
ngx.log(ngx.ERR, "bad result #1: ", err, ": ", errno, ": ", sqlstate, ".")
55+
return ngx.exit(500)
56+
end
57+
end
58+
59+
for _, row in ipairs(res) do
60+
local ncols = 0
61+
for k, v in pairs(row) do
62+
ncols = ncols + 1
63+
end
64+
ngx.say("ncols: ", ncols)
65+
end
66+
67+
local ok, err = db:set_keepalive(10000, 50)
68+
if not ok then
69+
ngx.log(ngx.ERR, "failed to set keepalive: ", err)
70+
ngx.exit(500)
71+
end
72+
';
73+
}
74+
--- request
75+
GET /t
76+
--- response_body eval
77+
"ncols: 5\n" x 50
78+
--- no_error_log
79+
[error]
80+

0 commit comments

Comments
 (0)