Hi,
I have an issue with code coverage reporting in SonarQube. More specfically, I have C code that is analyzed by sonar-scanner, and I use the cmocka (v1.1.5) unit testing framework to run some unit tests. These unit tests generate note files that are then parsed by gcov (v7.5.0) to produce .gcov files, which are in turn parsed by sonar-scanner.
My issue is with branches coverage: some branches are considered by SonarQube as “Not covered by tests”, even though the .gcov file indicates otherwise; on the other hand, most branches are parsed just fine. For instance, I have the following piece of code (the red line hover text reads “Not covered by tests (2 conditions).”):
and the corresponding piece of .gcov file (rest of file removed for privacy):
source.c.gcov.txt (941 Bytes)
The branch annotations are visible in the .gcov file.
Additionally, when I generate a branch coverage report locally on my development machine using lcov, it reports 100% branches coverage.
Furthermore, from a logical standpoint, I don’t understand how the branches could not be taken whereas the lines contained in both branches are actually covered (see picture above).
Note that gcov is invoked with the -b option.
I am using SonarCFamily v6.11.0 on SonarQube Developer Edition v8.4.1 with sonar-scanner v4.4. The machine hosting the sonar-scanner is a Linux Ubuntu 18.04 (amd64).
Is there something I’m missing? Could a misconfiguration on my part lead to such a behaviour?
Regards,
Grégor