authorgravatar for noam@pixelhero.devNoam Preil <noam@pixelhero.dev> 2020-08-21 18:24:00-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2020-08-22 12:45:29-07:00
logad9df43e4926247cff20a9d9851fffb2a99c8a30
treea438c4494ef4991d6b8eb33ff8ba8755deba67fe
parentf448b518f874929dd219ed957c314889d5dbf0cf

Tests: limit SPU-II cycle count


1 files changed, 9 insertions(+), 6 deletions(-)

src-self-hosted/test.zig+9-6
......@@ -645,14 +645,17 @@ pub const TestContext = struct {
645645 exec_node.activate();
646646 defer exec_node.end();
647647
648 // TODO: loop detection? Solve the halting problem? fork() and limit by wall clock?
649 // Limit by emulated cycles?
648 var blocks: u16 = 1000;
649 const block_size = 1000;
650650 while (!interpreter.undefined0) {
651651 const pre_ip = interpreter.ip;
652 try interpreter.ExecuteBlock(1);
653 if (pre_ip == interpreter.ip) {
654 std.debug.print("Infinite loop detected in SPU II test!\n", .{});
655 std.process.exit(1);
652 if (blocks > 0) {
653 blocks -= 1;
654 try interpreter.ExecuteBlock(block_size);
655 if (pre_ip == interpreter.ip) {
656 std.debug.print("Infinite loop detected in SPU II test!\n", .{});
657 std.process.exit(1);
658 }
656659 }
657660 }
658661 }