OCFS2 CODE COVERAGE ANALYSIS
This page documents the steps to perform code coverage analysis for OCFS2.
Introduction
GCOV, provided with GCC, allows one to generate and extract code coverage information for all user space apps. The LTP project provides a gcov-kernel patch that extends the same facility to the kernel code. It does so by providing a directory of virtual files (/proc/gcov) which are compatible with gcc's gcov tool (See manpage of gcov for more information).
Steps
- Untar a kernel tree in one of the shared/nfs volumes. (As the coverage tool uses the links to the source to generate the pretty html reports, we want the source to be accessible from all nodes in the cluster.)
Find the appropriate kernel-gcov patch for your kernel tree. The patches for kernels 2.6.22 and later can be found here. If you cannot find the patch for your kernel, try LTP's CVS repository.
$ cvs -d:pserver:anonymous@ltp.cvs.sourceforge.net:/cvsroot/ltp login
(Press Enter when prompted for the password.)
$ cvs -z3 -d:pserver:anonymous@ltp.cvs.sourceforge.net:/cvsroot/ltp co -P utils
(The patches are typically under the analysis directory.)
- Apply the patch to the kernel tree, set the CONFIG parameters as listed below and build the kernel.
Configuration options:
----------------------
CONFIG_GCOV_PROFILE=y
Basic gcov support. Say 'y' here.
CONFIG_GCOV_ALL=n
Say 'y' here if you want to get gcov data for the entire kernel. Otherwise
add the line
EXTRA_CFLAGS += $(GCOV_FLAGS)
to the respective Makefiles.
CONFIG_GCOV_PROC=y
Provide /proc/gcov. Say 'y' here.
CONFIG_GCOV_HAMMER=n
Say 'n' here unless you are using a modified gcc 3.3.x compiler (e.g. shipped
with SUSE SLES9 or Mandrake 10.x). Note: an incorrect setting of this option
may result in compile time errors or in file format errors in /proc/gcov.
If you've obtained the kernel-gcov patch from oss, the OCFS2 Makefiles should have the GCOV_FLAGS already set.
- Reboot the nodes with the new kernel.
- Once the OCFS2 modules are loaded, you will see directory entries under /proc/gcov/fs/ocfs2/.
- Reset the counters before starting the test.
$ lcov --zerocounters
- Run the tests.
After the tests are completed, collect the data on all nodes using lcov. (Install lcov if not already installed.)
$ lcov --capture --test-name TESTNAME --output-file OUTFILE
- Copy all the outputs above and generate an unified html report.
$ genhtml --css-file gcov.css --output-directory OUTDIR OUTFILE1 OUTFILE2 ...
- Label and save the output.