Skip to content

Commit

Permalink
Fix clippy warning
Browse files Browse the repository at this point in the history
  • Loading branch information
louismerlin committed Jan 9, 2024
1 parent f5183d9 commit 5387ef9
Showing 1 changed file with 39 additions and 39 deletions.
78 changes: 39 additions & 39 deletions src/bin/cargo-ziggy/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,45 +919,6 @@ impl Fuzz {
}
}

#[cfg(test)]
mod tests {
use std::{path::PathBuf, time::Instant};
#[test]
fn job_repartition_works() {
let mut fuzz = crate::Fuzz {
target: String::new(),
corpus: PathBuf::new(),
initial_corpus: None,
ziggy_output: PathBuf::new(),
jobs: 0,
timeout: None,
minimize: false,
dictionary: None,
max_length: 0,
min_length: 0,
no_afl: false,
no_libafl: false,
no_honggfuzz: false,
start_time: Instant::now(),
};
for i in 0..1024 {
fuzz.jobs = i;
fuzz.no_afl = i % 7 == 0;
fuzz.no_libafl = i % 11 == 0;
fuzz.no_honggfuzz = i % 5 == 0;
if i % 385 == 0 {
continue;
}
let (afl_jobs, libafl_jobs, honggfuzz_jobs) = fuzz.compute_job_repartition();
assert_eq!(
afl_jobs + libafl_jobs + honggfuzz_jobs,
fuzz.jobs,
"Jobs total mismatch"
);
}
}
}

pub fn kill_subprocesses_recursively(pid: &str) -> Result<(), anyhow::Error> {
let subprocesses = process::Command::new("pgrep")
.arg(&format!("-P{pid}"))
Expand Down Expand Up @@ -1001,3 +962,42 @@ pub fn extract_file_id(file: &Path) -> Option<(u32, String)> {
let file_id = str_id.parse::<u32>().ok()?;
Some((file_id, String::from(file_name)))
}

#[cfg(test)]
mod tests {
use std::{path::PathBuf, time::Instant};
#[test]
fn job_repartition_works() {
let mut fuzz = crate::Fuzz {
target: String::new(),
corpus: PathBuf::new(),
initial_corpus: None,
ziggy_output: PathBuf::new(),
jobs: 0,
timeout: None,
minimize: false,
dictionary: None,
max_length: 0,
min_length: 0,
no_afl: false,
no_libafl: false,
no_honggfuzz: false,
start_time: Instant::now(),
};
for i in 0..1024 {
fuzz.jobs = i;
fuzz.no_afl = i % 7 == 0;
fuzz.no_libafl = i % 11 == 0;
fuzz.no_honggfuzz = i % 5 == 0;
if i % 385 == 0 {
continue;
}
let (afl_jobs, libafl_jobs, honggfuzz_jobs) = fuzz.compute_job_repartition();
assert_eq!(
afl_jobs + libafl_jobs + honggfuzz_jobs,
fuzz.jobs,
"Jobs total mismatch"
);
}
}
}

0 comments on commit 5387ef9

Please sign in to comment.