Unable to get coverage data in SonarQube Community Version 8.9.9

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube – Community Version 8.9.9
    Sonar-scanner – 4.7.0.2747

  • how is SonarQube deployed: zip, Docker, Helm
    zip

  • what are you trying to achieve
    Display coverage data using gcovr

  • what have you tried so far to achieve this
    To achieve this I did:
    make build (-ftest-coverage option used with gcc)
    ./main
    gcovr -k a.c

*.gcov file is present in current directory

In sonar-project-properties specified

sonar.cfamily.gcov.reportsPath=.

sonar-scanner — SonarQube shows 0% coverage

Do not share screenshots of logs – share the text itself (bonus points for being well-formatted)!

Why coverage data is not getting displayed in sonarqube? What am I missing?

adding some more information: I am using code from GitHub - shenxianpeng/gcov-example: Use Gcov + LCOV/gcovr to show C/C++ projects code coverage results to test coverage in sonarqube.
3 *.gcno, *.gcda and *.gcov files are present in the dir. Used “gcovr -k” option to generate *.gcda files

Can anyone please look into my issue?

Hello @laxmij,

You mention gcov files, but the gcovr report tool. I guess you mean gcov -k a.c? If so, our example for gcov may help.

From what I can see, you may be missing the GCC flag -fprofile-abs-path, and the --preserve-paths gcov flag. Without them, the gcov files contain only the file name, while the analyzer needs to know their path.

Thanks for the response!
From where should I download build-wrapper-linux-x86-64?

From your instance of SonarQube.

  • Download Build Wrapper for Linux from {SonarQube URL}/static/cpp/build-wrapper-linux-x86.zip
  • Download Build Wrapper for macOS from {SonarQube URL}/static/cpp/build-wrapper-macosx-x86.zip
  • Download Build Wrapper for Windows from {SonarQube URL}/static/cpp/build-wrapper-win-x86.zip

I get error as HTTP status 404 page not found when trying to download build-wrapper-linux-x86.zip

will it be possible for you to download build-wrapper-linux-x86.zip and provide that to me? I tried yesterday also, same error message. For this reason only I wanted to know if I am not accessing correct webpage

I got build-wrapper-linux-x86.zip.

I used -fprofile-abs-path in gcc and --preserve-paths in gcov (followed the example https://github.com/sonarsource-cfamily-examples/linux-autotools-gcov-travis-sc/blob/main/.travis.yml)

I am using Community Edition 8.9.9 which doesn’t support c++. So I have to add

sonar.language=c++
sonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h

My coverage report is like

Coverage LINES TO COVER
Overview
On new code
Lines to cover 0
Uncovered Lines 0
Conditions to cover 0
Uncovered Condition 0
Overall
Coverage 0.0%
Lines to Cover 11
Uncovered Lines 11
Lines Coverage 0.0%

If I remove these 2 lines from sonar-project.properties,
sonar.language=c++
sonar.cxx.file.suffixes=.cxx,.cpp,.cc,.c,.hxx,.hpp,.hh,.h

Sonarqube shows “The main branch has no lines of code.”

sonar-project.properties of GitHub - sonarsource-cfamily-examples/linux-autotools-gcov-travis-sc: An example C++ repository built with CMake on Linux using GitHub Actions and analyzed on SonarCloud (test coverage by gcov) example doesn’t have “sonar.language=c==”

To me, it means this example is NOT meant for community edition.

Please confirm.

Best Regards
Laxmi

Sorry, I missed you were using the Community Edition. Indeed not, the example I provided is either for SonarQube Developer Edition and higher or SonarCloud (which is free for Open Source).

You can however check this other example that uses gcovr --sonarqube. Using the output of gcovr does not rely on having any particular plugin.

Thanks! I can see overall coverage after using coverage.xml.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.