zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit ad9df43e4926247cff20a9d9851fffb2a99c8a30 (tree)
parent f448b518f874929dd219ed957c314889d5dbf0cf
Author: Noam Preil <noam@pixelhero.dev>
Date:   Fri, 21 Aug 2020 18:24:00 -0400

Tests: limit SPU-II cycle count

Diffstat:
Msrc-self-hosted/test.zig | 15+++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/src-self-hosted/test.zig b/src-self-hosted/test.zig @@ -645,14 +645,17 @@ pub const TestContext = struct { exec_node.activate(); defer exec_node.end(); - // TODO: loop detection? Solve the halting problem? fork() and limit by wall clock? - // Limit by emulated cycles? + var blocks: u16 = 1000; + const block_size = 1000; while (!interpreter.undefined0) { const pre_ip = interpreter.ip; - try interpreter.ExecuteBlock(1); - if (pre_ip == interpreter.ip) { - std.debug.print("Infinite loop detected in SPU II test!\n", .{}); - std.process.exit(1); + if (blocks > 0) { + blocks -= 1; + try interpreter.ExecuteBlock(block_size); + if (pre_ip == interpreter.ip) { + std.debug.print("Infinite loop detected in SPU II test!\n", .{}); + std.process.exit(1); + } } } }