-
Notifications
You must be signed in to change notification settings - Fork 9
Testing coverage
Chris Newman edited this page Aug 14, 2017
·
3 revisions
- To generate testing coverage, in a rather hackish way, edit the CmakeLists.txt file as follows:
#---------------------------------------------------------------------------------
# Hack for test coverage flags
#---------------------------------------------------------------------------------
SET(GCC_COVERAGE_COMPILE_FLAGS "-fprofile-arcs -ftest-coverage")
SET(GCC_COVERAGE_LINK_FLAGS "-lgcov -fprofile-arcs")
SET( CMAKE_C_FLAGS "${Trilinos_C_COMPILER_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET( CMAKE_CXX_FLAGS "${Trilinos_CXX_COMPILER_FLAGS} ${TUSAS_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}" )
SET(GCC_COVERAGE_LINK_FLAGS "${GCC_COVERAGE_LINK_FLAGS}")
#---------------------------------------------------------------------------------
# Change compiler flags. This must be done after PROJECT() specification
#---------------------------------------------------------------------------------
#SET( CMAKE_C_FLAGS ${Trilinos_C_COMPILER_FLAGS} )
#SET( CMAKE_CXX_FLAGS "${Trilinos_CXX_COMPILER_FLAGS} ${TUSAS_CXX_FLAGS}" )
And configure and make in the usual way.
- Run the tests:
pn1512687:~/work/tusas_git/Test$ ctest
- Run the coverage tool:
pn1512687:~/work/tusas_git$ lcov -b . -c -d ./CMakeFiles/tusas.dir -o coverage.run
- Filter the coverage tool:
pn1512687:~/work/tusas_git$ lcov -e coverage.run /Users/cnewman/work/tusas_git/basis/* /Users/cnewman/work/tusas_git/error_estimator/* /Users/cnewman/work/tusas_git/input/* \ > /Users/cnewman/work/tusas_git/mesh/* /Users/cnewman/work/tusas_git/periodic_bc/* /Users/cnewman/work/tusas_git/post_process/* \ > /Users/cnewman/work/tusas_git/preconditioner/include/preconditioner_def.hpp \ > /Users/cnewman/work/tusas_git/timestep/include/ModelEvaluatorNEMESIS_def.hpp \ > /Users/cnewman/work/tusas_git/timestep/include/function_def.hpp \ > -o coverage.run.basis
- Generate the report:
pn1512687:~/work/tusas_git$ genhtml -o ./html/ coverage.run.basis
- Report lives at:
file:///Users/cnewman/work/tusas_git/html/index.html
Some helpful information was found at:
http://swarminglogic.com/jotting/2014_05_lcov