Skip to content

Make location coverage reported include all lines of a multi-line statement #5635

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Could use a comment explaining what this is here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is already explained in a comment of the .desc file.

*
23 changes: 23 additions & 0 deletions regression/cbmc-cover/location-multiline-statement/example.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#include <stdlib.h>

int foo(int x, int y)
{
return x;
}

int main()
{
int *ptr = malloc(sizeof(*ptr));

// clang-format off
foo(1,
*ptr);
// clang-format on

if(0)
{
*ptr = 0;
}

return 0;
}
25 changes: 25 additions & 0 deletions regression/cbmc-cover/location-multiline-statement/multi-file.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include <stdlib.h>

int foo(int x, int y)
{
return x;
}

int main()
{
int *ptr = malloc(sizeof(*ptr));

// clang-format off
foo(
1,
#include "dereference.h"
ptr);
// clang-format on

if(0)
{
*ptr = 0;
}

return 0;
}
11 changes: 11 additions & 0 deletions regression/cbmc-cover/location-multiline-statement/multi-file.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
multi-file.c
--cover location
^EXIT=0$
^SIGNAL=0$
^\[main.coverage.2\] file multi-file.c line 10 function main block 2 \(lines [\w\- /\.\\:]*dereference.h:main:2; multi-file.c:main:10,13,14,16\): SATISFIED
--
^warning: ignoring
--
Test that the lines covered by location coverage in the output include all lines
of a multi-line statement where some of the lines are in an included file.
11 changes: 11 additions & 0 deletions regression/cbmc-cover/location-multiline-statement/test.desc
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
CORE
example.c
--cover location
^EXIT=0$
^SIGNAL=0$
^\[main.coverage.2\] file example.c line 10 function main block 2 \(lines example.c:main:10,13,14\): SATISFIED$
--
^warning: ignoring
--
Test that the lines covered by location coverage in the output include all lines
of a multi-line statement.