Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 08-25-2009, 11:43 PM   #1
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Rep: Reputation: 148Reputation: 148
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:
lcov -z -d object/ -q

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

# generate the coverage data from the unit tests

lcov -c -d object/ -o lcov_tmp/ -t unitTests -q
lcov -e lcov_tmp/ "*optionManager/opt*" -o lcov_tmp/ -q
lcov -a lcov_tmp/ -a lcov_tmp/  -a lcov_tmp/ -o lcov_tmp/ -q

# Generate the html report from the tests

genhtml -o ./coverage lcov_tmp/ -t "qgetopt test coverage" -s
Note: The coverage details in lcov_tmp/ are generated by the test2 program itself

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

Last edited by graemef; 08-25-2009 at 11:47 PM. Reason: details about where lcov_tmp/ is generated
Old 08-26-2009, 12:07 AM   #2
Senior Member
Registered: Nov 2005
Location: Hanoi
Distribution: Fedora 13, Ubuntu 10.04
Posts: 2,379

Original Poster
Rep: Reputation: 148Reputation: 148
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] lcov problems graemef Programming 1 08-23-2009 01:02 AM
Sound Card problem(every time i install linux i have diffirent hardware problem) jacka1l Linux - Newbie 7 08-11-2005 06:10 AM
Lan configuration problem - NFS boot problem - RX&TX packets errors 242VDM242 Linux - Networking 4 11-25-2004 01:35 PM
perl problem? apache problem? cgi problem? WorldBuilder Linux - Software 1 09-17-2003 07:45 PM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:51 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration