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

Function test_coverage_sanitize

src/execution/sanitize.rs:383–423  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

381
382 #[test]
383 fn test_coverage_sanitize() -> Result<()> {
384 crate::config::Config::init_test("cJSON");
385 let deopt = Deopt::new("cJSON".to_string())?;
386 let executor = Executor::new(&deopt)?;
387
388 // this should pass the sanitization.
389 let cov_succ_program_path: std::path::PathBuf = [
390 crate::Deopt::get_crate_dir()?,
391 "testsuites",
392 "sanitize",
393 "cjson_cov_succ.cc",
394 ]
395 .iter()
396 .collect();
397 let work_path = deopt.get_work_seed_by_id(99999)?;
398 std::fs::copy(cov_succ_program_path, &work_path)?;
399 let has_err = executor.check_program_is_correct(&work_path)?;
400 //println!("{has_err:#?}");
401 assert!(has_err.is_none());
402
403 // this should be sanitized by coverage.
404 let cov_fail_program_path: std::path::PathBuf = [
405 crate::Deopt::get_crate_dir()?,
406 "testsuites",
407 "sanitize",
408 "cjson_cov_fail.cc",
409 ]
410 .iter()
411 .collect();
412 let work_path = deopt.get_work_seed_by_id(888888)?;
413 std::fs::copy(cov_fail_program_path, &work_path)?;
414 let has_err = executor.check_program_is_correct(&work_path)?;
415 assert!(has_err.is_some());
416 if let Some(err) = has_err {
417 match err {
418 ProgramError::Coverage(_) => return Ok(()),
419 _ => panic!("Should not fail on other sanitization"),
420 }
421 }
422 Ok(())
423 }
424
425 #[test]
426 fn test_sanitization_for_a_program() -> Result<()> {

Callers

nothing calls this directly

Calls 2

get_work_seed_by_idMethod · 0.80

Tested by

no test coverage detected