lcov-report 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. #! /bin/sh
  2. #
  3. # Generate coverage report
  4. #
  5. #
  6. # Copyright (C) 2007 Nokia Corporation
  7. # Contact: Pekka Pessi <pekka.pessi@nokia.com>
  8. # Licensed under LGPL. See file COPYING.
  9. #
  10. usage()
  11. {
  12. test X$1 = X0 || exec >&2
  13. cat << EOF
  14. usage: coverage-report OPTIONS
  15. where OPTIONS are
  16. --srcdir=DIR
  17. --output-directory=DIR | -o DIR
  18. --title=TITLE
  19. --prefix=PREFIX
  20. --show-details
  21. --legend
  22. --frames
  23. EOF
  24. exit $1;
  25. }
  26. GENHTML_OPTIONS= o=
  27. while test $# -gt 0;
  28. do
  29. case $1 in
  30. --srcdir | -s )
  31. test -z "$2" && usage 1; shift; srcdir=$1; shift; ;;
  32. --srcdir=* )
  33. srcdir=${1#--srcdir=}; shift ;;
  34. --output-directory | --output_directory | -o )
  35. test -z "$2" && usage 1; shift; o=$1; shift; ;;
  36. --output-directory=* | --output_directory=* )
  37. o=${1#--output?directory=}; shift ;;
  38. --prefix=* | --title=* | --show-details | --legend | --frames )
  39. GENHTML_OPTIONS="${GENHTML_OPTIONS} $1" ; shift ;;
  40. --prefix | --title )
  41. test -z "$2" && usage 1; GENHTML_OPTIONS="${GENHTML_OPTIONS} $1 $2" ; shift ; shift ;;
  42. --help | '-?' | -h ) usage 0 ;;
  43. - ) shift; break ;;
  44. -* ) usage 1; ;;
  45. * ) break ;;
  46. esac
  47. done
  48. info=${o:=.}/lcov.info geninfo=${o}/genhtml.info
  49. rm -f ${info} ${info}
  50. case ${GENHTML_OPTIONS} in *--prefix* ) ;; *)
  51. GENHTML_OPTIONS="${GENHTML_OPTIONS} --prefix=`cd ${srcdir:=.} && pwd`"
  52. esac
  53. lcov --compat-libtool --directory . --capture --output-file ${info} &&
  54. {
  55. # remove system includes with with inlined functions
  56. lcov -l ${info} | grep -v "`cd ${srcdir:-.} && pwd`"
  57. # remove source files in builddir
  58. test ${srcdir:-.} = . || lcov -l ${info} | grep "`pwd`"
  59. # remove test programs
  60. lcov -l ${info} | grep "/test\|/torture\|_test[.][ch][+xp]*$"
  61. } |
  62. cut -d: -f1 |
  63. xargs lcov -r ${info} > ${geninfo}
  64. genhtml ${GENHTML_OPTIONS} --output-directory $o ${geninfo}