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

Method fuzz_async

crates/fuzzing/src/oom.rs:350–371  ·  view source on GitHub ↗

The same as `fuzz` but `async`.

(&self, test_func: impl AsyncFn() -> Result<()>)

Source from the content-addressed store, hash-verified

348
349 /// The same as `fuzz` but `async`.
350 pub async fn fuzz_async(&self, test_func: impl AsyncFn() -> Result<()>) -> Result<()> {
351 let max_iters = match self.max_iters {
352 Some(n) => n,
353 None => bail!("OomTest::fuzz requires max_iters to be set"),
354 };
355
356 let total_allocs = Self::count_allocations(&test_func).await?;
357
358 if total_allocs == 0 {
359 return Ok(());
360 }
361
362 let mut rng = SmallRng::seed_from_u64(self.seed);
363
364 for _ in 0..max_iters {
365 let i = rng.random_range(0..total_allocs);
366 log::trace!("=== Injecting OOM after {i} allocations (fuzz) ===");
367 self.run_one_oom_injection(&test_func, i).await?;
368 }
369
370 Ok(())
371 }
372
373 /// Run the test function once, injecting OOM on the `i`th allocation, and
374 /// check that the result correctly reflects whether an OOM was hit.

Callers 2

fuzzMethod · 0.80
test_fuzz_asyncFunction · 0.80

Calls 2

OkFunction · 0.85
run_one_oom_injectionMethod · 0.80

Tested by 1

test_fuzz_asyncFunction · 0.64