Name Description Size
component
component.rs Generation of Wasm [components](https://github.com/WebAssembly/component-model). 74289
config.rs Configuring the shape of generated Wasm modules. 29672
core
core.rs Generating arbitary core Wasm modules. 105419
lib.rs A WebAssembly test case generator. ## Usage First, use [`cargo fuzz`](https://github.com/rust-fuzz/cargo-fuzz) to define a new fuzz target: ```shell $ cargo fuzz add my_wasm_smith_fuzz_target ``` Next, add `wasm-smith` to your dependencies: ```shell $ cargo add wasm-smith ``` Then, define your fuzz target so that it takes arbitrary `wasm_smith::Module`s as an argument, convert the module into serialized Wasm bytes via the `to_bytes` method, and then feed it into your system: ```no_run // fuzz/fuzz_targets/my_wasm_smith_fuzz_target.rs #![no_main] use libfuzzer_sys::fuzz_target; use wasm_smith::Module; fuzz_target!(|module: Module| { let wasm_bytes = module.to_bytes(); // Your code here... }); ``` Finally, start fuzzing: ```shell $ cargo fuzz run my_wasm_smith_fuzz_target ``` > **Note:** For a real world example, also check out [the `validate` fuzz > target](https://github.com/fitzgen/wasm-smith/blob/main/fuzz/fuzz_targets/validate.rs) > defined in this repository. Using the `wasmparser` crate, it checks that > every module generated by `wasm-smith` validates successfully. ## Design The design and implementation strategy of wasm-smith is outlined in [this article](https://fitzgeraldnick.com/2020/08/24/writing-a-test-case-generator.html). 5371