How to get real code coverage with vsinstr / vsperfmon
my Microsoft based IDE looks like this: - huge native C ++ code split into 10 projects - each project has a dependent test project (GoogleTest unit tests), the sources for testing are just referenced.
I generated a coverage report using vsinstr and vsperfmon (visual studio tools for tooling / monitoring executables and DLLs), but that was not as satisfying as I expected because the report only shows unit-test line coverage, not from tested sources (I measured testuite-executable Sample_Project_Test.exe).
For example, if I have a method like this:
(Sample_Project/add_ints.cpp)
int add(int a, int b){
return a+b;
}
int add2(int a, int b){
if (a == b)
return a * 2;
else
return a+b;
}
and the unit test looks like this:
(Sample_Project_Test/int_adds_tests.cpp)
TEST(AddTest, ReturnsCorrectSum)
{
EXPECT_EQ(4, add(2,2));
}
I am getting 100% line coverage because only the added part in add_ints.cpp is measured, add 2 seems to be completely removed because it is not touched. As far as I misunderstood the whole coverage problem, does it seem wrong?
source to share
Do you have optimization enabled in your build settings?
Maybe these links will help you:
/ GL (Whole Program Optimization) and / LTCG (Link-time Code Generation)
source to share