()
| 698 | #[tokio::test] |
| 699 | #[cfg_attr(miri, ignore)] |
| 700 | async fn hostcall_trap_events() -> wasmtime::Result<()> { |
| 701 | let _ = env_logger::try_init(); |
| 702 | |
| 703 | let (module, mut store) = get_module_and_store( |
| 704 | |config| { |
| 705 | config.wasm_exceptions(true); |
| 706 | }, |
| 707 | r#" |
| 708 | (module |
| 709 | (func (export "main") (result i32) |
| 710 | i32.const 0 |
| 711 | i32.const 0 |
| 712 | i32.div_u |
| 713 | drop |
| 714 | i32.const 42)) |
| 715 | "#, |
| 716 | )?; |
| 717 | |
| 718 | debug_event_checker!( |
| 719 | D, store, |
| 720 | { 0 ; |
| 721 | wasmtime::DebugEvent::Trap(wasmtime_environ::Trap::IntegerDivisionByZero) => { |
| 722 | let frame = store.debug_exit_frames().next().unwrap(); |
| 723 | let (_func, pc) = frame.wasm_function_index_and_pc(&mut store).unwrap().unwrap(); |
| 724 | assert_eq!(pc.raw(), 0x26); |
| 725 | } |
| 726 | } |
| 727 | ); |
| 728 | |
| 729 | let (handler, counter) = D::new_and_counter(); |
| 730 | store.set_debug_handler(handler); |
| 731 | |
| 732 | let instance = Instance::new_async(&mut store, &module, &[]).await?; |
| 733 | let func = instance.get_func(&mut store, "main").unwrap(); |
| 734 | let mut results = [Val::I32(0)]; |
| 735 | let result = func.call_async(&mut store, &[], &mut results).await; |
| 736 | assert!(result.is_err()); // Uncaught trap. |
| 737 | assert_eq!(counter.load(Ordering::Relaxed), 1); |
| 738 | |
| 739 | Ok(()) |
| 740 | } |
| 741 | |
| 742 | #[tokio::test] |
| 743 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected