Skip to content

Commit f6b4cbf

Browse files
committed
Add tests of the affect of assumptions on coverage blocks
1 parent f7d9e49 commit f6b4cbf

File tree

4 files changed

+52
-0
lines changed

4 files changed

+52
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#include <assert.h>
2+
3+
void main()
4+
{
5+
int i;
6+
int *p = &i;
7+
int j;
8+
__CPROVER_assume(j == 1 / (*p));
9+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
CORE
2+
end.c
3+
--pointer-check --div-by-zero-check --cover location
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main.coverage.1\] file end.c line 5 function main block 1 \(lines end\.c:main:5-8\): SATISFIED$
7+
^\[main.coverage.2\] file end.c line 8 function main block 2 \(lines end\.c:main:8\): SATISFIED$
8+
^\[main.coverage.3\] file end.c line 8 function main block 3 \(lines end\.c:main:8\): SATISFIED$
9+
^\[main.coverage.4\] file end.c line 8 function main block 4 \(lines end\.c:main:8\): SATISFIED$
10+
^\[main.coverage.5\] file end.c line 9 function main block 5 \(lines end\.c:main:9\): SATISFIED$
11+
^\*\* 5 of 5 covered \(100.0%\)
12+
--
13+
^warning: ignoring
14+
--
15+
Test that in the case where multiple assertions are added on the same line of
16+
code due to the addition of instrumentation checks, these do not result in
17+
further splitting blocks.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#include <assert.h>
2+
3+
int main()
4+
{
5+
int i;
6+
int j;
7+
j = i;
8+
__CPROVER_assume(0);
9+
j = i + 2;
10+
return 0;
11+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
CORE
2+
middle.c
3+
--cover location
4+
^EXIT=0$
5+
^SIGNAL=0$
6+
^\[main.coverage.1\] file middle.c line 5 function main block 1 \(lines middle\.c:main:5-8\): SATISFIED$
7+
^\[main.coverage.2\] file middle.c line 9 function main block 2 \(lines middle\.c:main:9-11\): FAILED$
8+
^\*\* 1 of 2 covered \(50.0%\)
9+
--
10+
^warning: ignoring
11+
--
12+
This test confirms that assumptions in the middle of what would otherwise be a
13+
single blocks without control flow will cause the code to be split into 2
14+
coverage blocks. This is required as an unsatisfiable assumption can result in
15+
the following statements being unreachable.

0 commit comments

Comments
 (0)