Closed yangsee0 closed 9 months ago
g++ -o sol -fprofile-arcs -ftest-coverage main.cpp sol.cpp ./sol gcov -abcf main.cpp sol.cpp lcov --rc lcov_branch_coverage=1 --capture --directory ./ --output-file sol.info genhtml --branch-coverage ./sol.info --output-directory ./cov
Exception handlers.
Did you happen to compile and run your lcov 1.6 test with gcc (C compiler) and the 2.0 test with g++ (C++ compiler)?
If so: that would explain the difference.
For lcov 2.0, you can use filtering to remove some of the bogus branches.
$ man genhtml <- then search for "filter" "branch" and "exception"
Confirmation is late. We have confirmed that it has been resolved by adding the --filter branch option you informed us. Thank you for your answer.
before : genhtml --branch-coverage ./sol.info --output-directory ./cov
after : genhtml --branch-coverage --filter branch ./sol.info --output-directory ./cov
“--filter branch” works for me, thanks very much
Test: gcc version 8.5.0 20210514 (Red Hat 8.5.0-15) (GCC)
I tested the gcov version differently on the same server, but the branch coverage is different. What's wrong with it? Please give your opinion. Thank you.
lcov 1.6.20230126![image](https://github.com/linux-test-project/lcov/assets/96777011/23e59b37-4c65-4007-ab0f-cab21e770e2a)
lcov 2.0![image](https://github.com/linux-test-project/lcov/assets/96777011/5206fd15-31e8-4ae3-9414-d716fc8c6057)