File: record-coverage.sh

package info (click to toggle)
qpid-proton 0.37.0-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 18,384 kB
  • sloc: ansic: 37,828; cpp: 37,140; python: 15,302; ruby: 6,018; xml: 477; sh: 320; pascal: 52; makefile: 18
file content (60 lines) | stat: -rwxr-xr-x 1,886 bytes parent folder | download | duplicates (5)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#! /usr/bin/env bash

# This script collates coverage data already present from running instrumented code.
#
# It requires the lcov tool to be installed (this provides the lcov and genhtml commands)
#
# It will produce a coverage analysis for gcc or clang compiled builds and currently for
# C and C++ parts of the build tree.
#
# It takes two command line arguments:
# - The first is the proton source tree: this is mandatory.
# - The second is the build tree: this is optional and if not specified is assumed to be the
#   current directory.
#
# The output is in the form of an html report which will be found in the generated html directory.
# - There will also be a number of intermediate files left in the current directory.
#
# The typical way to use it would be to use the "Coverage" build type to get instrumented
# code, then to run the tests then to extract the coverage information from running the
# tests.
# Something like:
#   cmake $PROTON_SRC -DCMAKE_BUILD_TYPE=Coverage
#   make
#   make test
#   make coverage

# set -x

# get full path
function getpath {
  pushd -n $1 > /dev/null
  echo $(dirs -0 -l)
  popd -n > /dev/null
}

SRC=${1?}
BLD=${2:-.}

BLDPATH=$(getpath $BLD)
SRCPATH=$(getpath $SRC)

# Get base profile
# - this initialises 0 counts for every profiled file
#   without this step any file with no counts at all wouldn't
#   show up on the final output.
lcov -c -i -d $BLDPATH -o proton-base.info

# Get actual coverage data
lcov -c -d $BLDPATH -o proton-ctest.info

# Total them up
lcov --add proton-base.info --add proton-ctest.info > proton-total-raw.info

# Snip out stuff in /usr (we don't care about coverage in system code)
lcov --remove proton-total-raw.info "/usr/include*" "/usr/share*" > proton-total.info

# Generate report
rm -rf html
genhtml -p $SRCPATH -p $BLDPATH proton-total.info --title "Proton CTest Coverage" --demangle-cpp -o html