| ... | @@ -645,14 +645,17 @@ pub const TestContext = struct { | ... | @@ -645,14 +645,17 @@ pub const TestContext = struct { |
| 645 | exec_node.activate(); | 645 | exec_node.activate(); |
| 646 | defer exec_node.end(); | 646 | defer exec_node.end(); |
| 647 | | 647 | |
| 648 | // TODO: loop detection? Solve the halting problem? fork() and limit by wall clock? | 648 | var blocks: u16 = 1000; |
| 649 | // Limit by emulated cycles? | 649 | const block_size = 1000; |
| 650 | while (!interpreter.undefined0) { | 650 | while (!interpreter.undefined0) { |
| 651 | const pre_ip = interpreter.ip; | 651 | const pre_ip = interpreter.ip; |
| 652 | try interpreter.ExecuteBlock(1); | 652 | if (blocks > 0) { |
| 653 | if (pre_ip == interpreter.ip) { | 653 | blocks -= 1; |
| 654 | std.debug.print("Infinite loop detected in SPU II test!\n", .{}); | 654 | try interpreter.ExecuteBlock(block_size); |
| 655 | std.process.exit(1); | 655 | if (pre_ip == interpreter.ip) { |
| | 656 | std.debug.print("Infinite loop detected in SPU II test!\n", .{}); |
| | 657 | std.process.exit(1); |
| | 658 | } |
| 656 | } | 659 | } |
| 657 | } | 660 | } |
| 658 | } | 661 | } |