()
| 1057 | #[test] |
| 1058 | #[cfg(feature = "component-model")] |
| 1059 | fn 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")] |
nothing calls this directly
no test coverage detected