Path: blob/main/crates/fuzzing/src/generators/async_config.rs
1693 views
use arbitrary::{Arbitrary, Unstructured};1use std::time::Duration;23/// Configuration for async support within a store.4///5/// Note that the `Arbitrary` implementation for this type always returns6/// `Disabled` because this is something that is statically chosen if the fuzzer7/// has support for async.8#[derive(Clone, Debug, Eq, Hash, PartialEq)]9pub enum AsyncConfig {10/// No async support enabled.11Disabled,12/// Async support is enabled and cooperative yielding is done with fuel.13YieldWithFuel(u64),14/// Async support is enabled and cooperative yielding is done with epochs.15YieldWithEpochs {16/// Duration between epoch ticks.17dur: Duration,18/// Number of ticks between yields.19ticks: u64,20},21}2223impl AsyncConfig {24/// Applies this async configuration to the `wasmtime::Config` provided to25/// ensure it's ready to execute with the resulting modules.26pub fn configure(&self, config: &mut wasmtime::Config) {27match self {28AsyncConfig::Disabled => {}29AsyncConfig::YieldWithFuel(_) => {30config.async_support(true).consume_fuel(true);31}32AsyncConfig::YieldWithEpochs { .. } => {33config.async_support(true).epoch_interruption(true);34}35}36}37}3839impl<'a> Arbitrary<'a> for AsyncConfig {40fn arbitrary(_: &mut Unstructured<'a>) -> arbitrary::Result<AsyncConfig> {41Ok(AsyncConfig::Disabled)42}43}444546