1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#[cfg(feature = "afl")]
pub use afl::fuzz as afl_fuzz;
#[cfg(feature = "honggfuzz")]
pub use honggfuzz::fuzz as honggfuzz_fuzz;
#[cfg(feature = "libfuzzer-sys")]
pub use libfuzzer_sys::fuzz_target as libfuzzer_fuzz;
#[macro_export]
#[cfg(feature = "afl")]
macro_rules! fuzz {
(|$buf:ident: &[u8]| $body:block) => {
#[no_mangle]
fn main() {
$crate::afl_fuzz!(|$buf| $body);
}
};
}
#[macro_export]
#[cfg(feature = "libfuzzer-sys")]
macro_rules! fuzz {
(|$buf:ident: &[u8]| $body:block) => {
$crate::libfuzzer_fuzz!(|$buf| $body);
};
}
#[macro_export]
#[cfg(feature = "honggfuzz")]
macro_rules! fuzz {
(|$buf:ident: &[u8]| $body:block) => {
#[no_mangle]
fn main() {
loop {
$crate::honggfuzz_fuzz!(|$buf| $body);
}
}
};
}