|
1 | 1 | #!/bin/sh |
2 | | -basepath=`pwd` |
| 2 | +basepath="`pwd`" |
3 | 3 |
|
4 | 4 | function print_help { |
5 | 5 | echo "#######################################################################" |
|
26 | 26 | exit -1 |
27 | 27 | fi |
28 | 28 |
|
29 | | -builddir=${1} |
30 | | -cd ${builddir} |
| 29 | +builddir="${basepath}/${1}" |
| 30 | +if [[ ! -d "${builddir}" ]] |
| 31 | +then |
| 32 | + echo "ERROR: Given build directory '${bilddir}' does not exist." |
| 33 | + exit -1 |
| 34 | +fi |
| 35 | +cd "${builddir}" |
31 | 36 |
|
32 | | -rm -rf ${basepath}/coverage |
33 | | -mkdir -p ${basepath}/coverage |
| 37 | +coveragedir="${basepath}/coverage" |
| 38 | +rm -rf "${coveragedir}" |
| 39 | +mkdir -p "${coveragedir}" |
34 | 40 |
|
35 | | -for testdir in `find ${basepath}/${builddir} -type d | grep -o 'tests/.*/.*\dir'` |
| 41 | +for testdir in `find ${builddir} -type d | grep -o 'tests/.*/.*\dir'` |
36 | 42 | 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 | | - if [[ -e all_tests.info ]] |
| 43 | + testname=`expr "${testdir}" : '.*\(test_[a-zA-Z\-_]*\)\.dir'` |
| 44 | + echo "# ${testname}" |
| 45 | + cd "${testdir}" |
| 46 | + echo " Deleting old tracing data" |
| 47 | + lcov --zerocounters --directory . \ |
| 48 | + > "${coveragedir}/log_${testname}_zero.log" 2&>1 |
| 49 | + |
| 50 | + cd "${builddir}" |
| 51 | + echo " Running test and generating tracing data" |
| 52 | + ctest -R ${testname} \ |
| 53 | + > "${coveragedir}/log_${testname}_test.log" |
| 54 | + if [[ $? -ne 0 ]] |
| 55 | + then |
| 56 | + echo "ERROR: test '${testname}' failed." |
| 57 | + echo " See '${coveragedir}/log_${testname}_test.log' for details." |
| 58 | + cd ${basepath} |
| 59 | + exit -1 |
| 60 | + fi |
| 61 | + |
| 62 | + cd "${testdir}" |
| 63 | + echo " Capturing all tracing data" |
| 64 | + lcov --directory . --capture --output-file "${testname}.info.tmp" \ |
| 65 | + > "${coveragedir}/log_${testname}_capture.log" |
| 66 | + |
| 67 | + echo " Extracting interesting tracing data" |
| 68 | + lcov --extract "${testname}.info.tmp" "*${basepath}/include/**/*" \ |
| 69 | + --output-file "${testname}.info" \ |
| 70 | + > "${coveragedir}/log_${testname}_extract.log" |
| 71 | + rm "${testname}.info.tmp" |
| 72 | + |
| 73 | + cd "${builddir}" |
| 74 | + echo " Aggegrating coverage data" |
| 75 | + if [[ -e "${coveragedir}/all_tests.info" ]] |
49 | 76 | then |
50 | | - lcov --add-tracefile all_tests.info --add-tracefile ${testdir}/${testname}.info --output-file all_tests.info |
| 77 | + lcov --add-tracefile "${coveragedir}/all_tests.info" \ |
| 78 | + --add-tracefile "${testdir}/${testname}.info" \ |
| 79 | + --output-file "${coveragedir}/all_tests.info" \ |
| 80 | + > "${coveragedir}/log_${testname}_aggregate.log" |
51 | 81 | else |
52 | | - lcov --add-tracefile ${testdir}/${testname}.info --output-file all_tests.info |
| 82 | + lcov --add-tracefile "${testdir}/${testname}.info" \ |
| 83 | + --output-file "${coveragedir}/all_tests.info" \ |
| 84 | + > "${coveragedir}/log_${testname}_aggregate.log" |
53 | 85 | fi |
54 | 86 | done |
55 | 87 |
|
56 | 88 | cd ${basepath} |
57 | | -genhtml --output-directory ./coverage \ |
58 | | - --demangle-cpp --num-spaces 2 --sort \ |
59 | | - --title "PFASST++ Test Coverage" --prefix ${basepath}/include \ |
60 | | - --function-coverage --branch-coverage --legend ${basepath}/${builddir}/all_tests.info |
| 89 | +echo "# Generating HTML report" |
| 90 | +genhtml --output-directory "${coveragedir}" \ |
| 91 | + --demangle-cpp --num-spaces 2 --sort \ |
| 92 | + --title "PFASST++ Test Coverage" --prefix "${basepath}/include" \ |
| 93 | + --function-coverage --branch-coverage --legend \ |
| 94 | + "${coveragedir}/all_tests.info" \ |
| 95 | + > "${coveragedir}/log_generate.log" |
| 96 | + |
| 97 | +echo "# Coverage report can be found in ${coveragedir}/index.html" |
| 98 | +echo "# Everything done." |
0 commit comments