Skip to content

Commit

Permalink
AFL_NO_CFG_FUZZING test added
Browse files Browse the repository at this point in the history
  • Loading branch information
HN026 committed Nov 18, 2023
1 parent 8925666 commit 6fd2a78
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions cargo-afl/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,4 @@ tempfile = "3.8"
[features]
default = []
plugins = []
fuzzing = []
6 changes: 6 additions & 0 deletions cargo-afl/src/fuzz.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
fn main() {
if !cfg!(fuzzing) {
panic!("Crash because fuzzing is not set. ");
}
println!("Running Normally");
}
12 changes: 12 additions & 0 deletions cargo-afl/tests/fuzz_test.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#[cfg(test)]
mod tests {
use assert_cmd::Command;

#[test]
fn test_fuzz(){
let mut cmd = Command::cargo_bin("fuzz").unwrap();
cmd.env("RUSTFLAGS", "-C passes=sancov -Zsanitizer=address");
let output = cmd.unwrap();
assert!(output.status.success());
}
}

0 comments on commit 6fd2a78

Please sign in to comment.