laxmij
(Laxmi Jain)
May 1, 2023, 10:52am
1
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)!
laxmij
(Laxmi Jain)
May 1, 2023, 10:54am
2
Why coverage data is not getting displayed in sonarqube? What am I missing?
laxmij
(Laxmi Jain)
May 2, 2023, 4:46am
3
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
laxmij
(Laxmi Jain)
May 3, 2023, 7:41am
4
Can anyone please look into my issue?
aalvarez
(Alejandro Álvarez Ayllón)
May 4, 2023, 9:22am
5
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.
laxmij
(Laxmi Jain)
May 4, 2023, 11:38am
6
Thanks for the response!
From where should I download build-wrapper-linux-x86-64?
aalvarez
(Alejandro Álvarez Ayllón)
May 4, 2023, 12:11pm
7
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
laxmij
(Laxmi Jain)
May 4, 2023, 1:30pm
9
I get error as HTTP status 404 page not found when trying to download build-wrapper-linux-x86.zip
laxmij
(Laxmi Jain)
May 4, 2023, 1:32pm
10
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
laxmij
(Laxmi Jain)
May 4, 2023, 1:40pm
11
I got build-wrapper-linux-x86.zip.
laxmij
(Laxmi Jain)
May 9, 2023, 10:52am
12
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
aalvarez
(Alejandro Álvarez Ayllón)
May 9, 2023, 1:18pm
13
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 .
laxmij
(Laxmi Jain)
May 10, 2023, 7:26am
14
Thanks! I can see overall coverage after using coverage.xml.
system
(system)
Closed
May 22, 2023, 7:27am
16
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.