Difference between revisions of "NA-MIC-kit-curriculum/Testing-Based Programming/How to run Code Coverage"

From NAMIC Wiki
Jump to: navigation, search
(Created page with '= Introduction = == Overview == This tutorial shows how to run Code Coverage in your project. Code coverage is a mechanism for counting the number of lines of code that are ex…')
 
Line 23: Line 23:
 
   cd ${BINARY_DIR}
 
   cd ${BINARY_DIR}
 
   make edit_cache
 
   make edit_cache
 
+
then search for the variable  
+
== Enable Debug ==
 +
 +
Then search for the variable  
  
 
   CMAKE_BUILD_TYPE
 
   CMAKE_BUILD_TYPE
  
 
and set it to the word "'''Debug'''"
 
and set it to the word "'''Debug'''"
 +
 +
 +
== Set Coverage Options ==
 +
 +
# Pass to the advanced mode by hitting the "t" key
 +
# Hit the "/" key in order to start a search
 +
# Type CXX_FLAGS
 +
# Hit the ENTER key to start editing the flags
 +
# add the following test: -g -O0 -fprofile-arcs -ftest-coverage
 +
# Hit the "/" key in order to start a search
 +
# Type C_FLAGS
 +
# Hit the ENTER key to start editing the flags
 +
# add the following test: -g -O0 -fprofile-arcs -ftest-coverage

Revision as of 14:54, 12 December 2009

Home < NA-MIC-kit-curriculum < Testing-Based Programming < How to run Code Coverage

Introduction

Overview

This tutorial shows how to run Code Coverage in your project.

Code coverage is a mechanism for counting the number of lines of code that are exercised during the execution of your tests.

Prerequisite

You should read first the tutorial:

You should also have installed the package

 gcov

this is usually installed along with your gcc package

Configuring the Test

In the project that you built in the previous tutorial, do

 cd ${BINARY_DIR}
 make edit_cache

Enable Debug

Then search for the variable

 CMAKE_BUILD_TYPE

and set it to the word "Debug"


Set Coverage Options

  1. Pass to the advanced mode by hitting the "t" key
  2. Hit the "/" key in order to start a search
  3. Type CXX_FLAGS
  4. Hit the ENTER key to start editing the flags
  5. add the following test: -g -O0 -fprofile-arcs -ftest-coverage
  6. Hit the "/" key in order to start a search
  7. Type C_FLAGS
  8. Hit the ENTER key to start editing the flags
  9. add the following test: -g -O0 -fprofile-arcs -ftest-coverage