Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCOV for multi-threaded apps

Is it possible to use gcov for coverage testing of multi-threaded applications?

I've set some trivial tests of our code-base up, but it would be nice to have some idea of the coverage we're achieving. If gcov isn't appropriate can anyone recommend an alternative tool (possible oprofile), ideally with some good documentation on getting started.

like image 719
Andrew Walker Avatar asked Sep 01 '08 11:09

Andrew Walker


People also ask

What is gcov used for?

Gcov is a source code coverage analysis and statement-by-statement profiling tool. Gcov generates exact counts of the number of times each statement in a program is executed and annotates source code to add instrumentation. Gcov comes as a standard utility with the GNU Compiler Collection (GCC) suite.

What is difference between gcov and LCOV?

gcov is a test coverage tool for the GCC (GNU Compiler Collection). lcov is a graphical front-end for gcov . “It collects gcov data for multiple source files and creates HTML pages containing the source code annotated with coverage information.”

How can you tell if an application is multi threaded?

In taskmanager, right-click the game process and set the affinity to one core. Play a little ingame and check your fps. Then change affinity to two cores, if your fps increases then the game is (properly) multithreaded.

What are some multi threaded applications?

Another example of a multithreaded program that we are all familiar with is a word processor. While you are typing, multiple threads are used to display your document, asynchronously check the spelling and grammar of your document, generate a PDF version of the document.


2 Answers

We've certainly used gcov to get coverage information on our multi-threaded application.

You want to compile with gcc 4.3 which can do coverage on dynamic code.

You compile with the -fprofile-arcs -ftest-coverage options, and the code will generate .gcda files which gcov can then process.

We do a separate build of our product, and collect coverage on that, running unit tests and regression tests.

Finally we use lcov to generate HTML results pages.

like image 164
Douglas Leeder Avatar answered Sep 28 '22 07:09

Douglas Leeder


Gcov works fine for multi-threaded apps. The instrumentation architecture is properly serialized so you will get coverage data of good fidelity.

I would suggest using gcov in conjunction with lcov. This will give you great reports scoped from full project down to individual source files.

lcov also gives you a nicely color coded HTML version of your source so you can quickly evaluate your coverage lapses.

like image 27
Jeremy Mayhew Avatar answered Sep 28 '22 07:09

Jeremy Mayhew