crucible_test_context/coverage/
types.rs1use std::collections::HashSet;
4
5#[derive(Clone, Debug, Default)]
7pub struct FunctionInfo {
8 pub name: String,
9 pub entry_pc: usize,
10}
11
12#[derive(Clone, Default)]
14pub struct ReachableAnalysis {
15 pub total_instructions: usize,
16 pub total_branches: usize,
17 pub total_edges: usize,
18 pub reachable_pcs: HashSet<usize>,
20 pub reachable_branch_pcs: HashSet<usize>,
22 pub reachable_edges: HashSet<u64>,
24}
25
26#[derive(Clone, Debug, Default)]
28pub struct CoverageStats {
29 pub total_instructions: usize,
30 pub hit_instructions: usize,
31 pub total_branches: usize,
32 pub hit_branches: usize,
33 pub total_blocks: usize,
34 pub hit_blocks: usize,
35}
36
37impl CoverageStats {
38 pub fn instruction_coverage_pct(&self) -> f64 {
40 if self.total_instructions == 0 {
41 0.0
42 } else {
43 100.0 * self.hit_instructions as f64 / self.total_instructions as f64
44 }
45 }
46
47 pub fn branch_coverage_pct(&self) -> f64 {
49 if self.total_branches == 0 {
50 0.0
51 } else {
52 100.0 * self.hit_branches as f64 / self.total_branches as f64
53 }
54 }
55
56 pub fn block_coverage_pct(&self) -> f64 {
58 if self.total_blocks == 0 {
59 0.0
60 } else {
61 100.0 * self.hit_blocks as f64 / self.total_blocks as f64
62 }
63 }
64}
65
66#[derive(Clone, Debug, Default)]
68pub struct CoverageWriteStats {
69 pub run_time_secs: u64,
70 pub executions: u64,
71 pub edges_hit: usize,
72 pub edges_total: usize,
73 pub branches_hit: usize,
74 pub branches_total: usize,
75 pub instructions_hit: usize,
76 pub instructions_total: usize,
77}
78
79#[derive(Clone, Debug)]
81pub struct CachedFunctionInfo {
82 pub name: String,
83 pub entry_pc: usize,
84 pub total_instructions: usize,
85 pub total_blocks: usize,
86 pub instruction_pcs: Vec<usize>,
88 pub blocks: Vec<(usize, Vec<usize>)>,
90}
91
92#[derive(Clone, Debug)]
94pub struct CachedProgramAnalysis {
95 pub program_name: String,
96 pub functions: Vec<CachedFunctionInfo>,
98 pub cfg_json: std::collections::HashMap<String, String>,
100}