Skip to content

Commit

Permalink
testing better coverage with travis and gcov
Browse files Browse the repository at this point in the history
  • Loading branch information
patflick committed Aug 2, 2016
1 parent ace91ce commit b39093c
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 9 deletions.
8 changes: 4 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ before_script:
# prepare build mxx
- mkdir build
- cd build
- if [ -z "$FAKEBIG" ]; then cmake -DENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -DMPI_C_COMPILER=$HOME/local/$MPI/bin/mpicc -DMPI_CXX_COMPILER=$HOME/local/$MPI/bin/mpicxx ../;
else cmake -DFAKE_BIG_MPI=ON -DENABLE_COVERAGE=ON -DCMAKE_BUILD_TYPE=Debug -DMPI_C_COMPILER=$HOME/local/$MPI/bin/mpicc -DMPI_CXX_COMPILER=$HOME/local/$MPI/bin/mpicxx ../; fi
- if [ -z "$FAKEBIG" ]; then cmake -DTRAVIS=ON -DCMAKE_BUILD_TYPE=Debug -DMPI_C_COMPILER=$HOME/local/$MPI/bin/mpicc -DMPI_CXX_COMPILER=$HOME/local/$MPI/bin/mpicxx ../;
else cmake -DFAKE_BIG_MPI=ON -DTRAVIS=ON -DCMAKE_BUILD_TYPE=Debug -DMPI_C_COMPILER=$HOME/local/$MPI/bin/mpicc -DMPI_CXX_COMPILER=$HOME/local/$MPI/bin/mpicxx ../; fi

script:
# build mxx and run tests
Expand All @@ -76,5 +76,5 @@ script:
after_success:
# only collect coverage if compiled with gcc
- if [ "$CXX" = "g++-4.8" ]; then codecov --gcov-exec gcov-4.8; fi
- cat "/home/travis/build/patflick/mxx/build/#home#travis#build#patflick#mxx#include#mxx#sort.hpp.gcov"
- gdb -batch -ex "b sort.hpp:47" -ex run -ex disas -ex q --args ./bin/mxx-test-sort
#- cat "/home/travis/build/patflick/mxx/build/#home#travis#build#patflick#mxx#include#mxx#sort.hpp.gcov"
#- gdb -batch -ex "b sort.hpp:47" -ex run -ex disas -ex q --args ./bin/mxx-test-sort
15 changes: 14 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,11 +52,23 @@ endif(DOXYGEN_FOUND)

### Test Coverage
OPTION(ENABLE_COVERAGE "Enable code coverage reporting" OFF)

# on travis: debug build with coverage
OPTION(TRAVIS "Travis build" OFF)
if(TRAVIS)
# enable coverage
SET(ENABLE_COVERAGE ON CACHE BOOL "Enable code coverage reporting" FORCE)
# set debug build
SET(CMAKE_BUILD_TYPE Debug)
endif(TRAVIS)

if(ENABLE_COVERAGE)
# turn off stack protection for gcov coverage, because the stack protector shows
# up as a never taken branch, and thus turns any last statement in a function
# with a stack procetor into a partially covered statement.
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fno-stack-protector")
#
# additionally: disable inlining for more precise coverage
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage -fno-stack-protector --fno-inline --fno-inline-small-functions -fno-default-inline")
endif(ENABLE_COVERAGE)

### Fake BIG MPI for testing of BigMPI functions on travis or other small RAM
Expand All @@ -77,4 +89,5 @@ include_directories("${PROJECT_SOURCE_DIR}")
# build tests
add_subdirectory(gtest)
add_subdirectory(test)

