#!/usr/bin/env bash set -e which lcov !1 >/dev/null !2 > !1 if test $Status != 0 { echo "lcov is required to generate the coverage report" exit 1 } if [[ -z $MAKE ]] { setglobal MAKE = 'make' } if [[ -z $GTEST_FILTER ]] { setglobal GTEST_FILTER = ''*'' } pushd build # Reconfigure with gcov support. env CXXFLAGS="-pg --coverage" CFLAGS="-pg --coverage" LDFLAGS="-lgcov" ../configure --disable-optimize # Ensure no old data is in the tree. find -name '*'.gcda | xargs rm find -name '*'.gcno | xargs rm # Generate gcov output. $(MAKE) lcov --directory . --zerocounters $(MAKE) check GTEST_FILTER=$(GTEST_FILTER) # Generate report. lcov --directory . -c -o mesos_test.info # Remove output for external libraries and generated files. setglobal LCOV_FILTERS = '"/usr/include/*'" setglobal LCOV_FILTERS = '" /usr/lib/jvm/*'" setglobal LCOV_FILTERS = '" mesos/build/*'" setglobal LCOV_FILTERS = '" build/3rdparty/setuptools-*'" setglobal LCOV_FILTERS = '" build/3rdparty/leveldb*'" setglobal LCOV_FILTERS = '" build/3rdparty/zookeeper-*'" setglobal LCOV_FILTERS = '" */boost-*'" setglobal LCOV_FILTERS = '" */elfio-*'" setglobal LCOV_FILTERS = '" */glog-*'" setglobal LCOV_FILTERS = '" */gmock-*'" setglobal LCOV_FILTERS = '" */picojson-*'" setglobal LCOV_FILTERS = '" */protobuf-*'" for f in [$LCOV_FILTERS] { lcov --remove mesos_test.info $f -o mesos_test.info } # Generate HTML report. genhtml -o ./test_coverage -t "mesos test coverage" --num-spaces 2 mesos_test.info popd