lcov-report 1.78 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
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
#! /bin/sh
#
# Generate coverage report
#

#
# Copyright (C) 2007 Nokia Corporation
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
# Licensed under LGPL. See file COPYING.
#

usage()
{
  test X$1 == X0 || exec >&2
  cat << EOF
usage: coverage-report OPTIONS
where OPTIONS are
   --srcdir=DIR
   --output-directory=DIR | -o DIR
   --title=TITLE
   --prefix=PREFIX
   --show-details
   --legend
   --frames
EOF
  exit $1;
}

GENHTML_OPTIONS= o=

while test $# -gt 0;
do
33
  case $1 in
Pekka Pessi's avatar
Pekka Pessi committed
34 35 36 37 38 39 40 41 42 43
  --srcdir | -s )
    test -z "$2" && usage 1; shift; srcdir=$1; shift; ;;
  --srcdir=* )
    srcdir=${1#--srcdir=}; shift ;;
  --output-directory | --output_directory | -o )
    test -z "$2" && usage 1; shift; o=$1; shift; ;;
  --output-directory=* | --output_directory=* )
    o=${1#--output?directory=}; shift ;;
  --prefix=* | --title=* | --show-details | --legend | --frames )
    GENHTML_OPTIONS="${GENHTML_OPTIONS} $1" ; shift ;;
44
  --prefix | --title )
Pekka Pessi's avatar
Pekka Pessi committed
45 46 47 48 49 50 51 52 53 54 55
    test -z "$2" && usage 1; GENHTML_OPTIONS="${GENHTML_OPTIONS} $1 $2" ; shift ; shift ;;
  --help | '-?' | -h ) usage 0 ;;
  - ) shift; break ;;
  -* ) usage 1; ;;
  * ) break ;;
  esac
done

info=${o:=.}/lcov.info geninfo=${o}/genhtml.info
rm -f ${info} ${info}

56
case ${GENHTML_OPTIONS} in *--prefix* ) ;; *)
Pekka Pessi's avatar
Pekka Pessi committed
57 58 59 60 61 62 63 64 65 66
  GENHTML_OPTIONS="${GENHTML_OPTIONS} --prefix=`cd ${srcdir:=.} && pwd`"
esac

lcov --compat-libtool --directory . --capture --output-file ${info} &&
{
    # remove system includes with with inlined functions
    lcov -l ${info} | grep -v "`cd ${srcdir:-.} && pwd`"
    # remove source files in builddir
    test ${srcdir:-.} = . || lcov -l ${info} | grep "`pwd`"
    # remove test programs
67
    lcov -l ${info} | grep "/test\|/torture\|_test[.][ch][+xp]*$"
Pekka Pessi's avatar
Pekka Pessi committed
68 69 70
} |
cut -d: -f1 |
xargs lcov -r ${info} > ${geninfo}
71
genhtml ${GENHTML_OPTIONS} --output-directory $o ${geninfo}