Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
sudo-project
GitHub Repository: sudo-project/sudo
Path: blob/main/scripts/generate_test_coverage.sh
1532 views
1
#!/bin/sh
2
3
# This script is meant as an example on how to generate test coverage
4
# information. It is meant to be executed from an empty build directory.
5
#
6
# Usage: <path to the script>/generate_test_coverage.sh [configure options]
7
#
8
# Example:
9
# mkdir -p build
10
# cd build
11
# ../scripts/generate_test_coverage.sh --enable-python
12
13
srcdir=$(dirname "$0")
14
srcdir=${srcdir%%"/scripts"}
15
CONFIGURE=${CONFIGURE:-${srcdir}/configure}
16
LCOV=${LCOV:-lcov}
17
GENHTML=${GENHTML:-genhtml}
18
19
echo "Using configure: $CONFIGURE (Override with CONFIGURE environment variable)"
20
echo "Extra configure options: $@ (Override with script arguments)"
21
echo "Using lcov: $LCOV (Override with LCOV environment variable)"
22
echo "Using genhtml: $GENHTML (Override with GENHTML environment variable)"
23
echo
24
25
"$CONFIGURE" "$@" CFLAGS="--coverage -fprofile-arcs -ftest-coverage -O0" LDFLAGS="-lgcov"
26
make || exit 1
27
make check
28
"${LCOV}" -c --directory . --output-file coverage.info --rc "geninfo_adjust_src_path = $PWD => $srcdir"
29
"${GENHTML}" coverage.info --output-directory test_coverage
30
echo "Test coverage can be found at: test_coverage/index.html"
31
32