#!/bin/bash set -exuo pipefail REPORT="@PROJECT_NAME@-coverage.info" STDERR="@PROJECT_NAME@-coverage.stderr" HTML_DIR="@PROJECT_NAME@-coverage" SRCS_DIR="/usr/src/debug/@PROJECT_NAME@-@VERSION@" # create dir for the report mkdir $HTML_DIR # remove old gcda files find / -iname "*.gcda" -exec rm {} \; # launch unit tests ckm-unit-tests # copy source files cp -rp $SRCS_DIR*/* "@CMAKE_BINARY_DIR@" # copy gcda files cp -r "@COVERAGE_BUILD_DIR@"/* "@COVERAGE_DIR@" # prepare report rm -f $STDERR # Due to mismatch in the version of gcc/gcov and lcov, we need to ignore few errors IGNORE_ERRORS=" --ignore-errors unused,unused \ --ignore-errors empty,empty \ --ignore-errors mismatch,mismatch \ --ignore-errors gcov,gcov " lcov $IGNORE_ERRORS --no-external -c -d "@COVERAGE_DIR@" -b "@CMAKE_BINARY_DIR@" -o $REPORT 2>$STDERR lcov $IGNORE_ERRORS -r $REPORT "@CMAKE_BINARY_DIR@/unit-tests/*" -o $REPORT lcov $IGNORE_ERRORS -r $REPORT "@CMAKE_BINARY_DIR@/common/*" -o $REPORT # Let's skip lcov warning # geninfo: WARNING: using JSON module "JSON::PP" - which is much slower than some alternatives. # Consider installing one of JSON::XS or Cpanel::JSON::XS sed -i '/WARNING/d' $STDERR # check errors if [ -s $STDERR ] then echo "Errors detected (see $STDERR). Aborting." exit 1 fi # html genhtml $REPORT --output-directory $HTML_DIR/