Skip to content

Commit 00906fd

Browse files
author
Remi Delmas
committed
CONTRACTS: loop normal form tests for DFCC
1 parent fda1142 commit 00906fd

File tree

8 files changed

+120
-0
lines changed

8 files changed

+120
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
int main()
2+
{
3+
int i = 0, j = 0, k = 0;
4+
5+
while(j < 10)
6+
{
7+
while(k < 10)
8+
__CPROVER_loop_invariant(1 == 1)
9+
{
10+
while(i < 10)
11+
{
12+
i++;
13+
}
14+
}
15+
j++;
16+
}
17+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
CORE dfcc-only
2+
main.c
3+
--dfcc main --apply-loop-contracts
4+
^file main.c line 10 function main: Found loop without contract nested in a loop with a contract.$
5+
^Please provide a contract or unwind this loop before applying loop contracts.$
6+
^EXIT=(6|10)$
7+
^SIGNAL=0$
8+
--
9+
--
10+
This test checks that our loop contract instrumentation verifies that loops
11+
nested in loops with contracts also have contracts.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
void main()
2+
{
3+
int i = 0;
4+
5+
HEAD:
6+
if(i > 5)
7+
goto EXIT;
8+
goto BODY;
9+
10+
LATCH:
11+
goto HEAD;
12+
13+
BODY:
14+
i++;
15+
goto LATCH;
16+
17+
EXIT:;
18+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE dfcc-only
2+
main.c
3+
--dfcc main --apply-loop-contracts
4+
^Found loop body instruction outside of the \[head, latch\] instruction span$
5+
^EXIT=(6|10)$
6+
^SIGNAL=0$
7+
--
8+
--
9+
This test checks that our loop contract instrumentation verifies that loops
10+
nested in loops with contracts also have contracts.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
void main()
2+
{
3+
int i = 0;
4+
int j = 0;
5+
6+
HEAD1:
7+
if(i > 5)
8+
goto EXIT1;
9+
goto BODY1;
10+
11+
EXIT1:;
12+
HEAD2:
13+
if(j > 5)
14+
goto EXIT2;
15+
goto BODY2;
16+
17+
BODY1:
18+
i++;
19+
goto HEAD1;
20+
21+
BODY2:
22+
j++;
23+
goto HEAD2;
24+
EXIT2:;
25+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE dfcc-only
2+
main.c
3+
--dfcc main --apply-loop-contracts
4+
^Found loops with overlapping instruction spans$
5+
^EXIT=(6|10)$
6+
^SIGNAL=0$
7+
--
8+
--
9+
This test checks that our loop contract instrumentation verifies that loops
10+
nested in loops with contracts also have contracts.
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <assert.h>
2+
3+
void main()
4+
{
5+
int i = 0;
6+
int j = 0;
7+
8+
HEAD:
9+
if(i > 5)
10+
goto EXIT1;
11+
i++;
12+
goto HEAD;
13+
EXIT1:;
14+
if(j > 5)
15+
goto EXIT2;
16+
j++;
17+
goto HEAD;
18+
EXIT2:;
19+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
CORE dfcc-only
2+
main.c
3+
--dfcc main --apply-loop-contracts
4+
^Found loop with more than one latch instruction$
5+
^EXIT=(6|10)$
6+
^SIGNAL=0$
7+
--
8+
--
9+
This test checks that our loop contract instrumentation verifies that loops
10+
nested in loops with contracts also have contracts.

0 commit comments

Comments
 (0)