Enum fuzzcheck::FuzzerBuilder [−][src]
pub enum FuzzerBuilder {}Expand description
Use this builder type to construct a fuzz test and launch it.
A fuzz-test is constructed by passing these five arguments, in order:
- the function to fuzz-test
- the mutator that produces the test cases
- the serializer to use when saving the interesting test cases to the file system
- other fuzzing arguments, which may be produced by
cargo-fuzzcheck, or specified manually - the files whose code coverage influece the fuzzer
For example, you may write:
#![feature(no_coverage)] use fuzzcheck::{FuzzerBuilder, DefaultMutator, SerdeSerializer}; fn my_function(xs: &Option<u16>) -> bool { // .. } fn fuzz_test() { FuzzerBuilder::test(my_function) .mutator(<Option<u16>>::default_mutator()) .serializer(SerdeSerializer::default()) .arguments_from_cargo_fuzzcheck() .observe_only_files_from_current_dir() .launch(); }
Each step is performed on a different type. You start with a
FuzzerBuilder, which asks for a test function. Once that test function
is given, you get a FuzzerBuilder1, which asks for a mutator.
FuzzerBuilder2 asks for a serializer. FuzzerBuilder3 asks for fuzzing
arguments. And finally, FuzzerBuilder4 has all the information needed to
launch the fuzz test.
Implementations
pub fn test<T, F, TestFunctionKind>(
test_function: F
) -> FuzzerBuilder1<T, F::NormalizedFunction> where
T: ?Sized,
F: FuzzTestFunction<T, TestFunctionKind>,
pub fn test<T, F, TestFunctionKind>(
test_function: F
) -> FuzzerBuilder1<T, F::NormalizedFunction> where
T: ?Sized,
F: FuzzTestFunction<T, TestFunctionKind>,
Specify the function to fuzz-test.
There are currently three kinds of functions that can be passed as arguments:
Fn(&T): the fuzzer will only report a failure when the given function crashesFn(&T) -> Bool: the fuzzer will report a failure when the output isfalseFn(&T) -> Result<_,_>: the fuzzer will report a failure when the output isErr(..)