Questions tagged [gcovr]
114 questions
1
vote
1 answer
gcov coverage limited to test files
I have the following CMakeLists.txt file:
cmake_minimum_required(VERSION 3.16)
project(first_coverage)
set(CXX_STANDARD 20)
set(CXX_STANDARD_REQUIRED True)
set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_EXPORT_COMPILE_COMMANDS…

LeonTheProfessional
- 334
- 5
- 14
1
vote
3 answers
xslt: remove attribute when parent node has an attribute matching a pattern (filter out branch coverage on sonar for files mathcing a pattern)
I am producing coverage reports using gcovr for import into sonar.
This use this format (https://docs.sonarqube.org/latest/analysis/generic-test/):
…

Bruce Adams
- 4,953
- 4
- 48
- 111
1
vote
1 answer
gcovr not showing code coverage for untouched header files
I have the following structure for a header only library
include
- header1.h
- header2.h
- header3.h
test
- test1.cpp
Now test1.cpp only uses header1.h, so when I compile test1.cpp with --coverage option, run the test, and then run gcovr to…

Vaibhav Thakkar
- 69
- 1
- 9
1
vote
1 answer
Unable to find GCC Code coverage libgcov.so for arm toolchain
Steps to Reproduce the issue
#include
int main(){
std::cout << "Hello World" << std::endl;
}
Write main.cpp
Download Toolchain from this link
Compile with below commands.
.…

Thomas Easo
- 3,457
- 3
- 21
- 32
1
vote
1 answer
I need some support for gcovr and cobertura
I am trying to create a pdf file which shows coverage of my unit tests. And same I need to push to Jenkins.
Steps:
I clone the repo.
Make the Env and Build it locally.
Run Batchfile for unit tests.
AND
When I run gcov in my local PC, I get…

Prawin
- 59
- 5
1
vote
2 answers
gcovr/SonarQube saying simple C++ function is only half covered
We are running gcovr on our codebase which is (FTR) then fed into SonarQube (cxx-plugin). There are many places where there is a report of less than 100% coverage, even though there are no obvious branches so it should be surely 0 or 100%. Take for…

johnfo
- 1,676
- 2
- 17
- 28
1
vote
1 answer
How to improve the branch coverage using gcovr tool
I have written a sample program using C++. I have written corresponding unit tests using GUNIT framework. I was successfully able to generate.gcda and .gcno files for every source file. I used (gcov -b -l -p -c *.gcno) command in the folder where…

Santosh Appachu
- 11
- 3
1
vote
0 answers
Parsing lcov total.info
I'm parsing the total.info file which is the result of running a few lcov commands on my source code in order to build a service that provides coverage information when needed.
lcov also provides a nice html ui to browse code coverage.
The problem…

Nader Kahwaji
- 137
- 9
1
vote
2 answers
How to obtain 100% branch coverage with gcovr with `if / else if / else`
I'm using gcovr for the first time and have hit a confusing issue with this code:
for (int i = 0; i < 4; i++)
{
bool a = i & 1;
bool b = i & 2;
if (a && b)
printf("a and b\n");
else if (a && !b)
…

Edd Inglis
- 1,067
- 10
- 22
1
vote
1 answer
How to get 100% coverage with gcovr with ifdef code?
I like working with gcovr on my Linux box to understand what is tested and what I have not.
I have fallen into a pit where I cannot see the solution.
I have C-code like shown just below (save as main.c). The code is made super simple - and the…

Peter Toft
- 565
- 7
- 19
1
vote
1 answer
setup gcovr with cmake-How can I Get Code coverage recursively on all static libraries
I have setup gcovr to get code coverage on my c++ project which is quite complex in terms of hierarchy of nested static libraries.
One approach I tried was to include required compile options (-fprofile-instr-generate -fcoverage-mapping -fPIC…

vkg
- 685
- 1
- 8
- 21
1
vote
1 answer
How to avoid that gcc generates extra code after compiling?
I am trying to get code coverage using ´gcovr´. I am using -O0 as optimization level. For line coverage, I get the results I need, but for branch coverage unfortunately not. According to the following answer, gcc generates extra code while…

Arturo Gonzalez
- 335
- 3
- 19
1
vote
1 answer
Unable to generate code coverage and also .gcda deleted from sub directories after running gcovr command
I am facing following issues with Code coverage:
The detailed html files are not generated for .cpp files which
have .gcno and .gcda counterparts.
gcda files automatically got deleted after running gcovr command.
I followed following steps…

MARCOS
- 21
- 1
- 7
1
vote
1 answer
How do I correctly handle output directories for GCC test coverage profiling?
I am trying to generate coverage data for my unit tests, with the ultimate goal of displaying said data as part of our automated build output.
We build using makefiles and cs-make, with cxxtest as the unit test framework. The autogenerated test…

jfowkes
- 1,495
- 9
- 17
1
vote
0 answers
Unit Testing Code which contains Linux system calls
I am new to unit testing in C++. I am using googletest for performing unit testing(and gcovr for coverage report) of the sources which contains linux system calls. To test them I thought of 2 approaches
1. Using **LD_PRELOAD (by stubbing own…

PrvnSrv
- 11
- 2