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

Method compute_recursive_func_coverage

src/feedback/branches.rs:278–303  ·  view source on GitHub ↗

compute the recursive code coverage inside a function

(
        &self,
        func: &str,
        cov_cache: &HashMap<String, (u32, u32)>,
    )

Source from the content-addressed store, hash-verified

276
277 /// compute the recursive code coverage inside a function
278 pub fn compute_recursive_func_coverage(
279 &self,
280 func: &str,
281 cov_cache: &HashMap<String, (u32, u32)>,
282 ) -> eyre::Result<f32> {
283 if let Some((covered, total)) = cov_cache.get(func) {
284 if covered == &0 && total != &0 {
285 return Ok(0_f32);
286 }
287 }
288 let mut visited = HashSet::new();
289 let (covered_branches, total_branches) =
290 self.get_func_branch_coverage(func, cov_cache, &mut visited)?;
291 if total_branches == 0 {
292 if let Some(exec_count) = get_exec_counter_value(func) {
293 if exec_count == 0 {
294 return Ok(0_f32);
295 } else {
296 return Ok(1_f32);
297 }
298 }
299 return Ok(0_f32);
300 }
301 let func_coverage = covered_branches as f32 / total_branches as f32;
302 Ok(func_coverage)
303 }
304
305 fn get_func_branch_coverage(
306 &self,

Callers 1

Calls 2

get_exec_counter_valueFunction · 0.85

Tested by

no test coverage detected