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

Function component_core_instances_limit

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

Source from the content-addressed store, hash-verified

1015#[test]
1016#[cfg(feature = "component-model")]
1017fn component_core_instances_limit() -> Result<()> {
1018 let mut pool = crate::small_pool_config();
1019 pool.max_core_instances_per_component(1);
1020 let mut config = Config::new();
1021 config.wasm_component_model(true);
1022 config.allocation_strategy(pool);
1023 let engine = Engine::new(&config)?;
1024
1025 // One core instance works.
1026 wasmtime::component::Component::new(
1027 &engine,
1028 r#"
1029 (component
1030 (core module $m)
1031 (core instance $a (instantiate $m))
1032 )
1033 "#,
1034 )?;
1035
1036 // Two core instances doesn't.
1037 match wasmtime::component::Component::new(
1038 &engine,
1039 r#"
1040 (component
1041 (core module $m)
1042 (core instance $a (instantiate $m))
1043 (core instance $b (instantiate $m))
1044 )
1045 "#,
1046 ) {
1047 Ok(_) => panic!("should have hit limit"),
1048 Err(e) => e.assert_contains(
1049 "The component transitively contains 2 core module instances, which exceeds the \
1050 configured maximum of 1",
1051 ),
1052 }
1053
1054 Ok(())
1055}
1056
1057#[test]
1058#[cfg(feature = "component-model")]

Callers

nothing calls this directly

Calls 7

OkFunction · 0.85
allocation_strategyMethod · 0.80
assert_containsMethod · 0.80
small_pool_configFunction · 0.70
newFunction · 0.50
wasm_component_modelMethod · 0.45

Tested by

no test coverage detected