ITK/Dynamic Analysis Practices: Difference between revisions

From KitwarePublic
< ITK
Jump to navigationJump to search
 
(One intermediate revision by one other user not shown)
Line 6: Line 6:


= How to run Valgrind locally =
= How to run Valgrind locally =
  How to use this script:


== Step 1 ==
== Step 1 ==


* Use Linux or Mac
Use Linux or Mac, install
* valgrind
* xsltproc


== Step 2 ==
== Step 2 ==


* Compile ITK for Debug
Compile ITK with RelWithDebInfo CMAKE_BUILD_TYPE


== Step 3 ==
== Step 3 ==


cd into  the ITK binary build directory
cd into  the ITK binary build directory
 
== Step 4 ==


== Step 4 ==
From the TOP of the binary directory type the "ctest" expression that
selects the tests that you want to perform memory checking on.


* Type the "ctest" expression that select the test that you want to check with Valgrind.
For example:
* For example:


          ctest  -R  itkHDF5ImageIOTest   -V  -N
    ctest  -R  itkHDF5ImageIOTest -N


* This will print to the console the command line instructions needed to run the tests (-V option), but without running the tests (-N option).
This will print the tests selected by the regular expression but not run the
tests (-N option).


== Step 5 ==
== Step 5 ==


* Type the path to this script in the ITK source tree and then put in front of it the expression that you get from step (4)
Type the path to this script in the ITK source tree and add the select expression
* For example:
from step 4 above.
 
For example:
 
  ~/src/ITK/Utilities/Maintenance/runValgrind.sh          -R itkHDF5ImageIOTest


          ~/src/ITK/Utilities/Maintenance/runValgrind.sh    \
This will run the selected tests under valgrind and generate HTML that can be
                $HOME/bin/ITK/Debug/bin/ITK-IO-HDF5TestDriver \
opened with your favorite browser.  The HTML is written to ./memcheck_index.html
                "itkHDF5ImageIOTest"  \
To open:
                "$HOME/bin/ITK/Debug/Testing/Temporary"


* At this point, the test will be run under the control of Valgrind and the combined text output of both the test and the Valgrind analysis will be printed in the console. For convienience, the same output is being copied to a file in the /tmp directory. More precisely to:
In Linux, you can do
      firefox  ./memcheck_index.html


        /tmp/itkValgrindReport.txt
In Mac,  you can do
      open    ./memcheck_index.html

Latest revision as of 01:27, 11 February 2012

Overview

  • ITK has a policy of ZERO Valgrind errors.
  • The developers community has put a lot of effort in reaching this level of quality and it is up to all contributors to keep the dynamic errors to the zero level.

How to run Valgrind locally

 How to use this script:

Step 1

Use Linux or Mac, install

  • valgrind
  • xsltproc

Step 2

Compile ITK with RelWithDebInfo CMAKE_BUILD_TYPE

Step 3

cd into the ITK binary build directory

Step 4

From the TOP of the binary directory type the "ctest" expression that 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).

Step 5

Type the path to this script in the ITK source tree and add the select expression from step 4 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