fuzz test are used to test the robustness of the code.
To run the fuzz tests, please copy the .env.example, which is at project root, to .env and change the values on need.
Take fs for example, we need to change to enable fuzz test on fs on /tmp.
OPENDAL_TEST=fs OPENDAL_FS_ROOT=/path/to/dir/
into
OPENDAL_TEST=fs OPENDAL_FS_ROOT=/tmp/
List all fuzz targets.
cargo +nightly fuzz list
Build fuzz targets.
cargo +nightly fuzz build
Run a fuzz target(such as reader).
cargo +nightly fuzz run fuzz_reader
If you want to reproduce a crash, you first need to obtain the Base64 encoded code, which usually appears at the end of a crash report, and store it in a file.
Alternatively, if you already have the crash file, you can skip this step.
echo "Base64" > .crash
Print the std::fmt::Debug output for an input.
cargo +nightly fuzz fmt fuzz_target .crash
Rerun the fuzz test with the input.
cargo +nightly fuzz run fuzz_target .crash
For more details, please visit cargo fuzz or run the command cargo fuzz --help.