The same as `test` but `async`.
(&self, test_func: impl AsyncFn() -> Result<()>)
| 319 | |
| 320 | /// The same as `test` but `async`. |
| 321 | pub async fn test_async(&self, test_func: impl AsyncFn() -> Result<()>) -> Result<()> { |
| 322 | let total_allocs = Self::count_allocations(&test_func).await?; |
| 323 | |
| 324 | let start = time::Instant::now(); |
| 325 | |
| 326 | for i in 0..total_allocs { |
| 327 | if self.max_iters.is_some_and(|n| i >= n) |
| 328 | || self.max_duration.is_some_and(|d| start.elapsed() >= d) |
| 329 | { |
| 330 | break; |
| 331 | } |
| 332 | |
| 333 | log::trace!("=== Injecting OOM after {i} allocations ==="); |
| 334 | self.run_one_oom_injection(&test_func, i).await?; |
| 335 | } |
| 336 | |
| 337 | Ok(()) |
| 338 | } |
| 339 | |
| 340 | /// Similar to `test` but instead of exhaustively injecting OOMs on every |
| 341 | /// allocation, randomly chooses which allocation to OOM each iteration. |
no test coverage detected