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

Minor bugfixes to generate Gcov/Lcov branch coverage #11489

Closed
wants to merge 5 commits into from

Conversation

MichaelKlemm
Copy link
Contributor

When using bazel to generate C++ branch coverage BA entries are created instead of BRDA lines. As far as these BA lines could not be used by genhtml, I changed it be processed as BRDA. Doing so the program throws an exception because of the wrong condition, trying to convert a '-' to a number. Inverted this condition to have the correct behavior of '-' which means wasExecuted = false and executionCount = 0.

@MichaelKlemm MichaelKlemm requested a review from lberki as a code owner May 26, 2020 11:56
@googlebot
Copy link

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project (if not, look below for help). Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed (or fixed any issues), please reply here with @googlebot I signed it! and we'll verify it.


What to do if you already signed the CLA

Individual signers
Corporate signers

ℹ️ Googlers: Go here for more info.

@MichaelKlemm
Copy link
Contributor Author

@googlebot I signed it!

@googlebot
Copy link

CLAs look good, thanks!

ℹ️ Googlers: Go here for more info.

@MichaelKlemm
Copy link
Contributor Author

recheck

Copy link
Contributor

@ulfjack ulfjack left a comment

Choose a reason for hiding this comment

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

It might be better to split this into two changes, and also add tests for each of the bugfixes.

Replaced obsolete 'BA:' tag by 'BRDA:' to be able to generate a valid branch
coverage report.
On taken indicator '-' the current implementation of the  LcovParser was
setting the branch as executed and tried to convert the sign '-' to a number.
Doing so an exception was thrown. Just inverted the condition to fix the
problem.
@MichaelKlemm
Copy link
Contributor Author

It might be better to split this into two changes, and also add tests for each of the bugfixes.

I know, one is the parsing and the other one the printing. Implementing tests will strongly combine these two, so I would suggest to keep it together.

@ulfjack
Copy link
Contributor

ulfjack commented May 27, 2020

Unfortunately, I don't know the history of the BA lines, but I wouldn't be surprised if the tool just changed silently at some minor version. The coverage tools seem to have a habit of doing that. :-/

The change looks reasonable to me, but I didn't do a careful review of the tests, and I also didn't research the BA / BRDA thing.

@meisterT can you take a look as well, or find someone to take a look?

@meisterT meisterT added the team-Rules-Server Issues for serverside rules included with Bazel label May 27, 2020
@meisterT
Copy link
Member

Sorry, I have no clue about this.
cc @lberki

@MichaelKlemm
Copy link
Contributor Author

Are there any other tools being used besides the lcov project (genhtml, geninfo, ...) using the *.dat output? I don't want to destroy compatibility but as far as I know there is only the one specification at the LCOV project and this is not using BA at all. So BRDA seems to be the way to go and it's also working quite well with my local C++ environment using branch coverage.

How to proceed here?

@ulfjack
Copy link
Contributor

ulfjack commented Jun 1, 2020

I think a couple tools use lcov internal output for further processing. Regardless, if lcov HEAD accepts this and doesn't accept or document BA, I think it's fine to change it to BRDA unconditionally.

@ulfjack
Copy link
Contributor

ulfjack commented Jun 2, 2020

So, the BA lines date back to lcov 1.9 (https://chromium.googlesource.com/chromium/src/third_party/lcov/+/dd41bfc42b684e08eb9205301932bae3056ff8e4%5E%21/). BRDA was introduced in 1.10 (http://ltp.sourceforge.net/coverage/lcov/changes.php):

commit b5c1bdddd1380be3ad12952ed2747df3744e227e 
Author: Peter Oberparleiter <[email protected]>
Date:   Wed Oct 10 08:20:21 2012 +0000

    lcov: finalizing release 1.10

I think it's fine not to support an 8-year-old release at this point.

@ulfjack
Copy link
Contributor

ulfjack commented Jun 2, 2020

@lberki doesn't seem to be very responsive. Lots of work to do?

@@ -280,7 +248,7 @@ private boolean parseBRDALine(String line) {

boolean wasExecuted = false;
Copy link
Contributor

Choose a reason for hiding this comment

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

This line can be deleted.

@@ -22,7 +22,7 @@

static BranchCoverage create(int lineNumber, int nrOfExecutions) {
return new AutoValue_BranchCoverage(
lineNumber, /*blockNumber=*/ "", /*branchNumber=*/ "", nrOfExecutions);
lineNumber, /*blockNumber=*/ "0", /*branchNumber=*/ "0", nrOfExecutions);
Copy link
Contributor

Choose a reason for hiding this comment

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

Are the two numbers here valid GCC IDs?

Below in this file it says it should be -1 for non-gcc emitted coverage. I'm guessing that if we don't have the values present, it should be -1 and not 0?

@oquenchil
Copy link
Contributor

Thank you for the change! I have a couple of nits.

@oquenchil
Copy link
Contributor

Actually hold on addressing my comments. A colleague has just told me that BA may be important internally. I will ping this again once I know more.

@ulfjack
Copy link
Contributor

ulfjack commented Jun 15, 2020

@oquenchil any updates? It's been a week...

@oquenchil
Copy link
Contributor

The problem that we are facing with coverage is that we have quite the knowledge gap right now and not enough people. I'm trying to fill that gap but I have been very busy with other issues.

The previous expert on coverage in the team told me that the BA line is important internally but they didn't remember why. I wrote an email today to reach out to 2 other people in the company that may have more context.

I will ping this once they reply.

@ulfjack
Copy link
Contributor

ulfjack commented Jun 15, 2020

Would it help if this change added support for BRDA lines without converting to or from BA lines? Would that be an option, @MichaelKlemm ?

@oquenchil
Copy link
Contributor

I asked this as well because from the reply I got yesterday it wasn't clear. If I cannot tell you for certain tomorrow, I will try importing this PR with the BA deletion anyway and then we might find out later in which way it was important.

Meanwhile, @MichaelKlemm could you please address the 2 nits?

@oquenchil
Copy link
Contributor

Ok, I have more information now. We definitely have internal tools still reporting BA lines. But we will change that. Meanwhile, if you can change this PR to be able to parse BA lines and treat them as BRDA, then that should be enough not to break anything as far as I can tell.

Thank you!

@meisterT
Copy link
Member

What is the status of this PR?

@oquenchil
Copy link
Contributor

Ok, I have more information now. We definitely have internal tools still reporting BA lines. But we will change that. Meanwhile, if you can change this PR to be able to parse BA lines and treat them as BRDA, then that should be enough not to break anything as far as I can tell.

Thank you!

It doesn't look like the internal tools will be changed any time soon, so this PR should keep the BA lines.

@c-mita
Copy link
Member

c-mita commented Aug 7, 2020

We're currently in the process of fixing issues around the handling of lcov; fixes to the parser are part of that, as is changing the generators to not output "BA" lines.

Unfortunately we cannot remove support for BA lines yet as they are still used internally at Google.

@c-mita c-mita closed this Aug 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes team-Rules-Server Issues for serverside rules included with Bazel
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants