Skip to content
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

Figure out a way to mark things as unreachable by unit tests #11

Open
olabini opened this issue Aug 26, 2015 · 12 comments
Open

Figure out a way to mark things as unreachable by unit tests #11

olabini opened this issue Aug 26, 2015 · 12 comments

Comments

@olabini
Copy link
Contributor

olabini commented Aug 26, 2015

https://trac.torproject.org/projects/tor/ticket/16792

@tdruiva
Copy link
Contributor

tdruiva commented Aug 27, 2015

   Exclusion markers

   To exclude specific lines of code from a tracefile, you can add  exclu-
   sion  markers to the source code. Additionally you can exclude specific
   branches from branch coverage without excluding the involved lines from
   line  and  function  coverage. Exclusion markers are keywords which can
   for example be added in the form of a comment.

   The following markers are recognized by geninfo:

   LCOV_EXCL_LINE
          Lines containing this marker will be excluded.
   LCOV_EXCL_START
          Marks the beginning of an excluded section. The current line  is
          part of this section.
   LCOV_EXCL_STOP
          Marks  the end of an excluded section. The current line not part
          of this section.
   LCOV_EXCL_BR_LINE
          Lines containing this marker will be excluded from branch cover-
          age.
   LCOV_EXCL_BR_START
          Marks  the  beginning of a section which is excluded from branch
          coverage. The current line is part of this section.
   LCOV_EXCL_BR_STOP
          Marks the end of a section which is excluded from branch  cover-
          age. The current line not part of this section.

@juniorz
Copy link
Member

juniorz commented Aug 27, 2015

\o/

@juniorz
Copy link
Member

juniorz commented Aug 27, 2015

The current code makes me believe it would be expected to have this in a macro, rather than a comment.

I would expect something along the lines of:

switch(some_value){
  case 1:
    // something
    break;
  case 0:
    // something else
    break;
  case -1:
    TOR_COV_UNREACHABLE_BEGIN
    //unreachable code
    TOR_COV_UNREACHABLE_ENF
}

but we have to double check with the Tor team.

I assume the macro would expand to LCOV_EXCL_START and LCOV_EXCL_STOP only if coverage is enable.

Who wants to start the conversation? ;)

@tdruiva
Copy link
Contributor

tdruiva commented Aug 27, 2015

Good point.
I'm starting a conversation by ticket message.

@tdruiva
Copy link
Contributor

tdruiva commented Aug 27, 2015

@tdruiva tdruiva reopened this Aug 28, 2015
@olabini
Copy link
Contributor Author

olabini commented Aug 28, 2015

Reinaldo, not sure I understand your point. What is the reason for having this be in macro's instead of in a comment?

@olabini
Copy link
Contributor Author

olabini commented Aug 28, 2015

Specifically, I think using macros for this is a bad idea, since macros usually have functional impliciations, while these things are specifically non-functional annotations.

@juniorz
Copy link
Member

juniorz commented Aug 28, 2015

My reasoning is to abstract the tool we are using.

Tor source code names their existing macros ad COVERAGE_ENABLED (and
TOR_COVERAGE) rather than "LCOV_ENABLED". On the same line, having
/LCOV_EXCL_START/ inside the code seems to be wrong, according to the
existing naming standard.

For this reason, I suggested to double check with the community before
assuming LCOV_EXCL_START is the way to go.

@olabini
Copy link
Contributor Author

olabini commented Aug 28, 2015

OK, I accept that reasoning. =)

@olabini
Copy link
Contributor Author

olabini commented Aug 28, 2015

however. that depends on whether LCOV expands macros or not when looking for those names

@tcz001
Copy link
Contributor

tcz001 commented Aug 28, 2015

Put it into macro could be a place where the coverage tool never goes to, I would prefer a trial before we say it's a solution or not.

@juniorz
Copy link
Member

juniorz commented Aug 28, 2015

I think my "proposal" is not feasible. "The C preprocessor converts comments to whitespace before macros are even considered"[1]

1 - https://gcc.gnu.org/onlinedocs/cpp/Concatenation.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants