Skip to content

Commit

Permalink
Merge pull request pmem#12 from igchor/coverage
Browse files Browse the repository at this point in the history
common: add coverage support
  • Loading branch information
marcinslusarz authored Jun 25, 2018
2 parents b73b65e + 81a1657 commit a84b467
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
coverage:
ignore:
- utils/
- tests/
- doc/
- examples/
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ env:
matrix:
- TYPE=normal OS=ubuntu OS_VER=16.04 PUSH_IMAGE=1
- TYPE=normal OS=fedora OS_VER=25 PUSH_IMAGE=1
- TYPE=normal OS=ubuntu OS_VER=16.04 COVERAGE=1
- TYPE=coverity OS=ubuntu OS_VER=16.04

before_install:
Expand Down
6 changes: 6 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ option(BUILD_DOC "build documentation" ON)
option(TRACE_TESTS
"more verbose test outputs" OFF)

option(COVERAGE "run coverage test" OFF)

set(TEST_DIR ${CMAKE_CURRENT_BINARY_DIR}/test
CACHE STRING "working directory for tests")

Expand Down Expand Up @@ -170,6 +172,10 @@ if(USE_UBSAN)
add_sanitizer_flag(undefined)
endif()

if(COVERAGE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -coverage")
endif()

add_executable(check_license EXCLUDE_FROM_ALL utils/check_license/check-license.c)

# Generates cppstyle-$name and cppformat-$name targets and attaches them
Expand Down
6 changes: 6 additions & 0 deletions utils/docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ if [[ "$command" == "" ]]; then
esac
fi

if [ "$COVERAGE" = "1" ]; then
docker_opts="${docker_opts} `bash <(curl -s https://codecov.io/env)`";
fi

if [ -n "$DNS_SERVER" ]; then DNS_SETTING=" --dns=$DNS_SERVER "; fi

WORKDIR=/libpmemobj-cpp
Expand All @@ -103,6 +107,7 @@ echo Building ${OS}-${OS_VER}
# - working directory set (-w)
docker run --privileged=true --name=$containerName -ti \
$DNS_SETTING \
${docker_opts} \
--env http_proxy=$http_proxy \
--env https_proxy=$https_proxy \
--env USE_LLVM_LIBCPP=$USE_LLVM_LIBCPP \
Expand All @@ -115,6 +120,7 @@ docker run --privileged=true --name=$containerName -ti \
--env TRAVIS_EVENT_TYPE=$TRAVIS_EVENT_TYPE \
--env COVERITY_SCAN_TOKEN=$COVERITY_SCAN_TOKEN \
--env COVERITY_SCAN_NOTIFICATION_EMAIL=$COVERITY_SCAN_NOTIFICATION_EMAIL \
--env COVERAGE=$COVERAGE \
--env CLANG_FORMAT=clang-format-3.8 \
-v $HOST_WORKDIR:$WORKDIR \
-v /etc/localtime:/etc/localtime \
Expand Down
29 changes: 25 additions & 4 deletions utils/docker/run-build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@

set -e

function cleanup() {
find . -name ".coverage" -exec rm {} \;
find . -name "coverage.xml" -exec rm {} \;
find . -name "*.gcov" -exec rm {} \;
find . -name "*.gcda" -exec rm {} \;
}

function test_command() {
if [ "$COVERAGE" = "1" ]; then
ctest --output-on-failure -E "_memcheck|_drd|_helgrind|_pmemcheck"
bash <(curl -s https://codecov.io/bash)
cleanup
else
ctest --output-on-failure
fi
}

cd $WORKDIR
INSTALL_DIR=/tmp/libpmemobj-cpp

Expand All @@ -50,12 +67,13 @@ cmake .. -DDEVELOPER_MODE=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DTRACE_TESTS=1 \
-DCOVERAGE=$COVERAGE \
-DUSE_LLVM_LIBCPP=1 \
-DLIBCPP_LIBDIR=$LIBCPP_LIBDIR \
-DLIBCPP_INCDIR=$LIBCPP_INCDIR

make -j2
ctest --output-on-failure
test_command
make install

cd ..
Expand All @@ -69,10 +87,11 @@ cmake .. -DDEVELOPER_MODE=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DTRACE_TESTS=1 \
-DCOVERAGE=$COVERAGE \
-DUSE_LLVM_LIBCPP=0

make -j2
ctest --output-on-failure
test_command
make install

cd ..
Expand All @@ -86,10 +105,11 @@ cmake .. -DDEVELOPER_MODE=1 \
-DCMAKE_BUILD_TYPE=Debug \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DTRACE_TESTS=1 \
-DCOVERAGE=$COVERAGE \
-DUSE_LLVM_LIBCPP=0

make -j2
ctest --output-on-failure
test_command
make install

cd ..
Expand All @@ -102,10 +122,11 @@ CC=gcc CXX=g++ \
cmake .. -DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=$INSTALL_DIR \
-DTRACE_TESTS=1 \
-DCOVERAGE=$COVERAGE \
-DUSE_LLVM_LIBCPP=0

make -j2
ctest --output-on-failure
test_command
make install

cd ..
Expand Down

0 comments on commit a84b467

Please sign in to comment.