add_subdirectory(src)
15 changes: 11 additions & 4 deletions include/mxx/datatypes.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,10 @@ datatype get_datatype(const T&) {
MPI_Type_free(&struct_type); \
return _type;

#define MXX_DT_STRUCT_MEMBERS_GET_TYPE(BASE_TYPE, ...) MXX_DT_PREAMBLE(BASE_TYPE); FOR_EACH(MXX_DT_MEMBER_DISPLS, __VA_ARGS__); MXX_DT_POSTAMBLE(BASE_TYPE);

#define MXX_WRAP_TEMPLATE(...) __VA_ARGS__

#define MXX_DT_STRUCT_MEMBERS_GET_TYPE(BASE_TYPE, ...) MXX_DT_PREAMBLE(MXX_WRAP_TEMPLATE(BASE_TYPE)); FOR_EACH(MXX_DT_MEMBER_DISPLS, __VA_ARGS__); MXX_DT_POSTAMBLE(MXX_WRAP_TEMPLATE(BASE_TYPE));
#define MXX_DT_STRUCT_MEMBER_NUM_BASIC(MEMBER) datatype_builder<decltype(p. MEMBER)>::num_basic_elements()
#define MXX_DT_STRUCT_MEMBER_ADD_NUM_BASIC(MEMBER) + datatype_builder<decltype(p. MEMBER)>::num_basic_elements()

Expand All @@ -551,12 +554,14 @@ datatype get_datatype(const T&) {
FOR_EACH(MXX_DT_STRUCT_MEMBER_ADD_NUM_BASIC, __VA_ARGS__) ;\
}



#define MXX_CUSTOM_STRUCT_(BASE_TYPE, ...) \
struct datatype_builder<BASE_TYPE> { \
static MPI_Datatype get_type() { \
MXX_DT_STRUCT_MEMBERS_GET_TYPE(BASE_TYPE, __VA_ARGS__); \
MXX_DT_STRUCT_MEMBERS_GET_TYPE(MXX_WRAP_TEMPLATE(BASE_TYPE), __VA_ARGS__); \
} \
MXX_DT_STRUCT_MEMBERS_NUM_BASIC(BASE_TYPE, __VA_ARGS__); \
MXX_DT_STRUCT_MEMBERS_NUM_BASIC(MXX_WRAP_TEMPLATE(BASE_TYPE), __VA_ARGS__); \
};

#define MXX_CUSTOM_STRUCT(BASE_TYPE, ...) \
Expand All @@ -566,7 +571,9 @@ MXX_CUSTOM_STRUCT_(BASE_TYPE, __VA_ARGS__); \
} // namespace mxx


#define MXX_CUSTOM_TEMPLATE_STRUCT(BASE_TYPE, ...) MXX_CUSTOM_STRUCT_(BASE_TYPE, __VA_ARGS__)
// use the MXX_WRAP_TEMPLATE() around templated types that have more than one paramter
// otherwise the comma "," in the template would split the templated type into separate arguments
#define MXX_CUSTOM_TEMPLATE_STRUCT(BASE_TYPE, ...) MXX_CUSTOM_STRUCT_(MXX_WRAP_TEMPLATE(BASE_TYPE), __VA_ARGS__)

} // namespace mxx

Expand Down
12 changes: 12 additions & 0 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@ cmake_minimum_required(VERSION 2.6)
# project settings
project(mxx-test)

if (TRAVIS)

# on travis: build a single executable
add_executable(mxx-test-all test_all.cpp)
target_link_libraries(mxx-test-all mxx-gtest-main)

else (TRAVIS)

add_executable(mxx-test-collective test_collective.cpp)
target_link_libraries(mxx-test-collective mxx-gtest-main)

Expand All @@ -28,6 +36,10 @@ target_link_libraries(mxx-test-bucketing mxx-gtest-main)
add_executable(mxx-test-all test_collective.cpp test_reductions.cpp test_send.cpp test_sort.cpp test_distribution.cpp)
target_link_libraries(mxx-test-all mxx-gtest-main)

endif (TRAVIS)



################
# Old tests: #
################
Expand Down
6 changes: 6 additions & 0 deletions test/test_all.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// include all tests into a single executable
#include "test_collective.cpp"
#include "test_reductions.cpp"
#include "test_send.cpp"
#include "test_sort.cpp"
#include "test_distribution.cpp"

0 comments on commit b39093c

Please sign in to comment.