A framework for fuzzing Rust projects using Google FuzzTest.
Clone the repository.
Build the C++ Centipede static library engine using Bazel (from the repository root):
cd /path/to/fuzztest bazel build //centipede:centipede_engine_static
Copy the libcentipede_engine_static.a library to another location:
mkdir -p $HOME/.local/lib cp /path/to/fuzztest/bazel-bin/centipede/libcentipede_engine_static.a \ $HOME/.local/lib/
Create a new Rust project:
cargo new my_fuzz_project --bin
Add fuzztest as a dependency in your Cargo.toml:
[dependencies] fuzztest = { path = "/path/to/fuzztest/rust" } googletest = "0.14.3"
In src/main.rs:
#[cfg(test)] mod tests { use fuzztest::domains::arbitrary::Arbitrary; use fuzztest::fuzztest; #[fuzztest(a = Arbitrary::<i32>::default(), b = Arbitrary::<i32>::default())] fn test_addition(a: i32, b: i32) { let _ = a.wrapping_add(b); } }
To run the fuzz tests, you must specify:
RUSTFLAGS="-L $HOME/.local/lib" cargo test __fuzztest_mod__::test_addition