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

Function early_epoch_yield_still_has_vmctx

tests/all/debug.rs:1392–1436  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1390#[tokio::test]
1391#[cfg_attr(miri, ignore)]
1392async fn early_epoch_yield_still_has_vmctx() -> wasmtime::Result<()> {
1393 let _ = env_logger::try_init();
1394
1395 let mut config = Config::default();
1396 config.guest_debug(true);
1397 config.epoch_interruption(true);
1398 let engine = Engine::new(&config)?;
1399 let module = Module::new(
1400 &engine,
1401 r#"
1402 (module
1403 (func (export "main") (param i32 i32) (result i32)
1404 local.get 0
1405 local.get 1
1406 i32.add))
1407 "#,
1408 )?;
1409 let mut store = Store::new(&engine, ());
1410 store.set_epoch_deadline(1);
1411 store.epoch_deadline_async_yield_and_update(1);
1412 engine.increment_epoch();
1413
1414 #[derive(Clone)]
1415 struct H;
1416 impl DebugHandler for H {
1417 type Data = ();
1418 async fn handle(&self, mut store: StoreContextMut<'_, ()>, _event: DebugEvent<'_>) {
1419 // Ensure we can access the instance (which accesses the
1420 // vmctx slot in the frame's debug info).
1421 let frame = store.debug_exit_frames().next().unwrap();
1422 let _instance = frame.instance(&mut store);
1423 }
1424 }
1425
1426 store.set_debug_handler(H);
1427
1428 let instance = Instance::new_async(&mut store, &module, &[]).await?;
1429 let func = instance.get_func(&mut store, "main").unwrap();
1430 let mut results = [Val::I32(0)];
1431 func.call_async(&mut store, &[Val::I32(1), Val::I32(2)], &mut results)
1432 .await?;
1433 assert_eq!(results[0].unwrap_i32(), 3);
1434
1435 Ok(())
1436}
1437
1438#[tokio::test]
1439#[cfg_attr(miri, ignore)]

Callers

nothing calls this directly

Calls 11

OkFunction · 0.85
guest_debugMethod · 0.80
set_debug_handlerMethod · 0.80
newFunction · 0.50
epoch_interruptionMethod · 0.45
set_epoch_deadlineMethod · 0.45
increment_epochMethod · 0.45
unwrapMethod · 0.45
get_funcMethod · 0.45
call_asyncMethod · 0.45

Tested by

no test coverage detected