Skip to content

Commit fddd098

Browse files
martinmartin
authored andcommitted
Add a test case for per-history verification
This shows that call-stack sensitivity (unsurprisingly) can significantly improve results -- but only with the previous patch.
1 parent 345d7eb commit fddd098

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
#include <assert.h>
2+
3+
void f00(int x, int y)
4+
{
5+
if(x < 0)
6+
{
7+
// Unreachable in all traces if they are considered individually
8+
assert(x < 0);
9+
assert(1);
10+
assert(0);
11+
}
12+
13+
assert(x >= 0); // True in all traces
14+
assert(x < 0); // False in all traces
15+
assert(x < 2); // Split; true in some, false in others
16+
17+
assert((x <= 0) ? 1 : y); // True in some, unknown in others
18+
assert((x <= 1) ? 0 : y); // False in some, unknown in others
19+
assert((x <= 2) ? ((x <= 3) ? 1 : 0) : y); // A mix of all three
20+
21+
if(x < 5)
22+
{
23+
// Not reachable in all traces
24+
assert((x <= 0) ? 1 : y); // True in some, unknown in others
25+
assert((x <= 1) ? 0 : y); // False in some, unknown in others
26+
assert((x <= 2) ? ((x <= 3) ? 1 : 0) : y); // A mix of all three
27+
}
28+
29+
if(x < 3)
30+
{
31+
// Not reachable in all traces
32+
assert((x <= 0) ? 1 : y); // True in some, unknown in others
33+
assert((x <= 1) ? 0 : y); // False in some, unknown in others
34+
assert((x <= 2) ? ((x <= 3) ? 1 : 0) : y); // A mix of all three
35+
}
36+
}
37+
38+
int nondet_int();
39+
40+
int main(int argc, char **argv)
41+
{
42+
int y = nondet_int();
43+
44+
// Because the history is context sensitive these should be analysed independently
45+
// Just showing the domain will merge them giving top for everything interesting
46+
f00(0, y);
47+
f00(1, y);
48+
f00(2, y);
49+
f00(3, y);
50+
f00(4, y);
51+
f00(5, y);
52+
53+
return 0;
54+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
CORE
2+
main.c
3+
--verify --recursive-interprocedural --call-stack 0 --constants --one-domain-per-history
4+
^\[f00.assertion.1\] .* assertion x < 0: SUCCESS \(unreachable\)$
5+
^\[f00.assertion.2\] .* assertion 1: SUCCESS \(unreachable\)$
6+
^\[f00.assertion.3\] .* assertion 0: SUCCESS \(unreachable\)$
7+
^\[f00.assertion.4\] .* assertion x >= 0: SUCCESS$
8+
^\[f00.assertion.5\] .* assertion x < 0: FAILURE \(if reachable\)$
9+
^\[f00.assertion.6\] .* assertion x < 2: FAILURE \(if reachable\)$
10+
^\[f00.assertion.7\] .* assertion \(x <= 0\) \? 1 : y: UNKNOWN$
11+
^\[f00.assertion.8\] .* assertion \(x <= 1\) \? 0 : y: UNKNOWN$
12+
^\[f00.assertion.9\] .* assertion \(x <= 2\) \? \(\(x <= 3\) \? 1 : 0\) : y: UNKNOWN$
13+
^\[f00.assertion.10\] .* assertion \(x <= 0\) \? 1 : y: UNKNOWN$
14+
^\[f00.assertion.11\] .* assertion \(x <= 1\) \? 0 : y: UNKNOWN$
15+
^\[f00.assertion.12\] .* assertion \(x <= 2\) \? \(\(x <= 3\) \? 1 : 0\) : y: UNKNOWN$
16+
^\[f00.assertion.13\] .* assertion \(x <= 0\) \? 1 : y: UNKNOWN$
17+
^\[f00.assertion.14\] .* assertion \(x <= 1\) \? 0 : y: UNKNOWN$
18+
^\[f00.assertion.15\] .* assertion \(x <= 2\) \? \(\(x <= 3\) \? 1 : 0\) : y: SUCCESS$
19+
^EXIT=0$
20+
^SIGNAL=0$
21+
--
22+
^warning: ignoring
23+
--
24+
Tests the verify tasks handling of multiple traces for each assertion
25+

0 commit comments

Comments
 (0)