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

Function total_component_instances_limit

tests/all/pooling_allocator.rs:833–863  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

831#[test]
832#[cfg(feature = "component-model")]
833fn total_component_instances_limit() -> Result<()> {
834 const TOTAL_COMPONENT_INSTANCES: u32 = 5;
835
836 let mut pool = crate::small_pool_config();
837 pool.total_component_instances(TOTAL_COMPONENT_INSTANCES);
838 let mut config = Config::new();
839 config.wasm_component_model(true);
840 config.allocation_strategy(pool);
841
842 let engine = Engine::new(&config)?;
843 let linker = wasmtime::component::Linker::new(&engine);
844 let component = wasmtime::component::Component::new(&engine, "(component)")?;
845
846 let mut store = Store::new(&engine, ());
847 for _ in 0..TOTAL_COMPONENT_INSTANCES {
848 linker.instantiate(&mut store, &component)?;
849 }
850
851 match linker.instantiate(&mut store, &component) {
852 Ok(_) => panic!("should have hit component instance limit"),
853 Err(e) => assert!(e.is::<PoolConcurrencyLimitError>()),
854 }
855
856 drop(store);
857 let mut store = Store::new(&engine, ());
858 for _ in 0..TOTAL_COMPONENT_INSTANCES {
859 linker.instantiate(&mut store, &component)?;
860 }
861
862 Ok(())
863}
864
865#[test]
866#[cfg(feature = "component-model")]

Callers

nothing calls this directly

Calls 8

OkFunction · 0.85
allocation_strategyMethod · 0.80
small_pool_configFunction · 0.70
newFunction · 0.50
dropFunction · 0.50
wasm_component_modelMethod · 0.45
instantiateMethod · 0.45

Tested by

no test coverage detected