MCPcopy Create free account
hub / github.com/FuzzAnything/PromptFuzz / execute_cov_fuzzer_pool

Method execute_cov_fuzzer_pool

src/execution/mod.rs:435–485  ·  view source on GitHub ↗
(
        &self,
        fuzzer_binary: &Path,
        corpus_dirs: Vec<&Path>,
        profdata: &Path,
    )

Source from the content-addressed store, hash-verified

433 }
434
435 pub fn execute_cov_fuzzer_pool(
436 &self,
437 fuzzer_binary: &Path,
438 corpus_dirs: Vec<&Path>,
439 profdata: &Path,
440 ) -> Result<()> {
441 let fuzzer_dir = get_file_dirname(fuzzer_binary);
442 let profraw_dir: PathBuf = [fuzzer_dir.clone(), "profraw".into()].iter().collect();
443 if profraw_dir.exists() {
444 std::fs::remove_dir_all(&profraw_dir)?;
445 }
446 crate::deopt::utils::create_dir_if_nonexist(&profraw_dir)?;
447 let corpus_files: Vec<Vec<PathBuf>> = corpus_dirs
448 .iter()
449 .map(|dir| crate::deopt::utils::read_sort_dir(dir).expect("read dir should not fial"))
450 .collect();
451 let corpus_files: Vec<PathBuf> = corpus_files.concat();
452 let cpu_count = max_cpu_count();
453 let pool = ThreadPool::new(cpu_count);
454
455 for (id, corpus_file) in corpus_files.iter().enumerate() {
456 let binary = fuzzer_binary.to_path_buf();
457 let corpus_file = corpus_file.to_path_buf();
458 let corpus_name = corpus_file
459 .file_name()
460 .expect("file name of corpus file should not be empty")
461 .to_string_lossy()
462 .to_string();
463 let profraw_file: PathBuf = [
464 PathBuf::from(&profraw_dir),
465 format!("{corpus_name}.profraw").into(),
466 ]
467 .iter()
468 .collect();
469 let len = corpus_files.len();
470 let executor = self.clone();
471
472 pool.execute(move || {
473 executor
474 .execute_cov_fuzzer(&binary, &corpus_file, &profraw_file)
475 .unwrap();
476 log::trace!("execute fuzz_cov on corpus finished {id}/{}", len);
477 });
478 }
479 pool.join();
480
481 let profraws = crate::deopt::utils::read_all_files_in_dir(&profraw_dir)?;
482 Self::merge_profdata(&profraws, profdata)?;
483 std::fs::remove_dir_all(profraw_dir)?;
484 Ok(())
485 }
486
487 pub fn collect_code_coverage(
488 &self,

Callers 3

collect_code_coverageMethod · 0.80
eval_seed_coverageMethod · 0.80

Calls 7

get_file_dirnameFunction · 0.85
create_dir_if_nonexistFunction · 0.85
read_sort_dirFunction · 0.85
max_cpu_countFunction · 0.85
read_all_files_in_dirFunction · 0.85
execute_cov_fuzzerMethod · 0.80
executeMethod · 0.45

Tested by

no test coverage detected