mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 21:07:59 +03:00
Add test to check Lua memory limit
This commit is contained in:
parent
07c89c4f84
commit
0c0d544e38
3 changed files with 32 additions and 0 deletions
|
@ -218,6 +218,18 @@ testing.registerLocalTest('findNearestNavMeshPosition',
|
||||||
'Navigation mesh position ' .. testing.formatActualExpected(result, expected))
|
'Navigation mesh position ' .. testing.formatActualExpected(result, expected))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
testing.registerLocalTest('playerMemoryLimit',
|
||||||
|
function()
|
||||||
|
local ok, err = pcall(function()
|
||||||
|
local str = 'a'
|
||||||
|
while true do
|
||||||
|
str = str .. str
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
testing.expectEqual(ok, false, 'Script reaching memory limit should fail')
|
||||||
|
testing.expectEqual(err, 'not enough memory')
|
||||||
|
end)
|
||||||
|
|
||||||
return {
|
return {
|
||||||
engineHandlers = {
|
engineHandlers = {
|
||||||
onFrame = testing.updateLocal,
|
onFrame = testing.updateLocal,
|
||||||
|
|
|
@ -206,6 +206,19 @@ local function testUTF8Strings()
|
||||||
testing.expectEqual(utf8.offset(utf8str, 9), 11)
|
testing.expectEqual(utf8.offset(utf8str, 9), 11)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local function testMemoryLimit()
|
||||||
|
local ok, err = pcall(function()
|
||||||
|
local t = {}
|
||||||
|
local n = 1
|
||||||
|
while true do
|
||||||
|
t[n] = n
|
||||||
|
n = n + 1
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
testing.expectEqual(ok, false, 'Script reaching memory limit should fail')
|
||||||
|
testing.expectEqual(err, 'not enough memory')
|
||||||
|
end
|
||||||
|
|
||||||
local function initPlayer()
|
local function initPlayer()
|
||||||
player:teleport('', util.vector3(4096, 4096, 867.237), util.transform.identity)
|
player:teleport('', util.vector3(4096, 4096, 867.237), util.transform.identity)
|
||||||
coroutine.yield()
|
coroutine.yield()
|
||||||
|
@ -260,6 +273,11 @@ tests = {
|
||||||
{'utf8Chars', testUTF8Chars},
|
{'utf8Chars', testUTF8Chars},
|
||||||
{'utf8Strings', testUTF8Strings},
|
{'utf8Strings', testUTF8Strings},
|
||||||
{'mwscript', testMWScript},
|
{'mwscript', testMWScript},
|
||||||
|
{'testMemoryLimit', testMemoryLimit},
|
||||||
|
{'playerMemoryLimit', function()
|
||||||
|
initPlayer()
|
||||||
|
testing.runLocalTest(player, 'playerMemoryLimit')
|
||||||
|
end}
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|
|
@ -64,6 +64,8 @@ def runTest(name):
|
||||||
"framerate limit = 60\n"
|
"framerate limit = 60\n"
|
||||||
"[Game]\n"
|
"[Game]\n"
|
||||||
"smooth animation transitions = true\n"
|
"smooth animation transitions = true\n"
|
||||||
|
"[Lua]\n"
|
||||||
|
f"memory limit = {1024 * 1024 * 128}\n"
|
||||||
)
|
)
|
||||||
stdout_lines = list()
|
stdout_lines = list()
|
||||||
exit_ok = True
|
exit_ok = True
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue