()
| 405 | |
| 406 | #[test] |
| 407 | fn total_core_instances_limit() -> Result<()> { |
| 408 | const INSTANCE_LIMIT: u32 = 10; |
| 409 | let mut pool = crate::small_pool_config(); |
| 410 | pool.total_core_instances(INSTANCE_LIMIT); |
| 411 | let mut config = Config::new(); |
| 412 | config.allocation_strategy(pool); |
| 413 | config.memory_guard_size(0); |
| 414 | config.memory_reservation(1 << 16); |
| 415 | |
| 416 | let engine = Engine::new(&config)?; |
| 417 | let module = Module::new(&engine, r#"(module)"#)?; |
| 418 | |
| 419 | // Instantiate to the limit |
| 420 | { |
| 421 | let mut store = Store::new(&engine, ()); |
| 422 | |
| 423 | for _ in 0..INSTANCE_LIMIT { |
| 424 | Instance::new(&mut store, &module, &[])?; |
| 425 | } |
| 426 | |
| 427 | match Instance::new(&mut store, &module, &[]) { |
| 428 | Ok(_) => panic!("instantiation should fail"), |
| 429 | Err(e) => assert!(e.is::<PoolConcurrencyLimitError>()), |
| 430 | } |
| 431 | } |
| 432 | |
| 433 | // With the above store dropped, ensure instantiations can be made |
| 434 | |
| 435 | let mut store = Store::new(&engine, ()); |
| 436 | |
| 437 | for _ in 0..INSTANCE_LIMIT { |
| 438 | Instance::new(&mut store, &module, &[])?; |
| 439 | } |
| 440 | |
| 441 | Ok(()) |
| 442 | } |
| 443 | |
| 444 | #[test] |
| 445 | #[cfg_attr(miri, ignore)] |
nothing calls this directly
no test coverage detected