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

Function component_memories_limit

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

Source from the content-addressed store, hash-verified

1057#[test]
1058#[cfg(feature = "component-model")]
1059fn component_memories_limit() -> Result<()> {
1060 let mut pool = crate::small_pool_config();
1061 pool.max_memories_per_component(1).total_memories(2);
1062 let mut config = Config::new();
1063 config.wasm_component_model(true);
1064 config.allocation_strategy(pool);
1065 let engine = Engine::new(&config)?;
1066
1067 // One memory works.
1068 wasmtime::component::Component::new(
1069 &engine,
1070 r#"
1071 (component
1072 (core module $m (memory 1 1))
1073 (core instance $a (instantiate $m))
1074 )
1075 "#,
1076 )?;
1077
1078 // Two memories doesn't.
1079 match wasmtime::component::Component::new(
1080 &engine,
1081 r#"
1082 (component
1083 (core module $m (memory 1 1))
1084 (core instance $a (instantiate $m))
1085 (core instance $b (instantiate $m))
1086 )
1087 "#,
1088 ) {
1089 Ok(_) => panic!("should have hit limit"),
1090 Err(e) => e.assert_contains(
1091 "The component transitively contains 2 Wasm linear memories, which exceeds the \
1092 configured maximum of 1",
1093 ),
1094 }
1095
1096 Ok(())
1097}
1098
1099#[test]
1100#[cfg(feature = "component-model")]

Callers

nothing calls this directly

Calls 8

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

Tested by

no test coverage detected