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

Function trap_with_native_to_wasm_stack_args

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

Source from the content-addressed store, hash-verified

1437
1438#[test]
1439fn trap_with_native_to_wasm_stack_args() -> Result<()> {
1440 let engine = Engine::default();
1441 let mut store = Store::new(&engine, ());
1442 let module = Module::new(
1443 &engine,
1444 r#"
1445 (module
1446 (func $trap
1447 unreachable)
1448 (func $run (param i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64 i64)
1449 call $trap)
1450 (export "run" (func $run))
1451 )
1452 "#,
1453 )?;
1454
1455 let instance = Instance::new(&mut store, &module, &[])?;
1456 let run = instance.get_func(&mut store, "run").unwrap();
1457
1458 let err = run
1459 .typed::<(
1460 i64,
1461 i64,
1462 i64,
1463 i64,
1464 i64,
1465 i64,
1466 i64,
1467 i64,
1468 i64,
1469 i64,
1470 i64,
1471 i64,
1472 i64,
1473 i64,
1474 i64,
1475 ), ()>(&mut store)?
1476 .call(&mut store, (0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0))
1477 .unwrap_err();
1478 assert!(err.is::<Trap>());
1479
1480 let trace = err.downcast_ref::<WasmBacktrace>().unwrap();
1481 assert_eq!(trace.frames().len(), 2);
1482 assert_eq!(trace.frames()[0].func_name(), Some("trap"));
1483 assert_eq!(trace.frames()[1].func_name(), Some("run"));
1484
1485 Ok(())
1486}
1487
1488#[test]
1489fn dont_see_stale_stack_walking_registers() -> Result<()> {

Callers

nothing calls this directly

Calls 5

OkFunction · 0.85
newFunction · 0.50
unwrapMethod · 0.45
get_funcMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected