processCoverage.sh 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. #!/usr/bin/env bash
  2. CIDIR=$(dirname $(readlink -fn $0))
  3. source $CIDIR/ci.functions
  4. if [ ! -r main/asterisk.gcno ]; then
  5. # Coverage is not enabled.
  6. exit 0
  7. fi
  8. if [ -z $LCOV_DIR ]; then
  9. LCOV_DIR="${OUTPUT_DIR:+${OUTPUT_DIR}/}lcov"
  10. fi
  11. if [ -z $COVERAGE_DIR ]; then
  12. COVERAGE_DIR="${OUTPUT_DIR:+${OUTPUT_DIR}/}coverage"
  13. fi
  14. if [ -z $ASTERISK_VERSION ]; then
  15. ASTERISK_VERSION=$(./build_tools/make_version .)
  16. fi
  17. set -x
  18. # Capture counter data from testing
  19. lcov --no-external --capture --directory . --output-file ${LCOV_DIR}/tested.info > /dev/null
  20. # Combine initial and tested data.
  21. lcov \
  22. --add-tracefile ${LCOV_DIR}/initial.info \
  23. --add-tracefile ${LCOV_DIR}/tested.info \
  24. --output-file ${LCOV_DIR}/combined.info > /dev/null
  25. # We don't care about coverage reporting for tests, utils or third-party.
  26. lcov --remove ${LCOV_DIR}/combined.info \
  27. "${PWD}/main/dns_test.*" \
  28. "${PWD}/main/test.*" \
  29. "${PWD}/tests/*" \
  30. "${PWD}/utils/*" \
  31. "${PWD}/third-party/*" \
  32. --output-file ${LCOV_DIR}/filtered.info > /dev/null
  33. # Generate HTML coverage report.
  34. mkdir -p ${COVERAGE_DIR}
  35. genhtml --prefix ${PWD} --ignore-errors source ${LCOV_DIR}/filtered.info \
  36. --legend --title "Asterisk ${ASTERISK_VERSION}" --output-directory=${COVERAGE_DIR} > /dev/null