Importing coverage for a mixed C/C++ project


(Eliezer Ramm) #1

I have a requirement to provide coverage reports via SonarQube for a project that has mostly C code but some C++ code as well Since the tests run in a distributed environment and there is no way to merge the .gcov files afterwards and use the CFammily plugin thus I am taking a lcov .info file and converting it to cobertura XML (there is a python module that does this) and importing it using the CXX plugin

My question is how independent is the coverage report from the code is that is actually scanned since most of the C code is skipped by the CXX plugin ?

Also is there no way to use a cobertura XML report with the CFamily (paid) plugin ?



(G Ann Campbell) #2


If you’ve got questions about the Cxx plugin, you should probably enter a GitHub Issue on the project. Regarding coverage with SonarCFamily, the docs indicate that you can import multiple .gcov reports. Does that meet your needs, or is there still something unanswered around file paths being different in the different environments where tests are run?


(Eliezer Ramm) #3

By way of example: when I run a test that accesses main.c that was built with coverage and has had gcov run on it after the tests I end up with 4 files main.c, main.gcno, main.gcda and main.c.gcov

main.c.gcov is a text file that shows the code coverage and how many times test accessed main.c

    -:    0:Graph:main.gcno
    -:    0:Data:main.gcda
    -:    0:Runs:2
    -:    0:Programs:1

my issue is that I have the source code on several machines that run tests against the same sources so I will have the above mentioned 4 files on 5 different machines.

SO my question how can the Cfamily plugin deal with this kind of setup ?

I don’t have a CXX question as there I can use cobertura XML and it would be a great workaround if I could use cobertura XML with the CFamily as well.

Hope I was more clear this time