libmicrohttpd

HTTP/1.x server C library (MHD 1.x, stable)
Log | Files | Refs | Submodules | README | LICENSE

3-coverage.sh (2334B)


      1 #!/bin/bash
      2 set -exuo pipefail
      3 
      4 # Produce an HTML coverage report into a local artifacts directory.
      5 #
      6 # Unlike the GNU Taler jobs this deliberately does *not* upload anywhere:
      7 # there is no rsync target for libmicrohttpd, and a CI job that silently
      8 # depends on a private host is a job that breaks for everyone else.  The
      9 # report is left in the working tree; wire it up to whatever artifact
     10 # store the runner has.
     11 
     12 ARTIFACT_DIR="${MHD_CI_ARTIFACT_DIR:-contrib/ci/artifacts/coverage/${CI_COMMIT_REF:-local}}"
     13 
     14 mkdir -p "${ARTIFACT_DIR}"
     15 
     16 # lcov 2.x turns a lot of things that used to be warnings into errors and
     17 # needs them switched off explicitly; lcov 1.x does not know some of
     18 # those keywords at all.  Try the strict-lcov invocation first and fall
     19 # back to the plain one, so the job works on either.
     20 lcov_try()
     21 {
     22 	lcov "$@" --ignore-errors mismatch,negative,source,empty,unused \
     23 	  || lcov "$@"
     24 }
     25 
     26 lcov_try --capture \
     27          --directory . \
     28          --output-file "${ARTIFACT_DIR}/coverage.info"
     29 
     30 # Only MHD's own sources are interesting; drop system headers and the
     31 # test programs themselves.
     32 lcov_try --remove "${ARTIFACT_DIR}/coverage.info" \
     33          '/usr/*' \
     34          "${PWD}/src/testcurl/*" \
     35          "${PWD}/src/testzzuf/*" \
     36          "${PWD}/src/fuzz/*" \
     37          "${PWD}/src/examples/*" \
     38          --output-file "${ARTIFACT_DIR}/coverage-lib.info" \
     39   || cp "${ARTIFACT_DIR}/coverage.info" "${ARTIFACT_DIR}/coverage-lib.info"
     40 
     41 genhtml "${ARTIFACT_DIR}/coverage-lib.info" \
     42         --output-directory "${ARTIFACT_DIR}/html" \
     43         --title "GNU libmicrohttpd ${CI_COMMIT_REF:-local}" \
     44         --legend \
     45         --ignore-errors source,empty \
     46   || genhtml "${ARTIFACT_DIR}/coverage-lib.info" \
     47              --output-directory "${ARTIFACT_DIR}/html" \
     48              --title "GNU libmicrohttpd ${CI_COMMIT_REF:-local}" \
     49              --legend
     50 
     51 echo "===================================================================="
     52 echo "== coverage report written to:"
     53 echo "==   ${PWD}/${ARTIFACT_DIR}/html/index.html"
     54 echo "== raw tracefiles:"
     55 echo "==   ${PWD}/${ARTIFACT_DIR}/coverage.info      (everything)"
     56 echo "==   ${PWD}/${ARTIFACT_DIR}/coverage-lib.info  (library only)"
     57 echo "===================================================================="
     58 lcov_try --summary "${ARTIFACT_DIR}/coverage-lib.info" || true