Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions src/bin/cargo-ziggy/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,9 @@ impl Build {
);
eprintln!(" {} honggfuzz", style("Building").red().bold());

let mut hfuzz_args = vec!["hfuzz"];
if self.release {
hfuzz_args.push("build");
} else {
hfuzz_args.push("build-debug");
}

// Second fuzzer we build: Honggfuzz
let run = process::Command::new(&cargo)
.args(hfuzz_args)
.args(["hfuzz", "build"])
.env("CARGO_TARGET_DIR", super::target_dir().join("honggfuzz"))
.env("HFUZZ_BUILD_ARGS", "--features=ziggy/honggfuzz")
.env("RUSTFLAGS", env::var("RUSTFLAGS").unwrap_or_default())
Expand Down
19 changes: 12 additions & 7 deletions src/bin/cargo-ziggy/clean.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,18 @@ impl Clean {
pub fn clean(&self) -> Result<(), Error> {
let cargo = env::var("CARGO").unwrap_or_else(|_| String::from("cargo"));

let clean = |sub_target: &str, target_triple: Option<&str>| -> Result<(), Error> {
let clean = |target, target_triple: Option<&str>, try_release| -> Result<(), Error> {
let already_profile = self
.args
.iter()
.any(|arg| arg.as_encoded_bytes().starts_with(b"--profile") || arg == "--release");
let status = Command::new(&cargo)
.arg("clean")
.arg("-q")
.args(&self.args)
.args(target_triple.map(|triple| format!("--target={triple}")))
.env("CARGO_TARGET_DIR", super::target_dir().join(sub_target))
.args((!already_profile && try_release).then_some("--release"))
.env("CARGO_TARGET_DIR", super::target_dir().join(target))
.status()
.expect("Error running cargo clean command");
if !status.success() {
Expand All @@ -21,15 +26,15 @@ impl Clean {
Ok(())
};

clean("afl", None)?;
clean("afl", None, false)?;
// ASan uses --target=host
clean("afl", Some(target_triple::TARGET))?;
clean("afl", Some(target_triple::TARGET), false)?;
// honggfuzz uses --target=host
clean("honggfuzz", Some(target_triple::TARGET))?;
clean("honggfuzz", Some(target_triple::TARGET), true)?;
// coverage (from ziggy cover)
clean("coverage", None)?;
clean("coverage", None, false)?;
// runner (from ziggy run)
clean("runner", None)?;
clean("runner", None, false)?;
Ok(())
}
}
2 changes: 1 addition & 1 deletion src/bin/cargo-ziggy/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -566,7 +566,7 @@ impl Fuzz {
super::target_dir()
.join("honggfuzz")
.join(target_triple::TARGET)
.join(if self.release { "release" } else { "debug" })
.join("release")
.join(&self.target)
.as_std_path(),
)?;
Expand Down
4 changes: 2 additions & 2 deletions tests/url_fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ fn clean() {
{
let afl_build_path = target_directory.join("afl/debug/url-fuzz");
let hfuzz_build_path = target_directory.join(format!(
"honggfuzz/{}/debug/url-fuzz",
"honggfuzz/{}/release/url-fuzz",
target_triple::TARGET
));

Expand Down Expand Up @@ -364,7 +364,7 @@ fn clean() {
// use temp_dir_path as target-dir
let afl_build_path = temp_dir_path.join("afl/debug/url-fuzz");
let hfuzz_build_path = temp_dir_path.join(format!(
"honggfuzz/{}/debug/url-fuzz",
"honggfuzz/{}/release/url-fuzz",
target_triple::TARGET
));

Expand Down