I am doing a PoC for a internal development group showing how Sonar deals with C code coverage. I compile with the gcov flag and run gcovr to export to xml which is then picked up with the “sonar.cfamily.gcov.reportsPath=” flag.
For a test i run the executable e.g myexec --version which generates gcda files.
When I use gcovr to generate html the report shows 100% coverage for the file main.c (whose job is simply to call the another function. (in the lines column 100% and 2/2 with a green background)
However when I look at the coverage report in Sonar (based on the imported xml file from gcovr) it shows me that the line of code is not covered by tests with red next to it.
If I call the code shouldn’t it be a green line next to it ? Also do I need gocvr to create the xml couldn’t I just point “sonar.cfamily.gcov.reportsPath=” to where the gcda and gcno files are ?
cmd line is
sonar-scanner-18.104.22.1688/bin/sonar-scanner -X -Dsonar.scm.forceReloadAll=true -Dsonar.sources=/usr/local/src/ -Dsonar.language=c -Dsonar.cxx.coverage.reportPath=/usr/local/src/ -Dsonar.cxx.coverage.overallReportPath=/usr/local/src/gcovr.xml -Dsonar.cfamily.build-wrapper-output=/usr/local/src/son_out -Dsonar.projectKey=vcc-11.3
SonarQube version -
SonarQube Scanner 22.214.171.1248