-
Notifications
You must be signed in to change notification settings - Fork 36.2k
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
[Tests] Include branch coverage info in coverage test #10511
Conversation
Here is a possible hack to force a variable list of arguments to be treated as 'used' for the purpose of static inline void MarkUsed() {}
template<typename T, typename... Args> static inline void MarkUsed(const T& t, const Args&... args)
{
(void)t;
MarkUsed(args...);
}
#ifdef USE_COVERAGE
#define LogPrintf(...) do { MarkUsed(__VA_ARGS__); } while(0)
#define LogPrint(category, ...) do { MarkUsed(__VA_ARGS__); } while(0)
#else |
Used @sipa's hack to shut up the warnings. |
Cool. Concept ACK. |
Added an option to configure to allow for branch coverage statistics gathering. Disabled logprint macro when coverage testing is on so that unnecessary branches are not analyzed.
contrib/filter-lcov.py
Outdated
with open(tracefile, 'r') as f: | ||
with open(outfile, 'w') as wf: | ||
for line in f: | ||
if pattern in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps instead use line.startswith("SF:" + pattern)
instead? That would prevent matching on variables that accidentally match the pattern name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
contrib/filter-lcov.py
Outdated
in_remove = True | ||
if not in_remove: | ||
wf.write(line) | ||
if 'end_of_record' in line: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Perhaps use line == 'end_of_record'
instead? Same reason as above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
8687849
to
405b86a
Compare
utACK 405b86a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK
@@ -0,0 +1,24 @@ | |||
#!/usr/bin/env python3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
explicit license is missing:
# Copyright (c) 2017 Bitcoin Core Developers
# Distributed under the MIT software license, see the accompanying
# file COPYING or http://www.opensource.org/licenses/mit-license.php.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
with open(outfile, 'w') as wf: | ||
for line in f: | ||
if line.startswith("SF:") and pattern in line: | ||
in_remove = True |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure why you need the var in_remove
. Couldn't you write wf.write(line);continue;
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The format of the file is
SF:<path to file>
<bunch of lines>
end_of_record
<repeat>
In order to know that we are in a <bunch of lines>
section that should be removed (because the SF:...
line matches our removal pattern, we need to have a variable to remember that we shouldn't be writing these lines to the output file. That is what in_remove
is for.
Instead of using lcov -r (which is extremely slow), first use a python script to perform bulk cleanup of the /usr/include/* coverage. Then use lcov -a to remove the duplicate entries. This has the same effect of lcov -r but runs significantly faster
The lcov stuff was added ages ago, when lcov's --no-external was too new to rely on. I think it'd be ok now to require >=1.10 and forego all of the filtering. |
@achow101 Are you still working on this? |
@MarcoFalke Yes |
Would it be okay with everyone if I just merged #10565 into this PR? It all falls under "improvements to coverage data". |
Needs rebase. |
Closing this as #10565 contains this PR (I totally forgot) except for the copyright header I added last commit :/ |
This PR adds an option to configure to include branch coverage statistics be gathered during
make cov
. It also disables logging when coverage is enabled so that the logging branches are not included in the coverage stats. This has a side effect of causing-Wunused-variable
warnings during compile time when coverage is enabled.