GCOV: A GNU Coverage Testing Tool

Download as pdf or txt
Download as pdf or txt
You are on page 1of 17

Applied Research Laboratories

The University of Texas at Austin

GCOV: A GNU Coverage


Testing Tool

Presentation by Eric Hagen


What is gcov? ARL
The University of Texas at Austin

♦ Gcov is a test coverage program


♦ Gcov is designed to work exclusively
with GCC to analyze programs to help
create more efficient, faster running
code
♦ Gcov can be used in concert with gprof,
an application which which assesses the
parts of code that take the greatest
amount of computing time

2
What can gcov do? ARL
The University of Texas at Austin

♦ With gcov and gprof one could


– Find how often each line of code
executes
– What lines of code are actually
executed
– How much computing time each section
of code uses

3
What can gcov do for us? ARL
The University of Texas at Austin

♦ Gcov can also be used with testsuites.


♦ A coverage program tests to see how
much of the program is exercised by the
testsuite
♦ With this information, developers can
determine which test cases need to be
added to the suite to ensure better
testing for a higher quality final
project

4
Gcov Options ARL
The University of Texas at Austin

♦ -h, --help
– Display help about using gcov
♦ -a, --all-blocks
– Write individual execution counts for
every basic block. With this option
you can determine if blocks within a
single line are not being executed
♦ -b, -branch-probabilities
– Write branch frequencies to the
output file, and write branch summary
info to the standard output. This
option allows you to see how often
each branch in your program was taken 5
Gcov Options ARL
The University of Texas at Austin

♦ -c, --branch-counts
– Write branch frequencies as the
number of branches taken, rather than
the percentage of branches taken
♦ -n, --no-output
– Do not create the gcov output file
♦ Within a gcov file the format is
<execution_count>:<line_number>:<source
line text>
♦ - is for lines containing no code
♦ ##### is for lines which were never
executed
6
Gcov an Example ARL
The University of Texas at Austin

7
Gcov : An Example ARL
The University of Texas at Austin

8
Gcov : An Example ARL
The University of Texas at Austin

9
Gcov: An Example ARL
The University of Texas at Austin

10
Gcov: An Example ARL
The University of Texas at Austin

11
Gcov and CppUnit ARL
The University of Texas at Austin

12
Gcov and CppUnit ARL
The University of Texas at Austin

13
ARL
The University of Texas at Austin

14
WhereSat Old Version ARL
The University of Texas at Austin

15
WhereSat New Version Without -v ARL
The University of Texas at Austin

16
WhereSat New Version with -v ARL
The University of Texas at Austin

17

You might also like