MCPcopy Create free account
hub / github.com/bytecodealliance/wasmtime / present_after_module_drop

Function present_after_module_drop

tests/all/traps.rs:600–620  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

598
599#[test]
600fn present_after_module_drop() -> Result<()> {
601 let mut store = Store::<()>::default();
602 let module = Module::new(store.engine(), r#"(func (export "foo") unreachable)"#)?;
603 let instance = Instance::new(&mut store, &module, &[])?;
604 let func = instance.get_typed_func::<(), ()>(&mut store, "foo")?;
605
606 println!("asserting before we drop modules");
607 assert_trap(func.call(&mut store, ()).unwrap_err());
608 drop((instance, module));
609
610 println!("asserting after drop");
611 assert_trap(func.call(&mut store, ()).unwrap_err());
612 return Ok(());
613
614 fn assert_trap(t: Error) {
615 println!("{t:?}");
616 let trace = t.downcast_ref::<WasmBacktrace>().unwrap().frames();
617 assert_eq!(trace.len(), 1);
618 assert_eq!(trace[0].func_index(), 0);
619 }
620}
621
622fn assert_trap_code(wat: &str, code: wasmtime::Trap) {
623 let mut store = Store::<()>::default();

Callers

nothing calls this directly

Calls 6

assert_trapFunction · 0.85
OkFunction · 0.85
newFunction · 0.50
dropFunction · 0.50
engineMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected