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

Function pulley_provenance_test_async_components

tests/all/pulley.rs:419–488  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

417#[tokio::test]
418#[cfg_attr(miri, ignore)]
419async fn pulley_provenance_test_async_components() -> Result<()> {
420 let config = provenance_test_config();
421 let engine = Engine::new(&config)?;
422 let component = if cfg!(miri) {
423 unsafe {
424 Component::deserialize_file(
425 &engine,
426 "./tests/all/pulley_provenance_test_async_component.cwasm",
427 )?
428 }
429 } else {
430 Component::from_file(
431 &engine,
432 "./tests/all/pulley_provenance_test_async_component.wat",
433 )?
434 };
435 {
436 let mut store = Store::new(&engine, ());
437 let mut linker = component::Linker::new(&engine);
438 linker
439 .root()
440 .func_wrap_concurrent("return-slowly", |_, ()| {
441 Box::pin(async {
442 for _ in 0..5 {
443 tokio::task::yield_now().await;
444 }
445 Ok(())
446 })
447 })?;
448
449 let instance = linker.instantiate_async(&mut store, &component).await?;
450
451 let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackless")?;
452 store
453 .run_concurrent(async move |accessor| {
454 wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?)
455 })
456 .await??;
457
458 let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackful")?;
459 store
460 .run_concurrent(async move |accessor| {
461 wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?)
462 })
463 .await??;
464
465 let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackless-stackless")?;
466 store
467 .run_concurrent(async move |accessor| {
468 wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?)
469 })
470 .await??;
471
472 let run = instance.get_typed_func::<(), ()>(&mut store, "run-stackful-stackful")?;
473 store
474 .run_concurrent(async move |accessor| {
475 wasmtime::error::Ok(run.call_concurrent(accessor, ()).await?)
476 })

Callers

nothing calls this directly

Calls 9

provenance_test_configFunction · 0.85
yield_nowFunction · 0.85
OkFunction · 0.85
run_concurrentMethod · 0.80
call_concurrentMethod · 0.80
newFunction · 0.50
func_wrap_concurrentMethod · 0.45
rootMethod · 0.45
instantiate_asyncMethod · 0.45

Tested by

no test coverage detected