Skip to content

Commit 46b2f30

Browse files
committed
Added test cases
1 parent a5560d9 commit 46b2f30

File tree

10 files changed

+179
-14
lines changed

10 files changed

+179
-14
lines changed

Test/irreduciblecfg/Await.bpl

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// RUN: %parallel-boogie "%s" > "%t"
2+
// RUN: %OutputCheck --file-to-check "%t" "%s"
3+
// CHECK-L: Boogie program verifier finished with 1 verified, 0 errors
4+
5+
var new: int;
6+
procedure await_eq_add(val : int)
7+
modifies new;
8+
ensures val == old(val);
9+
ensures (new == old(new) + val);
10+
{
11+
var x : int;
12+
var tmp : bool;
13+
assume tmp == true;
14+
B:
15+
havoc x;
16+
if (x == val) {
17+
goto E;
18+
}
19+
else {
20+
goto C;
21+
}
22+
C:
23+
if (tmp == true) {
24+
havoc x;
25+
}
26+
goto D;
27+
D:
28+
if (x != val) {
29+
goto C;
30+
}
31+
else {
32+
goto E;
33+
}
34+
E:
35+
havoc tmp;
36+
if (tmp == true) {
37+
new := new + x;
38+
goto G;
39+
}
40+
else {
41+
goto C;
42+
}
43+
G:
44+
}

Test/irreduciblecfg/Canonical.bpl

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// RUN: %parallel-boogie "%s" > "%t"
2+
// RUN: %OutputCheck --file-to-check "%t" "%s"
3+
// CHECK-L: Boogie program verifier finished with 1 verified, 0 errors
4+
5+
procedure Irreducible ()
6+
{
7+
A: goto B,C;
8+
B: goto C,D;
9+
C: goto B;
10+
D: return;
11+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
// RUN: %parallel-boogie "%s" > "%t"
2+
// RUN: %diff "%s.expect" "%t"
3+
4+
procedure irreducible() {
5+
var i: int;
6+
var j: int;
7+
8+
i := 1;
9+
goto B1, B4;
10+
11+
B1:
12+
assume j > 0;
13+
goto B2;
14+
15+
B2:
16+
assert i > 0;
17+
goto B3;
18+
19+
B3:
20+
assert j > 0;
21+
goto B4;
22+
23+
B4:
24+
i := i+1;
25+
goto B2;
26+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
CanonicalAssertAssume.bpl(20,9): Error: this loop invariant could not be proved on entry
2+
Execution trace:
3+
CanonicalAssertAssume.bpl(8,7): anon0
4+
5+
Boogie program verifier finished with 0 verified, 1 error
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// RUN: %parallel-boogie "%s" > "%t"
2+
// RUN: %OutputCheck --file-to-check "%t" "%s"
3+
// CHECK-L: Boogie program verifier finished with 1 verified, 0 errors
4+
5+
procedure simple_irreducible() {
6+
var x: int;
7+
x := 0;
8+
A:
9+
assert x == 0;
10+
x := x + 1;
11+
goto B, C;
12+
13+
B:
14+
assert x <= 2;
15+
x := x - 1;
16+
goto C, D;
17+
C:
18+
x := x + 1;
19+
goto B;
20+
D:
21+
assert x <= 1;
22+
}

Test/irreduciblecfg/Tangled.bpl

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// RUN: %parallel-boogie "%s" > "%t"
2+
// RUN: %OutputCheck --file-to-check "%t" "%s"
3+
// CHECK-L: Boogie program verifier finished with 1 verified, 0 errors
4+
5+
var x, y, z : int;
6+
var add: int;
7+
procedure tangled()
8+
requires x > 0;
9+
requires y > 0;
10+
requires z > 0;
11+
modifies x;
12+
modifies y;
13+
modifies z;
14+
modifies add;
15+
ensures (x + y + z) == old(x) + old(y) + old(z) + add - old(add);
16+
{
17+
A:
18+
goto B, C;
19+
B:
20+
assert (x + y + z) == old(x) + old(y) + old(z) + add - old(add);
21+
z := z - 1;
22+
x := x + 1;
23+
goto C, D, F, EXIT;
24+
C:
25+
x := x - 1;
26+
y := y + 1;
27+
goto B, D, E, EXIT;
28+
D:
29+
assert (x + y + z) == old(x) + old(y) + old(z) + add - old(add);
30+
y := y + 1;
31+
add := add + 1;
32+
goto E, F, D, G;
33+
E:
34+
assert (x + y + z) == old(x) + old(y) + old(z) + add - old(add);
35+
z := z + 1;
36+
add := add + 1;
37+
goto E, F, D, B;
38+
F:
39+
assert (x + y + z) == old(x) + old(y) + old(z) + add - old(add);
40+
x := x + 1;
41+
add := add + 1;
42+
goto E, F, D, C;
43+
G:
44+
z := z + 1;
45+
y := y - 1;
46+
goto B, D, EXIT;
47+
48+
EXIT:
49+
}

Test/irreduciblecfg/Unsound.bpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// RUN: %parallel-boogie "%s" > "%t"
2+
// RUN: %diff "%s.expect" "%t"
3+
4+
procedure unsound() {
5+
var x: int;
6+
assume(x == 0);
7+
if (true) {
8+
goto Inside;
9+
}
10+
while (x < 10000) {
11+
Inside: x := x + 1;
12+
}
13+
14+
assert(x == -1);
15+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Unsound.bpl(14,5): Error: this assertion could not be proved
2+
Execution trace:
3+
Unsound.bpl(6,5): anon0
4+
Unsound.bpl(8,9): anon4_Then
5+
Unsound.bpl(10,5): anon5_LoopDone
6+
7+
Boogie program verifier finished with 0 verified, 1 error

Test/test0/Irreducible.bpl

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

Test/test0/Irreducible.bpl.expect

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

0 commit comments

Comments
 (0)