Skip to content

Commit

Permalink
Print failed checks for global conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
adpaco-aws committed Jun 19, 2023
1 parent ec604a7 commit b77937e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 3 deletions.
12 changes: 12 additions & 0 deletions kani-driver/src/call_cbmc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,18 @@ impl GlobalCondition {
},
}
}

pub fn blame_properties<'a>(&self, properties: &'a[Property]) -> Vec<&'a Property> {
match &self {
Self::ShouldPanic { status, .. } => match *status {
FailedProperties::None => properties.iter().filter(|prop| prop.property_class() == "assertion" && prop.status != CheckStatus::Failure).collect(),
FailedProperties::Other => properties.iter().filter(|prop| prop.property_class() != "assertion" && prop.status == CheckStatus::Failure).collect(),
_ => vec![],
},
Self::FailUncoverable { .. } =>
properties.iter().filter(|prop| prop.property_class() == "cover" && prop.status != CheckStatus::Satisfied).collect(),
}
}
}

/// Our (kani-driver) notions of CBMC results.
Expand Down
12 changes: 9 additions & 3 deletions kani-driver/src/cbmc_property_renderer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -332,18 +332,24 @@ pub fn format_result(
result_str.push_str("GLOBAL CONDITIONS:\n");
for cond in global_conditions {
if cond.enabled() {
let cond_status = if cond.passed() {
CheckStatus::Success
let (cond_status, blame_properties) = if cond.passed() {
(CheckStatus::Success, None)
} else {
global_condition_failures = true;
CheckStatus::Failure
(CheckStatus::Failure, Some(cond.blame_properties(&properties)))
};
result_str.push_str(&format!(
" - {}: {} ({})\n",
cond.name(),
cond_status,
cond.reason()
));
if !cond.passed() {
for prop in blame_properties.unwrap() {
let failure_message = build_failure_message(prop.description.clone(), &prop.trace.clone());
result_str.push_str(&failure_message);
}
}
}
}
}
Expand Down

0 comments on commit b77937e

Please sign in to comment.