SPI Software Process & Infrastructure QA http://spi.cern.ch/qa - - PowerPoint PPT Presentation
SPI Software Process & Infrastructure QA http://spi.cern.ch/qa - - PowerPoint PPT Presentation
SPI Software Process & Infrastructure QA http://spi.cern.ch/qa Gcov presentation - 03 June 2005 Johanne BENARD johanne.benard@cern.ch GCOV presentation What is Gcov ? Code Analysis principle Coverage tool Other utilities
J.Benard SPI - Software Process & Infrastructure 2
GCOV presentation What is Gcov ?
- Code Analysis principle
- Coverage tool
- Other utilities
Application on ROOT
- Compilation
- Test running
- Result
J.Benard SPI - Software Process & Infrastructure 3
Code analysis principle
- Aim at showing what percentage of an application has
been executed by the test process.
- Two different principles in gcov:
Statement coverage analysis which breaks the code down into basic blocs. Then by construction, if a line is executed a given number of times, every instruction line within the basic block would have been executed the same number of times. Branch coverage analysis which rather than focusing on a basic blocks, will look at possible paths a conditional can take and how often each path through the conditional is taken. Then knowledge of how many times each line of code was executed can be derived by knowing how many times each conditional was evaluated for each possible outcome.
J.Benard SPI - Software Process & Infrastructure 4
Coverage tool
- Code instrumentation during compilation:
- GCC must be used to compile the program with the flags
- fprofile-arcs -ftest-coverage
- GCC generates two output files for each Sourcefile.c compiled:
- Sourcefile.bb: list of source files and functions within those files and
line numbers corresponding to basic blocks in the source file )
- Sourcefile.bbg: list of the program flow arcs for each function
- Data collection during code execution:
- Counter vector entries are incremented every time an
instrumented basic block is entered
J.Benard SPI - Software Process & Infrastructure 5
Coverage tool
- Data extraction at program exit time:
- Creates a file sourcefile.da and populates the file with the size of
the vector and the counters of the vector itself
- Coverage analysis and presentation:
- GCOV utility integrates and relates the information of the "*.bbg",
"*.bb" and the "*.da" to produce the "*.gcov" files containing per line coverage output
Runtime Compilation time
File.c File.bb File.bbg File.da
Coverage analysis
File.gcov
J.Benard SPI - Software Process & Infrastructure 6
Other utilities
- Genhtml:
- Creates an HTML view from coverage data found in INFOFILE
- Geninfo:
- Converts .da files into .info files
- Genpgn:
- Creates an overview image for a given source code file of either
plain text or .gcov file format
- Gendesc:
- Converts a test case description file into a format as understood
by genhtml INPUTFILE
J.Benard SPI - Software Process & Infrastructure 7
Application to ROOT
- Compilation:
- Edition of MyConfig.mk in $ROOTSYS
- Link the shared libraries with libgcc.a
- Test running:
- In $ROOTSYS/test
- In roottest
- Results:
J.Benard SPI - Software Process & Infrastructure 8
ROOT test coverage report
J.Benard SPI - Software Process & Infrastructure 9
ROOT test coverage report
J.Benard SPI - Software Process & Infrastructure 10
J.Benard SPI - Software Process & Infrastructure 11
More information
- Please visit our web site: http://spi.cern.ch/qa/gcov
- Proposed next actions:
- Publication of test coverage for ROOT
- at a given frequency?
- Addressed to a QA person?
- Run it on CVS tagged or HEAD source
- Add a section on SPI/QA web site dedicated to test coverage for
ROOT
- Produce automatically a list of files that have less than 80% test
coverage
J.Benard SPI - Software Process & Infrastructure 12