File: coverage.sh

package info (click to toggle)
lizardfs 3.12.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 8,064 kB
  • sloc: cpp: 91,899; sh: 9,341; python: 3,878; ansic: 3,109; pascal: 128; makefile: 57
file content (38 lines) | stat: -rwxr-xr-x 1,053 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env bash
appname=$0
command=$1
builddir=$2
shift 2

usage() {
	{
		echo "Usage:"
		echo "$appname prepare <build-dir>"
		echo "    Prepares a CMake build directory to run tests with will generate"
		echo "    a code coverage report. This is needed, because LizardFS tests are"
		echo "    run with a different UID than the user who builds sources."
		echo "$appname generate-html <build-dir> <out-dir>"
		echo "    Generates a HTML code coverage report from the data collected during tests"
	} >&2
	exit 1
}

if [[ ! -f "$builddir/CMakeCache.txt" ]]; then
	usage
fi

if [[ $command == prepare ]]; then
	set -eu
	find "$builddir" -type d | xargs chmod a+w
	find "$builddir" -name '*.gcda' | xargs rm -f
elif [[ $command == generate-html ]]; then
	outdir=$1
	set -eu
	mkdir -p "$outdir"
	lcov --capture --directory . --output-file cov.raw
	lcov --remove cov.raw '/usr/*' '*/external/*' '*/tests/*' '*/utils/*' '*/devtools/*' -o cov.info
	genhtml cov.info --output-directory "$outdir" --no-branch-coverage
	rm -f cov.raw cov.info
else
	usage
fi