mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-31 16:36:41 +00: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))
|
||||
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…
Reference in a new issue