It would be great to have a way to tell the test coverage code "this line won't be reached by tests, so don't worry about it." This would let us have a prayer of reaching 100%.
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items
0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items
0
Link issues together to show that they're related.
Learn more.
We can use the lcov exclusion markers like: LCOV_EXCL_LINE, LCOV_EXCL_START, LCOV_EXCL_STOP,
LCOV_EXCL_BR_LINE, LCOV_EXCL_BR_START and, LCOV_EXCL_BR_STOP.
The usage will be something like this:
/* LCOV_EXCL_START /
if (!options->Tor2webMode) {
log_err(LD_CONFIG, "This copy of Tor was compiled to run in "
"'tor2web mode'. It can only be run with the Tor2webMode torrc "
"option enabled.");
return -1;
}
/ LCOV_EXCL_STOP */
What do you think if we use macros to have this markers only if the coverage is enable?
Something like:
switch(some_value){
case 1:
// something
break;
case 0:
// something else
break;
case -1:
TOR_COV_UNREACHABLE_BEGIN
//unreachable code
TOR_COV_UNREACHABLE_ENF
}
The only reason was to abstract from the tool we are using - since Tor source code names the existing macros as COVERAGE_ENABLED (and TOR_COVERAGE) rather than LCOV_ENABLED.
I think that the approach from comment:6 above is the best we're going to be able to do. We'll need to teach our own coverage-parsers about them, though.
Note: my approach to when we should use these LCOV_EXCL lines differs from the approach taken in tortls.c and config.c so far. I believe that we should only mark a line as excluded when it is truly unreachable. The annotations in tortls.c think that "maybe unreachable" can be a good enough reason.