|
| 1 | +#!/bin/sh |
| 2 | +basepath=`pwd` |
| 3 | + |
| 4 | +function print_help { |
| 5 | + echo "#######################################################################" |
| 6 | + echo "### Generation of Test Coverage Report ###" |
| 7 | + echo "# #" |
| 8 | + echo "# This only works for builds made with GCC and the following CMake #" |
| 9 | + echo "# variables: #" |
| 10 | + echo "# -Dpfasst_WITH_GCC_PROF=ON -Dpfasst_BUILD_TESTS=ON #" |
| 11 | + echo "# #" |
| 12 | + echo "# First (and only) parameter must be the name of the build directory #" |
| 13 | + echo "# #" |
| 14 | + echo "# Example: #" |
| 15 | + echo "# ./generate_coverage.sh build_gcc #" |
| 16 | + echo "# #" |
| 17 | + echo "#######################################################################" |
| 18 | + return 0 |
| 19 | +} |
| 20 | + |
| 21 | + |
| 22 | +if [[ $# -ne 1 ]] |
| 23 | +then |
| 24 | + print_help |
| 25 | + echo "ERROR: Please name the build directory as the first parameter." |
| 26 | + exit -1 |
| 27 | +fi |
| 28 | + |
| 29 | +builddir=${1} |
| 30 | +cd ${builddir} |
| 31 | + |
| 32 | +rm -rf ${basepath}/coverage |
| 33 | +mkdir -p ${basepath}/coverage |
| 34 | + |
| 35 | +for testdir in `find ${basepath}/${builddir} -type d | grep -o 'tests/.*/.*\dir'` |
| 36 | +do |
| 37 | + testname=`expr "$testdir" : '.*\(test_[a-zA-Z\-_]*\)\.dir'` |
| 38 | + echo "Gathering Coverage for ${testname}" |
| 39 | + cd $testdir |
| 40 | + lcov --zerocounters --directory . |
| 41 | + cd ${basepath}/${builddir} |
| 42 | + ctest -R $testname |
| 43 | + cd $testdir |
| 44 | + lcov --directory . --capture --output-file ${testname}.info.tmp |
| 45 | + lcov --extract ${testname}.info.tmp "*${basepath}/include/**/*" --output-file ${testname}.info |
| 46 | + rm ${testname}.info.tmp |
| 47 | + cd ${basepath}/${builddir} |
| 48 | + lcov --add-tracefile ${testdir}/${testname}.info --output-file all_tests.info |
| 49 | +done |
| 50 | + |
| 51 | +cd ${basepath} |
| 52 | +genhtml --output-directory ./coverage \ |
| 53 | + --demangle-cpp --num-spaces 2 --sort \ |
| 54 | + --title "PFASST++ Test Coverage" --prefix ${basepath}/include \ |
| 55 | + --function-coverage --branch-coverage --legend ${basepath}/${builddir}/all_tests.info |
0 commit comments