From 2422273f0abf1bcee0e746a3b4bb2b4184c8c4ba Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Thu, 17 Oct 2013 10:47:36 +0000 Subject: [PATCH] Add Coverage support git-svn-id: https://svn.dealii.org/branches/branch_port_the_testsuite@31279 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/cmake/scripts/run_testsuite.cmake | 32 ++++++++++++++++++++ deal.II/cmake/setup_cached_variables.cmake | 7 +++++ deal.II/cmake/setup_compiler_flags_gnu.cmake | 9 ++++++ deal.II/doc/users/Config.sample | 4 +++ deal.II/doc/users/cmake.html | 5 +++ 5 files changed, 57 insertions(+) diff --git a/deal.II/cmake/scripts/run_testsuite.cmake b/deal.II/cmake/scripts/run_testsuite.cmake index 6e496b0b55..d9ab676ae2 100644 --- a/deal.II/cmake/scripts/run_testsuite.cmake +++ b/deal.II/cmake/scripts/run_testsuite.cmake @@ -77,6 +77,11 @@ # # cmake -C ${CONFIG_FILE}). This only has an effect if # CTEST_BINARY_DIRECTORY is empty. # +# COVERAGE +# - If set to TRUE deal.II will be configured with +# DEAL_II_SETUP_COVERAGE=TRUE and the CTEST_COVERAGE() stage will +# be run. Test results must go into the "Experimental" section +# # Furthermore, the following variables controlling the testsuite can be set # and will be automatically handed down to cmake: # @@ -254,6 +259,11 @@ FOREACH(_var ${_variables}) ENDIF() ENDFOREACH() +IF(COVERAGE) + LIST(APPEND _options "-DDEAL_II_SETUP_COVERAGE=TRUE") + LIST(APPEND _options "-DCMAKE_BUILD_TYPE=Debug") +ENDIF() + # # CTEST_BUILD_NAME: # @@ -371,6 +381,23 @@ SET(CTEST_NOTES_FILES ${CTEST_BINARY_DIRECTORY}/include/deal.II/base/config.h ) +# +# Setup coverage: +# +IF(COVERAGE) + FIND_PROGRAM(GCOV_COMMAND NAMES gcov) + + IF(GCOV_COMMAND MATCHES "-NOTFOUND") + MESSAGE(FATAL_ERROR " +TRACK was set to \"Build Tests\" which requires the source directory to be +under Subversion version control. +" + ) + ENDIF() + + SET(CTEST_COVERAGE_COMMAND "${GCOV_COMMAND}") +ENDIF() + ######################################################################## # # @@ -406,6 +433,11 @@ IF("${_res}" STREQUAL "0") ENDIF() CTEST_TEST() + + IF(COVERAGE) + CTEST_COVERAGE() + ENDIF(COVERAGE) + ENDIF() ENDIF() diff --git a/deal.II/cmake/setup_cached_variables.cmake b/deal.II/cmake/setup_cached_variables.cmake index c2e04fe20d..8d476fb437 100644 --- a/deal.II/cmake/setup_cached_variables.cmake +++ b/deal.II/cmake/setup_cached_variables.cmake @@ -35,6 +35,7 @@ # CMAKE_BUILD_TYPE # DEAL_II_ALLOW_PLATFORM_INTROSPECTION # DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS +# DEAL_II_SETUP_COVERAGE # BUILD_SHARED_LIBS # DEAL_II_PREFER_STATIC_LIBS # DEAL_II_STATIC_EXECUTABLE @@ -152,6 +153,12 @@ OPTION(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS ) MARK_AS_ADVANCED(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS) +OPTION(DEAL_II_SETUP_COVERAGE + "Setup debug compiler flags to provide additional test coverage information. Currently only gprof is supported." + OFF + ) +MARK_AS_ADVANCED(DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS) + SET(BUILD_SHARED_LIBS "ON" CACHE BOOL "Build a shared library" ) diff --git a/deal.II/cmake/setup_compiler_flags_gnu.cmake b/deal.II/cmake/setup_compiler_flags_gnu.cmake index 14884e265d..16dc992969 100644 --- a/deal.II/cmake/setup_compiler_flags_gnu.cmake +++ b/deal.II/cmake/setup_compiler_flags_gnu.cmake @@ -167,5 +167,14 @@ IF (CMAKE_BUILD_TYPE MATCHES "Debug") ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-g") ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS_DEBUG "-g") ENDIF() + + IF(DEAL_II_SETUP_COVERAGE) + # + # Enable test coverage + # + ENABLE_IF_SUPPORTED(DEAL_II_CXX_FLAGS_DEBUG "-ftest-coverage -fprofile-arcs") + ENABLE_IF_SUPPORTED(DEAL_II_LINKER_FLAGS_DEBUG "-ftest-coverage -fprofile-arcs") + ENDIF() + ENDIF() diff --git a/deal.II/doc/users/Config.sample b/deal.II/doc/users/Config.sample index 7b4500bf2f..06b915700b 100644 --- a/deal.II/doc/users/Config.sample +++ b/deal.II/doc/users/Config.sample @@ -75,6 +75,10 @@ # "Configure sensible default CFLAGS and CXXFLAGS depending on platform, compiler and build target." # ) # +# SET(DEAL_II_SETUP_COVERAGE OFF CACHE BOOL +# "Setup debug compiler flags to provide additional test coverage information. Currently only gprof is supported." +# ) +# # SET(CMAKE_CXX_COMPILER "" CACHE STRING # "CXX Compiler." # ) diff --git a/deal.II/doc/users/cmake.html b/deal.II/doc/users/cmake.html index 37fce5e748..c4df8f5d04 100644 --- a/deal.II/doc/users/cmake.html +++ b/deal.II/doc/users/cmake.html @@ -918,6 +918,11 @@ DEAL_II_SETUP_DEFAULT_COMPILER_FLAGS to OFF. Beware of the fact that certain features may still pull in necessary compiler flags. + +
  • + You can setup additional debug compiler flags to provide test + coverage information by setting + DEAL_II_SETUP_COVERAGE to ON.

    -- 2.39.5