Question

I'm using Ubuntu 12, g++ and lcov, the latter installed with apt-get install lcov.

I'm successfully compiling, and generating html reports with genhtml. The line coverage information looks good, but many of the function coverage counts seem odd. For example, one C++ class containing just a constructor and virtual destructor is reported by lcov as having 7 functions. Therefore, my coverage is only 2/7 if I call both during the session.

Here is an example output which shows a class with one function that never gets called. I can't work out what that function is:

example output

Can anyone decode the mangled function name, explain the inflated function counts, and suggest how to go about resolving the problem?

Thanks in advance.

Update

OK, since answering my original question below (see comments), I am now inviting suggestions as to how I can prevent these under-the-hood ctors and dtors corrupting my function coverage statistics. How can I limit the function counts to those functions I've written myself?

Was it helpful?

Solution

I suppose you are on a new project by now, and at the time you may not have been using C++11, but if you do that now maybe this will help:

class my_class
{
    ...
    my_class(my_class const &) = delete;
    ...
};

This also means you have to have some form of declaration for all the possible default constructors that you do not want to have... Now if you are using the default constructors, then you probably need to enhance your tests because lcov is telling you that you are actually not testing them! Something of the sort should do:

my_class a;
my_class b(a);
my_class c;
c = b;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top