diff options
author | Sridhar Periyasamy <sridhper@microsoft.com> | 2015-09-03 16:38:54 -0700 |
---|---|---|
committer | Sridhar Periyasamy <sridhper@microsoft.com> | 2015-09-04 11:19:21 -0700 |
commit | 38f82df88a37fa4f47bd1b01b0faad9970b00476 (patch) | |
tree | 547062129ee02cd3b35e3173113461d39684615e /CMakeLists.txt | |
parent | 1165038551b7ca20f230d867dc5fd2357ede14fe (diff) | |
download | coreclr-38f82df88a37fa4f47bd1b01b0faad9970b00476.tar.gz coreclr-38f82df88a37fa4f47bd1b01b0faad9970b00476.tar.bz2 coreclr-38f82df88a37fa4f47bd1b01b0faad9970b00476.zip |
Build Code Coverage instrumented binaries for native bianries in Linux and OSX.
Add an option in build.sh called 'coverage' to produce gcov-style instrumented builds.
Example usage - ./build.sh debug coverage clean
This will generate the '.gcno' notes files for each object file in the same directory along with the instrumented native binaries. These .gcno files contain some of the coverage data like source line mappings, basic block graphs info etc.
Each time these instrumented binaries are run, a separate .gcda file is created for each object file in the same directory. These .gcda files contain arc transition counts, and some summary information.
Code Coverage reports can be generated from the .gcno and .gcda files using a tool like gcovr or lcov. *But this commit is only for generated the .gcno files while compiling with the 'coverage' option.*
The next steps
- Add option in run-test.sh to generate code-coverage reports using the instrumented native binaries.
- Integrate with Jenkins CI to do code-coverage runs.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index ffb761f18a..f5e1b19a52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -337,6 +337,26 @@ endif (WIN32) endif (OVERRIDE_CMAKE_CXX_FLAGS) +OPTION(CMAKE_ENABLE_CODE_COVERAGE "Enable code coverage" OFF) + +if(CMAKE_ENABLE_CODE_COVERAGE) + + string(TOUPPER ${CMAKE_BUILD_TYPE} UPPERCASE_CMAKE_BUILD_TYPE) + if(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) + message( WARNING "Code coverage results with an optimised (non-Debug) build may be misleading" ) + endif(NOT UPPERCASE_CMAKE_BUILD_TYPE STREQUAL DEBUG) + + if(CLR_CMAKE_PLATFORM_UNIX) + add_definitions(-fprofile-arcs -ftest-coverage -fPIC) + set(CLANG_COVERAGE_LINK_FLAGS "--coverage") + set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${CLANG_COVERAGE_LINK_FLAGS}") + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CLANG_COVERAGE_LINK_FLAGS}") + else() + message(WARNING "Code coverage builds not supported on current platform") + endif(CLR_CMAKE_PLATFORM_UNIX) + +endif(CMAKE_ENABLE_CODE_COVERAGE) + if(CLR_CMAKE_PLATFORM_UNIX) add_definitions(-DDISABLE_CONTRACTS) # The -ferror-limit is helpful during the porting, it makes sure the compiler doesn't stop |