Skip to content

Commit

Permalink
Fix thread status bug
Browse files Browse the repository at this point in the history
  • Loading branch information
louismerlin committed Oct 31, 2024
1 parent 798eab5 commit 4656610
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions src/bin/cargo-ziggy/fuzz.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,14 @@ impl Fuzz {
(true, false, wait) if wait < self.coverage_interval => {
format!("waiting {} minutes", self.coverage_interval - wait)
}
(true, _, _) => String::from("running"),
(true, false, _) => String::from("starting"),
(true, true, _) => String::from("running"),
(false, _, _) => String::from("disabled"),
};

self.print_stats(&coverage_status);

if coverage_status.as_str() == "running" {
if coverage_status.as_str() == "starting" {
*coverage_now_running.lock().unwrap() = true;

let main_corpus = main_corpus.clone();
Expand All @@ -206,7 +207,7 @@ impl Fuzz {
let output_target = output_target.clone();
let cov_start_time = Arc::clone(&cov_start_time);
let cov_end_time = Arc::clone(&cov_end_time);
let coverage_now_running_thread = Arc::clone(&coverage_now_running);
let coverage_now_running = Arc::clone(&coverage_now_running);

thread::spawn(move || {
let mut seen_new_entry = false;
Expand All @@ -225,20 +226,19 @@ impl Fuzz {
.unwrap()
.elapsed()
.unwrap_or_default();
// TODO Handle corpus entries that were created during the last run.
if prev_start_time
.map(|s| s.elapsed())
.unwrap_or(Duration::MAX)
>= created
{
process::Command::new(format!("./target/coverage/debug/{}", &target))
.arg(format!("{}", entry.display()))
.stdout(Stdio::null())
.stderr(Stdio::null())
.spawn()
.unwrap()
.wait()
.unwrap();
let _ = process::Command::new(format!(
"./target/coverage/debug/{}",
&target
))
.arg(format!("{}", entry.display()))
.stdout(Stdio::null())
.stderr(Stdio::null())
.status();
seen_new_entry = true;
}
}
Expand All @@ -250,7 +250,7 @@ impl Fuzz {
}

*cov_end_time.lock().unwrap() = Instant::now();
*coverage_now_running_thread.lock().unwrap() = false;
*coverage_now_running.lock().unwrap() = false;
});
}

Expand Down

0 comments on commit 4656610

Please sign in to comment.