add Lua sandbox with timer system (milestones 1-5 complete)
This commit is contained in:
20
sandbox-test/scripts/test_memory_limit.lua
Normal file
20
sandbox-test/scripts/test_memory_limit.lua
Normal file
@@ -0,0 +1,20 @@
|
||||
-- This script intentionally tries to exhaust memory
|
||||
-- When run with a 512KB limit, it should fail before completing
|
||||
|
||||
local t = {}
|
||||
local i = 0
|
||||
|
||||
while true do
|
||||
i = i + 1
|
||||
-- Each string is 100KB
|
||||
t[i] = string.rep("x", 100000)
|
||||
|
||||
-- Safety check - if we get past 100 iterations with 512KB limit,
|
||||
-- something is wrong
|
||||
if i > 100 then
|
||||
error("FAIL: Should have hit memory limit by now (allocated ~10MB)")
|
||||
end
|
||||
end
|
||||
|
||||
-- Should never reach here
|
||||
error("FAIL: Memory limit not enforced")
|
||||
Reference in New Issue
Block a user