Skip to content

Add fault-localization regression tests #5934

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 2, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions doc/assets/xml_spec.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,27 @@

<xs:element name="refinement-iteration" type="xs:integer"/>

<xs:element name="fault-localization">
<xs:complexType>
<xs:sequence>
<xs:element name="diagnosis">
<xs:complexType>
<xs:sequence>
<xs:element name="result">
<xs:complexType>
<xs:sequence>
<xs:element ref="location"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="property" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>

<xs:element name="program" type="xs:string"/>
<xs:element name="cprover-status" type="xs:string"/>
<xs:element name="cprover">
Expand All @@ -193,6 +214,7 @@
<xs:element ref="message"/>
<xs:element ref="result"/>
<xs:element ref="refinement-iteration"/>
<xs:element ref="fault-localization"/>
</xs:choice>
<xs:element ref="cprover-status" minOccurs="0"/>
</xs:sequence>
Expand Down
12 changes: 12 additions & 0 deletions regression/cbmc/fault_localization-all_properties1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <assert.h>

void main()
{
int x, c;
if(c)
x = 0;
else
x++;
assert(x == 0);
assert(x != 0);
}
12 changes: 12 additions & 0 deletions regression/cbmc/fault_localization-all_properties1/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
KNOWNBUG
main.c
--localize-faults
^EXIT=10$
^SIGNAL=0$
line 7 function main$
line 9 function main$
^VERIFICATION FAILED$
--
--
With --localize-faults, CBMC only reports the first assertion as failing.
Without --localize-faults, CBMC correctly reports both assertions as failing.
12 changes: 12 additions & 0 deletions regression/cbmc/fault_localization-all_properties2/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <assert.h>

void main()
{
int x, c;
if(c)
x = 0;
else
x++;
assert(x == 0);
assert(x == 0 || c == 0);
}
11 changes: 11 additions & 0 deletions regression/cbmc/fault_localization-all_properties2/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
KNOWNBUG
main.c
--localize-faults
^EXIT=10$
^SIGNAL=0$
line 9 function main$
^VERIFICATION FAILED$
--
--
CBMC wrongly reports line 7 as the faulty statement when instead it should be
line 9.
12 changes: 12 additions & 0 deletions regression/cbmc/fault_localization-stop_on_fail1/main.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include <assert.h>

void main()
{
int x, c;
if(c)
x = 0;
else
x++;
assert(x == 0);
assert(x != 0);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
CORE
CORE paths-lifo-expected-failure broken-smt-backend
main.c
--localize-faults --stop-on-fail
^EXIT=10$
^SIGNAL=0$
^\[main.assertion.1\]:
^\[main.assertion.[12]\]:
line . function main$
^VERIFICATION FAILED$
--
12 changes: 0 additions & 12 deletions regression/fault-localization/Makefile

This file was deleted.

10 changes: 0 additions & 10 deletions regression/fault-localization/all_properties1/main.c

This file was deleted.

9 changes: 0 additions & 9 deletions regression/fault-localization/all_properties1/test.desc

This file was deleted.

10 changes: 0 additions & 10 deletions regression/fault-localization/all_properties2/main.c

This file was deleted.

8 changes: 0 additions & 8 deletions regression/fault-localization/all_properties2/test.desc

This file was deleted.

10 changes: 0 additions & 10 deletions regression/fault-localization/stop_on_fail1/main.c

This file was deleted.

17 changes: 9 additions & 8 deletions src/goto-checker/bmc_util.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,21 +79,22 @@ void output_error_trace(

case ui_message_handlert::uit::XML_UI:
{
xmlt xml;
convert(ns, goto_trace, xml);
msg.status() << xml;
const goto_trace_stept &last_step = goto_trace.get_last_step();
property_infot info{
last_step.pc, last_step.comment, property_statust::FAIL};
xmlt xml_result = xml(last_step.property_id, info);
convert(ns, goto_trace, xml_result.new_element());
msg.result() << xml_result;
}
break;

case ui_message_handlert::uit::JSON_UI:
{
json_stream_objectt &json_result =
ui_message_handler.get_json_stream().push_back_stream_object();
const goto_trace_stept &step = goto_trace.steps.back();
json_result["property"] =
json_stringt(step.pc->source_location.get_property_id());
json_result["description"] =
json_stringt(step.pc->source_location.get_comment());
const goto_trace_stept &step = goto_trace.get_last_step();
json_result["property"] = json_stringt(step.property_id);
json_result["description"] = json_stringt(step.comment);
json_result["status"] = json_stringt("failed");
json_stream_arrayt &json_trace =
json_result.push_back_stream_array("trace");
Expand Down