[Insight-developers] code coverage and memory leak scripts

Matt McCormick matt.mccormick at kitware.com
Mon Aug 8 14:49:12 EDT 2011


Hi all,

Some recently added scripts to the source tree may be useful in your
development adventures.

They are:

  ./Utilities/Maintenance/computeCodeCoverageLocallyForOneTest.sh
  ./Utilities/Maintenance/runValgrind.sh

They allow you to run code coverage or memory leak coverage on a
single test or a set of tests specified with a ctest regular
expression (-R).  The output is easily digested HTML.  Usage for these
scripts can be found by passing '--help'.

./Utilities/Maintenance/runValgrind.sh --help

  How to use this script:

0)  Use Linux or Mac, install
     - valgrind
     - xsltproc

1)  Compile ITK with RelWithDebInfo CMAKE_BUILD_TYPE

2)  cd into  the ITK binary build directory

3)  From the TOP of the binary directory type the "ctest" expression that
set(DOC  "
    selects the tests that you want to perform memory checking on.

For example:

    ctest  -R   itkHDF5ImageIOTest  -N

This will print the tests selected by the regular expression but not run the
tests (-N option).

4)  Type the path to this script in the ITK source tree and add the
select expression
    from step 3 above.

For example:

   ~/src/ITK/Utilities/Maintenance/runValgrind.sh          -R itkHDF5ImageIOTest

This will run the selected tests under valgrind and generate HTML that can be
opened with your favorite browser.  The HTML is written to ./memcheck_index.html
To open:

  In Linux, you can do      firefox  ./memcheck_index.html
  In Mac,   you can do      open     ./memcheck_index.html

These tools should augment the dashboard output, and help us reach our
goals of 84% or better test coverage, and zero memory leaks.

Happy hacking,
Matt


More information about the Insight-developers mailing list