LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Problem with LCOV GCOV (https://www.linuxquestions.org/questions/programming-9/problem-with-lcov-gcov-750269/)

graemef 08-25-2009 11:43 PM

Problem with LCOV GCOV
 
I am getting code coverage statistics with for one of my small library's that I'm currently testing. However, I'm getting a few odd results, lines that I know are being covered are not being counted, Other lines are being missed, until I cover them.

For lines being covered but missed see lines 63, 83, 96 & 113

For lines being missed see line 342

My library of routines is written in C++ and uses many QT routines.

I have compiled with and without optimisation and of course I include the flags -fprofile-arcs -ftest-coverage when both compiling and linking.

my commands to lcov are as follows:
Code:

lcov -z -d object/ -q

# generate a blank coverage file
lcov -c -i  -d object/ -o lcov_tmp/qgetopt_base.info -q
lcov -e lcov_tmp/qgetopt_base.info "*optionManager/opt*" -o lcov_tmp/qgetopt_base.info -q
 
# Run the tests
cd object/
./test2
cd ../

# generate the coverage data from the unit tests

lcov -c -d object/ -o lcov_tmp/qgetopt_utest.info -t unitTests -q
lcov -e lcov_tmp/qgetopt_utest.info "*optionManager/opt*" -o lcov_tmp/qgetopt_utest.info -q
lcov -a lcov_tmp/qgetopt_base.info -a lcov_tmp/qgetopt_utest.info  -a lcov_tmp/qgetopt_test.info -o lcov_tmp/qgetopt_total_coverage.info -q

# Generate the html report from the tests

genhtml -o ./coverage lcov_tmp/qgetopt_total_coverage.info -t "qgetopt test coverage" -s

Note: The coverage details in lcov_tmp/qgetopt_test.info are generated by the test2 program itself

My question: Is this something that I have to live with or is there a work around?

graemef 08-26-2009 12:07 AM

Typical, five minutes after posting my question I find the answer... At least for the lines being covered but missed. It's due to optimisation of the implied copy constructor. If I compile with -fno-elide-constructors it works as hoped.

I think that the other problem is due to the inlining of the code and that I can live with.


All times are GMT -5. The time now is 05:20 AM.