Skip to content

Commit 598c554

Browse files
authored
Merge pull request #5934 from tautschnig/fault-localization-tests
Add fault-localization regression tests
2 parents 4ae0bcf + 40309c0 commit 598c554

File tree

14 files changed

+92
-69
lines changed

14 files changed

+92
-69
lines changed

doc/assets/xml_spec.xsd

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,27 @@
183183

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

186+
<xs:element name="fault-localization">
187+
<xs:complexType>
188+
<xs:sequence>
189+
<xs:element name="diagnosis">
190+
<xs:complexType>
191+
<xs:sequence>
192+
<xs:element name="result">
193+
<xs:complexType>
194+
<xs:sequence>
195+
<xs:element ref="location"/>
196+
</xs:sequence>
197+
</xs:complexType>
198+
</xs:element>
199+
</xs:sequence>
200+
<xs:attribute name="property" type="xs:string"/>
201+
</xs:complexType>
202+
</xs:element>
203+
</xs:sequence>
204+
</xs:complexType>
205+
</xs:element>
206+
186207
<xs:element name="program" type="xs:string"/>
187208
<xs:element name="cprover-status" type="xs:string"/>
188209
<xs:element name="cprover">
@@ -193,6 +214,7 @@
193214
<xs:element ref="message"/>
194215
<xs:element ref="result"/>
195216
<xs:element ref="refinement-iteration"/>
217+
<xs:element ref="fault-localization"/>
196218
</xs:choice>
197219
<xs:element ref="cprover-status" minOccurs="0"/>
198220
</xs:sequence>
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
3+
void main()
4+
{
5+
int x, c;
6+
if(c)
7+
x = 0;
8+
else
9+
x++;
10+
assert(x == 0);
11+
assert(x != 0);
12+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
KNOWNBUG
2+
main.c
3+
--localize-faults
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 7 function main$
7+
line 9 function main$
8+
^VERIFICATION FAILED$
9+
--
10+
--
11+
With --localize-faults, CBMC only reports the first assertion as failing.
12+
Without --localize-faults, CBMC correctly reports both assertions as failing.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
3+
void main()
4+
{
5+
int x, c;
6+
if(c)
7+
x = 0;
8+
else
9+
x++;
10+
assert(x == 0);
11+
assert(x == 0 || c == 0);
12+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
KNOWNBUG
2+
main.c
3+
--localize-faults
4+
^EXIT=10$
5+
^SIGNAL=0$
6+
line 9 function main$
7+
^VERIFICATION FAILED$
8+
--
9+
--
10+
CBMC wrongly reports line 7 as the faulty statement when instead it should be
11+
line 9.
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#include <assert.h>
2+
3+
void main()
4+
{
5+
int x, c;
6+
if(c)
7+
x = 0;
8+
else
9+
x++;
10+
assert(x == 0);
11+
assert(x != 0);
12+
}
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
CORE
1+
CORE paths-lifo-expected-failure broken-smt-backend
22
main.c
33
--localize-faults --stop-on-fail
44
^EXIT=10$
55
^SIGNAL=0$
6-
^\[main.assertion.1\]:
6+
^\[main.assertion.[12]\]:
77
line . function main$
88
^VERIFICATION FAILED$
99
--

regression/fault-localization/Makefile

Lines changed: 0 additions & 12 deletions
This file was deleted.

regression/fault-localization/all_properties1/main.c

Lines changed: 0 additions & 10 deletions
This file was deleted.

regression/fault-localization/all_properties1/test.desc

Lines changed: 0 additions & 9 deletions
This file was deleted.

regression/fault-localization/all_properties2/main.c

Lines changed: 0 additions & 10 deletions
This file was deleted.

regression/fault-localization/all_properties2/test.desc

Lines changed: 0 additions & 8 deletions
This file was deleted.

regression/fault-localization/stop_on_fail1/main.c

Lines changed: 0 additions & 10 deletions
This file was deleted.

src/goto-checker/bmc_util.cpp

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -79,21 +79,22 @@ void output_error_trace(
7979

8080
case ui_message_handlert::uit::XML_UI:
8181
{
82-
xmlt xml;
83-
convert(ns, goto_trace, xml);
84-
msg.status() << xml;
82+
const goto_trace_stept &last_step = goto_trace.get_last_step();
83+
property_infot info{
84+
last_step.pc, last_step.comment, property_statust::FAIL};
85+
xmlt xml_result = xml(last_step.property_id, info);
86+
convert(ns, goto_trace, xml_result.new_element());
87+
msg.result() << xml_result;
8588
}
8689
break;
8790

8891
case ui_message_handlert::uit::JSON_UI:
8992
{
9093
json_stream_objectt &json_result =
9194
ui_message_handler.get_json_stream().push_back_stream_object();
92-
const goto_trace_stept &step = goto_trace.steps.back();
93-
json_result["property"] =
94-
json_stringt(step.pc->source_location.get_property_id());
95-
json_result["description"] =
96-
json_stringt(step.pc->source_location.get_comment());
95+
const goto_trace_stept &step = goto_trace.get_last_step();
96+
json_result["property"] = json_stringt(step.property_id);
97+
json_result["description"] = json_stringt(step.comment);
9798
json_result["status"] = json_stringt("failed");
9899
json_stream_arrayt &json_trace =
99100
json_result.push_back_stream_array("trace");

0 commit comments

Comments
 (0)