Skip to content

Commit

Permalink
Change combined results again
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Aug 31, 2024
1 parent 5512d28 commit 0e1dcc0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion tools/kani-cov/src/coverage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ pub struct CoverageResults {

#[derive(Clone, Debug, Serialize, Deserialize)]
pub struct CombinedCoverageResults {
pub data: BTreeMap<String, Vec<CovResult>>,
pub data: BTreeMap<String, Vec<(String, Vec<CovResult>)>>,
}

// pub fn fmt_coverage_results(coverage_results: &CoverageResults) -> Result<String> {
Expand Down
13 changes: 10 additions & 3 deletions tools/kani-cov/src/merge.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ fn parse_raw_results(paths: &Vec<PathBuf>) -> Result<Vec<CoverageResults>> {
fn combine_raw_results(results: &Vec<CoverageResults>) -> CombinedCoverageResults {
let all_file_function_names = function_names_from_results(results);

let mut new_data = BTreeMap::new();
let mut new_data: BTreeMap<String, Vec<(String, Vec<CovResult>)>> = BTreeMap::new();

for (file_name, fun_name) in all_file_function_names {
let mut this_fun_checks: Vec<&CoverageCheck> = Vec::new();

Expand Down Expand Up @@ -83,8 +84,14 @@ fn combine_raw_results(results: &Vec<CoverageResults>) -> CombinedCoverageResult
new_results.push(new_result);
}

let pair_string = format!("{file_name}+{fun_name}");
new_data.insert(pair_string, new_results);
// let pair_string = format!("{file_name}+{fun_name}");
let filename_copy = file_name.clone();
if new_data.contains_key(&file_name) {
new_data.get_mut(&filename_copy).unwrap().push((fun_name, new_results));
} else {
new_data.insert(file_name.clone(), vec![(fun_name, new_results)]);
}
// new_data.insert(file_name, (fun_name, new_results));
}
CombinedCoverageResults { data: new_data }
}
Expand Down
15 changes: 15 additions & 0 deletions tools/kani-cov/src/summary.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,23 @@ pub fn summary_main(args: &SummaryArgs) -> Result<()> {
function_info.extend(new_info);
}

for info in function_info {
calculate_coverage_info(&info, &cov_results);
}

Ok(())
}

pub fn validate_summary_args(_args: &SummaryArgs) -> Result<()> {
Ok(())
}

fn calculate_coverage_info(info: &FunctionCoverageInfo, results: &CombinedCoverageResults) {
// `info` does not include file so how do we match?
// use function just for now...
let this_info_key = results.data.keys().find(|key| key.split_once('+').unwrap_or_default().1 == info.name).unwrap();
let this_info_results = results.data.get(this_info_key);
}
#[derive(Debug)]
struct FunctionCoverageInfo {
name: String,
Expand All @@ -48,6 +58,11 @@ struct FunctionCoverageInfo {
num_lines: usize,
}

// struct SummaryInfo {
// covered_functions: u32,
// total_functions: u32,
// }

fn function_info_from_file(filepath: &PathBuf) -> Vec<FunctionCoverageInfo> {
let source_code = fs::read_to_string(filepath).expect("could not read source file");
let mut parser = Parser::new();
Expand Down

0 comments on commit 0e1dcc0

Please sign in to comment.