Skip to content

Commit f7d9e49

Browse files
committed
Define coverage blocks so as to be terminated by assumptions
If a coverage block has an assumption in the middle then then an assertion at the end of the block could be reported as covered but actually be unreachable due to the preceding the assumption. Therefore coverage blocks should be terminated by assumptions in order to ensure than coverage reporting is accurate.
1 parent 0838c70 commit f7d9e49

File tree

7 files changed

+23
-13
lines changed

7 files changed

+23
-13
lines changed

regression/cbmc-cover/location12/test.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ main.c
77
^\[main.coverage.2\] file main.c line 10 function main block 2.*: SATISFIED$
88
^\[foo.coverage.1\] file main.c line 3 function foo block 1.*: SATISFIED$
99
^\[foo.coverage.2\] file main.c line 4 function foo block 2.*: FAILED$
10-
^\[foo.coverage.3\] file main.c line 5 function foo block 3.*: SATISFIED$
11-
^\*\* 4 of 5 covered \(80.0%\)
10+
^\[foo.coverage.3\] file main.c line 5 function foo block 3.*: FAILED$
11+
^\[foo.coverage.4\] file main.c line 5 function foo block 4.*: SATISFIED$
12+
^\*\* 4 of 6 covered \(66.7%\)
1213
--
1314
^warning: ignoring

regression/cbmc-cover/location15/test.desc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@ main.c
66
^\[main.coverage.1\] file main.c line 10 function main block 1.*: SATISFIED$
77
^\[main.coverage.2\] file main.c line 10 function main block 2.*: SATISFIED$
88
^\[main.coverage.3\] file main.c line 13 function main block 3.*: FAILED$
9-
^\[main.coverage.4\] file main.c line 16 function main block 4.*: SATISFIED$
9+
^\[main.coverage.4\] file main.c line 14 function main block 4.*: FAILED$
10+
^\[main.coverage.5\] file main.c line 16 function main block 5.*: SATISFIED$
1011
^\[foo.coverage.1\] file main.c line 5 function foo block 1.*: FAILED$
1112
^\*\* 3 of \d+ covered
1213
--

regression/cbmc-cover/location16/test.desc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ main.c
99
^\[func.coverage.2\] file main.c line 6 function func block 2.*: FAILED$
1010
^\[func.coverage.3\] file main.c line 8 function func block 3.*: FAILED$
1111
^\[func.coverage.4\] file main.c line 12 function func block 4.*: FAILED$
12-
^\[func.coverage.5\] file main.c line 15 function func block 5.*: SATISFIED$
13-
^\*\* 4 of 7 covered \(57.1%\)
12+
^\[func.coverage.5\] file main.c line 14 function func block 5.*: FAILED$
13+
^\[func.coverage.6\] file main.c line 15 function func block 6.*: SATISFIED$
14+
^\*\* 4 of 8 covered \(50.0%\)
1415
--
1516
^warning: ignoring

regression/cbmc-cover/location2/test.desc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[main.coverage.1\] file main.c line 9 function main block 1 \(lines main.c:main:9,10\): SATISFIED$
7-
^\[main.coverage.2\] file main.c line 11 function main block 2 \(lines main.c:main:11\): SATISFIED$
8-
^\*\* 2 of 2 covered \(100.0%\)
7+
^\[main.coverage.3\] file main.c line 11 function main block 3 \(lines main.c:main:11\): SATISFIED$
8+
^\*\* 3 of 3 covered \(100.0%\)
99
--
1010
^warning: ignoring
1111
main.c::5

regression/cbmc-cover/simple_assert/test.desc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ main.c
44
^EXIT=0$
55
^SIGNAL=0$
66
^\[main\.coverage\.1\] .* function main block 1.*: SATISFIED$
7-
(1 of 1|3 of 3) covered \(100\.0%\)$
7+
(1 of 1|2 of 2|3 of 3) covered \(100\.0%\)$
88
--
99
^warning: ignoring
1010
^CONVERSION ERROR$

regression/cbmc/cover-failed-assertions/test-no-failed-assertions.desc

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
CORE paths-lifo-expected-failure new-smt-backend
22
test.c
33
--cover location --pointer-check --malloc-may-fail --malloc-fail-null
4-
\[main\.coverage\.4\] file test\.c line \d+ function main block 4 \(lines test\.c:main:17,18\): SATISFIED
5-
\[main\.coverage\.3\] file test\.c line \d+ function main block 3 \(lines test\.c:main:15\): FAILED
6-
\[main\.coverage\.2\] file test\.c line \d+ function main block 2 \(lines test\.c:main:5,6,12,14\): SATISFIED
4+
\[main\.coverage\.10\] file test\.c line \d+ function main block 10 \(lines test\.c:main:17,18\): SATISFIED
5+
\[main\.coverage\.9\] file test\.c line \d+ function main block 9 \(lines test\.c:main:15\): FAILED
6+
\[main\.coverage\.8\] file test\.c line \d+ function main block 8 \(lines test\.c:main:12,14\): SATISFIED
7+
\[main\.coverage\.7\] file test\.c line \d+ function main block 7 \(lines test\.c:main:12\): SATISFIED
8+
\[main\.coverage\.6\] file test\.c line \d+ function main block 6 \(lines test\.c:main:12\): SATISFIED
9+
\[main\.coverage\.5\] file test\.c line \d+ function main block 5 \(lines test\.c:main:12\): SATISFIED
10+
\[main\.coverage\.4\] file test\.c line \d+ function main block 4 \(lines test\.c:main:12\): SATISFIED
11+
\[main\.coverage\.3\] file test\.c line \d+ function main block 3 \(lines test\.c:main:12\): SATISFIED
12+
\[main\.coverage\.2\] file test\.c line \d+ function main block 2 \(lines test\.c:main:5,6,12\): SATISFIED
713
\[main\.coverage\.1\] file test\.c line \d+ function main block 1 \(lines test\.c:main:5\): SATISFIED
814
^EXIT=0$
915
^SIGNAL=0$

src/goto-instrument/cover_basic_blocks.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,11 @@ cover_basic_blockst::cover_basic_blockst(const goto_programt &goto_program)
7373
}
7474

7575
next_is_target =
76-
#if 0
77-
// Disabled for being too messy
76+
#if 1
77+
// Previously disabled for being too messy.
7878
it->is_goto() || it->is_function_call() || it->is_assume();
7979
#else
80+
// Disabled for being misleading.
8081
it->is_goto() || it->is_function_call();
8182
#endif
8283
}

0 commit comments

Comments
 (0)