Skip to content

Commit

Permalink
Enable C++ coverage (apache#12642)
Browse files Browse the repository at this point in the history
* Enable C++ coverage for make

* Enable C++ test coverage for CMake

* Add environment variable GCOV_PREFIX

* Stash GCNO files

* Enable test coverage for Scala

* Fix -P not found error

* Remove debug comments

* Add linking with coverage

* Trigger separate build

* Add ignored files
  • Loading branch information
marcoabreu authored Sep 24, 2018
1 parent c93c78e commit ccba621
Show file tree
Hide file tree
Showing 7 changed files with 125 additions and 62 deletions.
4 changes: 4 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ parsers:
method: no
macro: no

ignore:
- "cpp-package/example/**/*"
- "tests/**/*"

# Disable comments for now to gather data in the background
comment: false
# layout: "header, diff"
Expand Down
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -169,4 +169,11 @@ tests/mxnet_unit_tests

# generated wrappers for ccache
cc
cxx
cxx

# Code coverage related
.coverage
*.gcov
*.gcno
coverage.xml

15 changes: 15 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ mxnet_option(INSTALL_EXAMPLES "Install the example source files." OFF)
mxnet_option(USE_SIGNAL_HANDLER "Print stack traces on segfaults." OFF)
mxnet_option(USE_TENSORRT "Enable infeference optimization with TensorRT." OFF)
mxnet_option(USE_ASAN "Enable Clang/GCC ASAN sanitizers." OFF)
mxnet_option(ENABLE_TESTCOVERAGE "Enable compilation with test coverage metric output" OFF)

message(STATUS "CMAKE_SYSTEM_NAME ${CMAKE_SYSTEM_NAME}")
if(USE_CUDA AND NOT USE_OLDCMAKECUDA)
Expand Down Expand Up @@ -218,6 +219,20 @@ if(USE_TENSORRT)
${ONNX_PROTO_LIBRARY} ${ONNX_LIBRARY} ${PROTOBUF_LIBRARY})
endif()

if(ENABLE_TESTCOVERAGE)
message(STATUS "Compiling with test coverage support enabled. This will result in additional files being written to your source directory!")
find_program( GCOV_PATH gcov )
if(NOT GCOV_PATH)
message(FATAL_ERROR "gcov not found! Aborting...")
endif() # NOT GCOV_PATH

set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --coverage")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage")
set(CMAKE_LINKER_FLAGS "${CMAKE_LINKER_FLAGS} --coverage")
set(GTEST_LIBRARIES "${GTEST_LIBRARIES} --coverage")
link_libraries(gcov)
endif()

if(USE_MKLDNN)
include(cmake/MklDnn.cmake)
# CPU architecture (e.g., C5) can't run on another architecture (e.g., g3).
Expand Down
Loading

0 comments on commit ccba621

Please sign in to comment.