How to Run Code Coverage Analysis
ICC
- Build the code as normal with the
-prof-gen=srcpos -prof-dir=PATH_TO_PROF_DIR/prof-info
compiler flag. WherePATH_TO_PROF_DIR
is the path to a directory that you have created to store the profiling information. - Run the test/simulation as normal and this should generate a
.dyn
file inprof-info
, which contains dynamic profile information. - Navigate to the
prof-info
directory. - Use the
profmerge
tool to merge all.dyn
files into one.dpi
file. This merges multiple.dyn
from successive runs of the application with different runtime parameters (e.g. runningtest27cells
with varying number of particles per cell):
profmerge -a
(Note: If you only want code coverage from the last test run remove old .dyn
files and the .dpi
file in the prof-info
directory. As old test runs might cover code that was not covered in the latest test run.)
- Run the code coverage tool:
codecov
This will generate an HTML
file called CODE_COVERAGE.HTML
, which contains the code coverage report and show how much of the application was actually executed, line by line.
- If you didn't specify the
-prof-dir
flag you can run the code coverage tool and specify the path to SWIFT library.spi
file instead:
codecov -spi swiftsim/src/pgopti.spi
(However this will not contain code coverage for the test source code itself.)
- A more detailed guide can be found at https://software.intel.com/en-us/node/522743
GCC
- Build the code as normal with
-Wall -fprofile-arcs -ftest-coverage
compiler flags. - Run the test/simulation as normal and this should generate a
.gcda
file, which contains dynamic profile information. - Run the
gcov
tool on the executable source file:
gcov test27cells.c
This will generate annotated versions of each original source file appended with .gcov
.
- Each
.gcov
file contains counts of the number of times each line was executed. Lines which were not executed are marked with hashes ‘######’. - A more detailed guide can be found at http://www.network-theory.co.uk/docs/gccintro/gccintro_81.html.