Interrupt test: continue an infinite-loop debuggee, interrupt it, verify the interrupt, then set the exit flag in memory and continue to completion. Tests against `debugger_debuggee_loop.wat`.
(d: &Debuggee)
| 89 | /// |
| 90 | /// Tests against `debugger_debuggee_loop.wat`. |
| 91 | fn test_loop(d: &Debuggee) { |
| 92 | // Continue execution (the debuggee should loop). |
| 93 | let r = Resumption::continue_(d); |
| 94 | |
| 95 | // Yield to the event loop and let it run for a bit. |
| 96 | std::thread::sleep(Duration::from_millis(100)); |
| 97 | |
| 98 | // Request interrupt. |
| 99 | d.interrupt(); |
| 100 | |
| 101 | // Wait for the interrupt event. |
| 102 | let event = r.result(d).unwrap(); |
| 103 | assert!( |
| 104 | matches!(event, Event::Interrupted), |
| 105 | "expected Interrupted, got {event:?}" |
| 106 | ); |
| 107 | |
| 108 | // Set the exit-flag to kill the infinite loop in the guest (the |
| 109 | // debugger environment will not otherwise end until the guest |
| 110 | // ends; we have no way of forcing an early exit yet). |
| 111 | for inst in &d.all_instances() { |
| 112 | if let Ok(mem) = inst.get_memory(d, 0) { |
| 113 | mem.set_bytes(d, 0, &[1]).unwrap(); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | // Continue; the debuggee should exit normally now. |
| 118 | let r = Resumption::continue_(d); |
| 119 | let event = r.result(d).unwrap(); |
| 120 | assert!( |
| 121 | matches!(event, Event::Complete), |
| 122 | "expected Complete, got {event:?}" |
| 123 | ); |
| 124 | |
| 125 | eprintln!("OK"); |
| 126 | } |
| 127 | |
| 128 | fn main() {} |
no test coverage detected