diff options
| author | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-03-01 13:54:29 -0300 |
|---|---|---|
| committer | Roberto Ierusalimschy <roberto@inf.puc-rio.br> | 2021-03-01 13:54:29 -0300 |
| commit | 5276973224066e591b0f1a79c3b091d395848ac4 (patch) | |
| tree | e72f167dca7796b4014b1833cb1e9eaed58a623e /testes/cstack.lua | |
| parent | f9d857a81b87b695c1e3b34f1e7fe55884d1288f (diff) | |
| download | lua-github-5276973224066e591b0f1a79c3b091d395848ac4.tar.gz | |
New test module 'tracegc'
New module easies the inclusion of GC tracing in individual test files.
Diffstat (limited to 'testes/cstack.lua')
| -rw-r--r-- | testes/cstack.lua | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/testes/cstack.lua b/testes/cstack.lua index 7bd55063..213d15d4 100644 --- a/testes/cstack.lua +++ b/testes/cstack.lua @@ -2,6 +2,8 @@ -- See Copyright Notice in file all.lua +local tracegc = require"tracegc" + print"testing stack overflow detection" -- Segmentation faults in these tests probably result from a C-stack @@ -21,7 +23,9 @@ do print("testing stack overflow in message handling") count = count + 1 return 1 + loop(x, y, z) end + tracegc.stop() -- __gc should not be called with a full stack local res, msg = xpcall(loop, loop) + tracegc.start() assert(msg == "error in error handling") print("final count: ", count) end @@ -135,18 +139,18 @@ if T then local topB, sizeB -- top and size Before overflow local topA, sizeA -- top and size After overflow topB, sizeB = T.stacklevel() - collectgarbage("stop") -- __gc should not be called with a full stack + tracegc.stop() -- __gc should not be called with a full stack xpcall(f, err) - collectgarbage("restart") + tracegc.start() topA, sizeA = T.stacklevel() -- sizes should be comparable assert(topA == topB and sizeA < sizeB * 2) print(string.format("maximum stack size: %d", stack1)) LIM = N -- will stop recursion at maximum level N = 0 -- to count again - collectgarbage("stop") -- __gc should not be called with a full stack + tracegc.stop() -- __gc should not be called with a full stack f() - collectgarbage("restart") + tracegc.start() print"+" end |
