Commit f108699e authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Added scripts to generate coverage reports with clang

parent cd12eadf
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@
/Documentation/html/
/CMakeLists.txt.user
/Build
/coverage_report

# Eclipse project stuff
/.settings
+5 −2
Original line number Diff line number Diff line
@@ -22,6 +22,7 @@ WITH_CUDA_ARCH="auto"
WITH_OPENMP="yes"
WITH_GMP="no"
WITH_TESTS="yes"
RUN_TESTS="yes"   # whether to run tests if they were compiled (coverage script sets it to no)
WITH_PROFILING="no"
WITH_COVERAGE="no"
WITH_DOC="yes"
@@ -52,6 +53,7 @@ do
        --with-openmp=*                  ) WITH_OPENMP="${option#*=}" ;;
        --with-gmp=*                     ) WITH_GMP="${option#*=}" ;;
        --with-tests=*                   ) WITH_TESTS="${option#*=}" ;;
        --run-tests=*                    ) RUN_TESTS="${option#*=}" ;;
        --with-profiling=*               ) WITH_PROFILING="${option#*=}" ;;
        --with-coverage=*                ) WITH_COVERAGE="${option#*=}" ;;
        --with-doc=*                     ) WITH_DOC="${option#*=}" ;;
@@ -79,7 +81,8 @@ if [[ ${HELP} == "yes" ]]; then
    echo "   --with-cuda-arch=all/auto/30/35/...   Chooses CUDA architecture. 'auto' by default."
    echo "   --with-openmp=yes/no                  Enables OpenMP. 'yes' by default."
    echo "   --with-gmp=yes/no                     Enables the wrapper for GNU Multiple Precision Arithmetic Library. 'no' by default."
    echo "   --with-tests=yes/no                   Enables unit tests. 'yes' by default."
    echo "   --with-tests=yes/no                   Enables compilation of unit tests. 'yes' by default."
    echo "   --run-tests=yes/no                    Runs unit tests if they were compiled. 'yes' by default."
    echo "   --with-profiling=yes/no               Enables code profiling compiler falgs. 'no' by default."
    echo "   --with-coverage=yes/no                Enables code coverage reports for unit tests. 'no' by default (lcov is required)."
    echo "   --with-doc=yes/no                     Build documentation. 'yes' by default."
@@ -226,6 +229,6 @@ if [[ ${WITH_DOC} == "yes" ]]; then
   "$ROOT_DIR/Documentation/build" --prefix="$PREFIX"
fi

if [[ ${WITH_TESTS} == "yes" ]]; then
if [[ ${WITH_TESTS} == "yes" ]] && [[ ${RUN_TESTS} == "yes" ]]; then
   CTEST_OUTPUT_ON_FAILURE=1 $make test
fi
+24 −17
Original line number Diff line number Diff line
@@ -5,6 +5,7 @@ if ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )
   message( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" )
endif ( NOT CMAKE_BUILD_TYPE STREQUAL "Debug" )

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
   if ( NOT DEFINED CODECOV_OUTPUTFILE )
       set( CODECOV_OUTPUTFILE cmake_coverage.output )
   endif ( NOT DEFINED CODECOV_OUTPUTFILE )
@@ -13,13 +14,19 @@ if ( NOT DEFINED CODECOV_HTMLOUTPUTDIR )
       set( CODECOV_HTMLOUTPUTDIR coverage_results )
   endif ( NOT DEFINED CODECOV_HTMLOUTPUTDIR )

if ( CMAKE_COMPILER_IS_GNUCXX )
   find_program( CODECOV_GCOV gcov )
   find_program( CODECOV_LCOV lcov )
   find_program( CODECOV_GENHTML genhtml )
    add_definitions( -fprofile-arcs -ftest-coverage )
   add_compile_options( -fprofile-arcs -ftest-coverage )
   link_libraries( gcov )
   set( CMAKE_EXE_LINKER_FLAGS ${CMAKE_EXE_LINKER_FLAGS} --coverage )
   add_custom_target( coverage_init ALL ${CODECOV_LCOV} --base-directory .  --directory ${CMAKE_SOURCE_DIR} --no-external --output-file ${CODECOV_OUTPUTFILE} --capture --initial --quiet )
   add_custom_target( coverage ${CODECOV_LCOV} --base-directory .  --directory ${CMAKE_SOURCE_DIR} --no-external --output-file ${CODECOV_OUTPUTFILE} --capture --quiet COMMAND genhtml --quiet -o ${CODECOV_HTMLOUTPUTDIR} ${CODECOV_OUTPUTFILE} )
endif ( CMAKE_COMPILER_IS_GNUCXX )
elseif(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
   # http://clang.llvm.org/docs/SourceBasedCodeCoverage.html
   add_compile_options( -fprofile-instr-generate -fcoverage-mapping )
   add_link_options( -fprofile-instr-generate -fcoverage-mapping )
   if( ${WITH_CUDA} )
      set(CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS} ; -Xcompiler -fprofile-instr-generate ; -Xcompiler -fcoverage-mapping )
   endif()
endif()
+567 −0

File added.

Preview size limit exceeded, changes collapsed.

+711 −0

File added.

Preview size limit exceeded, changes collapsed.

Loading