| ... | ... | @@ -645,14 +645,17 @@ pub const TestContext = struct { |
| 645 | 645 | exec_node.activate(); |
| 646 | 646 | defer exec_node.end(); |
| 647 | 647 | |
| 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; |
| 650 | 650 | while (!interpreter.undefined0) { |
| 651 | 651 | 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 | } |
| 656 | 659 | } |
| 657 | 660 | } |
| 658 | 661 | } |