[Tarantool-patches] [PATCH v2 luajit 12/30] test: adapt PUC Lua test with count hooks

Sergey Kaplun skaplun at tarantool.org
Fri Mar 26 10:42:55 MSK 2021


LuaJIT does not check hooks at traces without defined
-DLUAJIT_ENABLE_CHECKHOOK. For more information see <src/lj_record.c>
or commit 6bce6b118eeb2bb7f36157de158e5cccf0ea68e5 (Add compile-time
option LUAJIT_ENABLE_CHECKHOOK. Disabled by default.).

This patch adapts these tests for LuaJIT by disabling JIT while testing
count hooks.

Closes tarantool/tarantool#5701
Part of tarantool/tarantool#5845
Part of tarantool/tarantool#4473
---
 test/PUC-Lua-5.1-tests/db.lua | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/test/PUC-Lua-5.1-tests/db.lua b/test/PUC-Lua-5.1-tests/db.lua
index 6985c29..c1a635a 100644
--- a/test/PUC-Lua-5.1-tests/db.lua
+++ b/test/PUC-Lua-5.1-tests/db.lua
@@ -347,6 +347,18 @@ assert(debug.setupvalue(io.read, 1, 10) == nil)
 
 -- testing count hooks
 local a=0
+-- LuaJIT: LuaJIT does not check hooks at traces without defined
+-- -DLUAJIT_ENABLE_CHECKHOOK.
+-- For more information see <src/lj_record.c> or commit
+-- 6bce6b118eeb2bb7f36157de158e5cccf0ea68e5 (Add compile-time
+-- option LUAJIT_ENABLE_CHECKHOOK. Disabled by default.).
+-- See also https://github.com/tarantool/tarantool/issues/5701
+-- Test is adapted for LuaJIT by disabling JIT while
+-- testing count hooks.
+local jit_is_enabled = jit.status()
+if jit_is_enabled then
+  jit.off()
+end
 debug.sethook(function (e) a=a+1 end, "", 1)
 a=0; for i=1,1000 do end; assert(1000 < a and a < 1012)
 debug.sethook(function (e) a=a+1 end, "", 4)
@@ -359,6 +371,9 @@ debug.sethook(print, "", 2^24 - 1)   -- count upperbound
 local f,m,c = debug.gethook()
 assert(({debug.gethook()})[3] == 2^24 - 1)
 debug.sethook()
+if jit_is_enabled then
+  jit.on()
+end
 
 
 -- tests for tail calls
-- 
2.31.0



More information about the Tarantool-patches mailing list