xref: /wasmtime-44.0.1/crates/fuzzing/src/lib.rs (revision 2cd52b76)
1 //! Fuzzing infrastructure for Wasmtime.
2 
3 #![deny(missing_docs)]
4 
5 pub use wasm_mutate;
6 pub use wasm_smith;
7 pub mod generators;
8 pub mod mutators;
9 pub mod oracles;
10 pub mod single_module_fuzzer;
11 
12 /// One time start up initialization for fuzzing:
13 ///
14 /// * Enables `env_logger`.
15 ///
16 /// * Restricts `rayon` to a single thread in its thread pool, for more
17 ///   deterministic executions.
18 ///
19 /// If a fuzz target is taking raw input bytes from the fuzzer, it is fine to
20 /// call this function in the fuzz target's oracle or in the fuzz target
21 /// itself. However, if the fuzz target takes an `Arbitrary` type, and the
22 /// `Arbitrary` implementation is not derived and does interesting things, then
23 /// the `Arbitrary` implementation should call this function, since it runs
24 /// before the fuzz target itself.
25 pub fn init_fuzzing() {
26     static INIT: std::sync::Once = std::sync::Once::new();
27 
28     INIT.call_once(|| {
29         let _ = env_logger::try_init();
30     });
31 }
32