lcov icon indicating copy to clipboard operation
lcov copied to clipboard

Confused with branch coverage

Open juraj67 opened this issue 5 years ago • 3 comments

Hi, I would like to ask, if there is a way to do properly only conditional branch coverage with LCOV/GCOV.

I found this simple project which is showing the problem: https://github.com/ghandmann/lcov-branch-coverage-weirdness

There is also some thread about this problem: https://stackoverflow.com/questions/42003783/lcov-gcov-branch-coverage-with-c-producing-branches-all-over-the-place

I can't use -fno-exceptions flag, so I would like to know if there is any solution for this problem.

Thanks in advance for your help.

juraj67 avatar Feb 13 '20 12:02 juraj67

With the solution proposed in Pull Request #80 you can exclude exception branches from branch coverage, which will reduce a lot the coverage errors in the report.

You could try the version from the PR with your code to check if it has the expected results.

jgonzalezdr avatar May 14 '20 18:05 jgonzalezdr

Hi @jgonzalezdr, Have you progressed ? Will be your pull request merged with master ?

Thanks in advance for your answer.

juraj67 avatar Jun 26 '20 13:06 juraj67

Hi @jgonzalezdr, I have tried your solution from Pull Request #80 on this simple project: https://github.com/ghandmann/lcov-branch-coverage-weirdness

Result before using your solution: image

Result after using your solution: image

Some branch coverage errors in the report are reduced, but the main error caused by the std namespace is still there. Any ideas ?

Thanks in advance for your help

juraj67 avatar Jul 14 '20 11:07 juraj67

PR #116 contains a partial fix for this issue (see "--filter branch). There is a discussion in various places about why that could be considered a hack - and does not completely address the issue. Unfortunately - given the way that lcov works, the underlying issue is not one that can be solved by lcov (need compiler/tool chain support).

henry2cox avatar Nov 10 '22 11:11 henry2cox

There are a few other issue requests about branch coverage strangeness. The specific issues mentioned here are addressed in SHA 5f659f63801e, I think. Could you try your actual code with the current TOT to see if issues remain?

I fear that any issues that do remain might be very hard to fix given the filtering approach that I took, and the lack of real compiler infrastructure in lcov. (That lack is likely never going to be fixed.)

You will have to decide if your issue is resolved or not :-)

Henry

henry2cox avatar Dec 08 '22 09:12 henry2cox

6 months with no update or further comments. I believe this issue is addressed - so closing it.

If there is still a problem, please reopen this issue or file a new issue. Please provide a detailed description of the problem you see and ideally also provide a small testcase which illustrates the issue. Henry

henry2cox avatar May 11 '23 10:05 henry2cox