Skip to content

Commit d90d076

Browse files
committed
tests/lapi: add debug tests
1 parent 0508724 commit d90d076

File tree

3 files changed

+87
-0
lines changed

3 files changed

+87
-0
lines changed

tests/lapi/debug_getinfo_test.lua

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--[[
2+
SPDX-License-Identifier: ISC
3+
Copyright (c) 2023-2025, Sergey Bronnikov.
4+
5+
Parameter 'what' of 'debug.getinfo' cannot start with '>',
6+
https://www.lua.org/bugs.html#5.4.2-2
7+
8+
Access to debug information in line hook of stripped function,
9+
https://github.com/lua/lua/commit/ae5b5ba529753c7a653901ffc29b5ea24c3fdf3a
10+
11+
Return hook may not see correct values for active local variables when function returns,
12+
https://www.lua.org/bugs.html#5.3.0-4
13+
14+
Synopsis: debug.getinfo([thread,] function [, what])
15+
]]
16+
17+
local luzer = require("luzer")
18+
19+
local function debug_hook()
20+
-- TODO: getinfo
21+
end
22+
23+
local function TestOneInput(buf)
24+
debug.sethook(debug_hook, "crl")
25+
assert(loadstring(buf))()
26+
debug.sethook(debug_hook)
27+
end
28+
29+
local args = {
30+
artifact_prefix = "debug_getinfo_",
31+
}
32+
luzer.Fuzz(TestOneInput, nil, args)

tests/lapi/debug_getlocal_test.lua

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
--[[
2+
SPDX-License-Identifier: ISC
3+
Copyright (c) 2023-2025, Sergey Bronnikov.
4+
5+
Negation overflow in getlocal/setlocal,
6+
https://github.com/lua/lua/commit/a585eae6e7ada1ca9271607a4f48dfb17868ab7b
7+
8+
debug.getlocal on a coroutine suspended in a hook can crash the interpreter,
9+
https://www.lua.org/bugs.html#5.3.0-2
10+
11+
Synopsis: debug.getlocal([thread,] level, local)
12+
]]
13+
14+
local luzer = require("luzer")
15+
16+
local function debug_hook()
17+
-- TODO: getlocal
18+
end
19+
20+
local function TestOneInput(buf)
21+
debug.sethook(debug_hook, "crl")
22+
assert(loadstring(buf))()
23+
debug.sethook(debug_hook)
24+
end
25+
26+
local args = {
27+
artifact_prefix = "debug_getlocal_",
28+
}
29+
luzer.Fuzz(TestOneInput, nil, args)

tests/lapi/debug_getupvalue_test.lua

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
--[[
2+
SPDX-License-Identifier: ISC
3+
Copyright (c) 2023-2025, Sergey Bronnikov.
4+
5+
lua_getupvalue and lua_setupvalue do not check for index too small,
6+
https://www.lua.org/bugs.html#5.0.2-2
7+
8+
Synopsis: debug.getupvalue (f, up)
9+
]]
10+
11+
local luzer = require("luzer")
12+
13+
local function debug_hook()
14+
-- TODO: getupvalue
15+
end
16+
17+
local function TestOneInput(buf)
18+
debug.sethook(debug_hook, "crl")
19+
assert(loadstring(buf))()
20+
debug.sethook(debug_hook)
21+
end
22+
23+
local args = {
24+
artifact_prefix = "debug_getupvalue_",
25+
}
26+
luzer.Fuzz(TestOneInput, nil, args)

0 commit comments

Comments
 (0)