Merge branch 'test_memory_limit' into 'master'

Add test to check Lua memory limit

See merge request OpenMW/openmw!4298
pull/3236/head
psi29a 5 months ago
commit 35f60cef62

@ -218,6 +218,18 @@ testing.registerLocalTest('findNearestNavMeshPosition',
'Navigation mesh position ' .. testing.formatActualExpected(result, expected))
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 {
engineHandlers = {
onFrame = testing.updateLocal,

@ -206,6 +206,19 @@ local function testUTF8Strings()
testing.expectEqual(utf8.offset(utf8str, 9), 11)
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()
player:teleport('', util.vector3(4096, 4096, 867.237), util.transform.identity)
coroutine.yield()
@ -260,6 +273,11 @@ tests = {
{'utf8Chars', testUTF8Chars},
{'utf8Strings', testUTF8Strings},
{'mwscript', testMWScript},
{'testMemoryLimit', testMemoryLimit},
{'playerMemoryLimit', function()
initPlayer()
testing.runLocalTest(player, 'playerMemoryLimit')
end}
}
return {

@ -64,6 +64,8 @@ def runTest(name):
"framerate limit = 60\n"
"[Game]\n"
"smooth animation transitions = true\n"
"[Lua]\n"
f"memory limit = {1024 * 1024 * 128}\n"
)
stdout_lines = list()
exit_ok = True

Loading…
Cancel
Save