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

Function trap_display_multi_module

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

Source from the content-addressed store, hash-verified

325
326#[test]
327fn trap_display_multi_module() -> Result<()> {
328 let mut store = Store::<()>::default();
329 let wat = r#"
330 (module $a
331 (func $die unreachable)
332 (func call $die)
333 (func $foo call 1)
334 (func (export "bar") call $foo)
335 )
336 "#;
337
338 let module = Module::new(store.engine(), wat)?;
339 let instance = Instance::new(&mut store, &module, &[])?;
340 let bar = instance.get_export(&mut store, "bar").unwrap();
341
342 let wat = r#"
343 (module $b
344 (import "" "" (func $bar))
345 (func $middle call $bar)
346 (func (export "bar2") call $middle)
347 )
348 "#;
349 let module = Module::new(store.engine(), wat)?;
350 let instance = Instance::new(&mut store, &module, &[bar])?;
351 let bar2 = instance.get_typed_func::<(), ()>(&mut store, "bar2")?;
352
353 let e = bar2.call(&mut store, ()).unwrap_err();
354 e.assert_contains(
355 "\
356error while executing at wasm backtrace:
357 0: 0x23 - a!die
358 1: 0x27 - a!<wasm function 1>
359 2: 0x2c - a!foo
360 3: 0x31 - a!<wasm function 3>
361 4: 0x29 - b!middle
362 5: 0x2e - b!<wasm function 2>",
363 );
364 e.assert_contains("wasm trap: wasm `unreachable` instruction executed");
365 Ok(())
366}
367
368#[test]
369fn trap_start_function_import() -> Result<()> {

Callers

nothing calls this directly

Calls 7

OkFunction · 0.85
assert_containsMethod · 0.80
newFunction · 0.50
engineMethod · 0.45
unwrapMethod · 0.45
get_exportMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected