From 3765da98c7312788461db5e5ac09b6a13bc69141 Mon Sep 17 00:00:00 2001 From: wanghuancoder Date: Thu, 3 Dec 2020 09:22:01 +0800 Subject: [PATCH] add coverage incremental switch, test=develop (#29290) --- CMakeLists.txt | 1 + cmake/coveralls.cmake | 8 ++++++-- cmake/generic.cmake | 2 +- paddle/scripts/paddle_build.sh | 2 ++ 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8322b7f378a..d0cff762e22 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -128,6 +128,7 @@ option(WITH_AMD_GPU "Compile PaddlePaddle with AMD GPU" OFF) option(WITH_NV_JETSON "Compile PaddlePaddle with NV JETSON" OFF) option(WITH_PROFILER "Compile PaddlePaddle with GPU profiler and gperftools" OFF) option(WITH_COVERAGE "Compile PaddlePaddle with code coverage" OFF) +option(WITH_INCREMENTAL_COVERAGE "Generate coverage reports only for incremental code" OFF) OPTION(WITH_LIBXSMM "Compile with libxsmm" OFF) option(COVERALLS_UPLOAD "Package code coverage data to coveralls" OFF) option(WITH_PSLIB "Compile with pslib support" OFF) diff --git a/cmake/coveralls.cmake b/cmake/coveralls.cmake index aad02d24be1..f7da3560f75 100644 --- a/cmake/coveralls.cmake +++ b/cmake/coveralls.cmake @@ -62,11 +62,15 @@ function(code_coverage _COVERAGE_SRCS _COVERALLS_UPLOAD _CMAKE_SCRIPT_PATH) endfunction() if(WITH_COVERAGE) - if (NOT ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "")) + if (WITH_INCREMENTAL_COVERAGE) + if (NOT ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "")) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") + endif() + else() set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -g -O0 -fprofile-arcs -ftest-coverage") endif() - set(EXCLUDE_DIRS "demo/" "build/" diff --git a/cmake/generic.cmake b/cmake/generic.cmake index d3fca7c66f2..9d0d9e7dc44 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -267,7 +267,7 @@ function(merge_static_libs TARGET_NAME) endfunction(merge_static_libs) function(check_coverage_opt TARGET_NAME SRCS) - if(WITH_COVERAGE) + if(WITH_COVERAGE AND WITH_INCREMENTAL_COVERAGE) if ("$ENV{PADDLE_GIT_DIFF_H_FILE}" STREQUAL "") if (NOT ("$ENV{PADDLE_GIT_DIFF_CC_FILE}" STREQUAL "")) string(REPLACE "," ";" CC_FILE_LIST $ENV{PADDLE_GIT_DIFF_CC_FILE}) diff --git a/paddle/scripts/paddle_build.sh b/paddle/scripts/paddle_build.sh index 35c9d581d9f..419e1722d95 100755 --- a/paddle/scripts/paddle_build.sh +++ b/paddle/scripts/paddle_build.sh @@ -232,6 +232,7 @@ function cmake_base() { -DCUDNN_ROOT=/usr/ -DWITH_TESTING=${WITH_TESTING:-ON} -DWITH_COVERAGE=${WITH_COVERAGE:-OFF} + -WITH_INCREMENTAL_COVERAGE=${WITH_INCREMENTAL_COVERAGE:-OFF} -DCMAKE_MODULE_PATH=/opt/rocm/hip/cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON @@ -266,6 +267,7 @@ EOF -DCUDNN_ROOT=/usr/ \ -DWITH_TESTING=${WITH_TESTING:-ON} \ -DWITH_COVERAGE=${WITH_COVERAGE:-OFF} \ + -WITH_INCREMENTAL_COVERAGE=${WITH_INCREMENTAL_COVERAGE:-OFF} \ -DCMAKE_MODULE_PATH=/opt/rocm/hip/cmake \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DWITH_CONTRIB=${WITH_CONTRIB:-ON} \ -- GitLab