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