Commit 41bd7786 authored by Pekka Pessi's avatar Pekka Pessi

lcov: updated usage

Made rules/lcov.am suitable for different projects.

Removed rules/coverage.am, rules/covcheck.am, scripts/add-coverage

Added scripts/lcov-report, which has functionality previously in the
lcov-report makefile target.

Added m4/sac-coverage.am for autoconf macros used by rules/lcov.am.

darcs-hash:20070427142118-55b16-d827dc7a851ffdc27233bdea8d3b6948198d6118.gz
parent fa875d9c
......@@ -24,13 +24,15 @@ EXTRA_DIST = AUTHORS COPYING COPYRIGHTS ChangeLog.ext-trees \
ACLOCAL_AMFLAGS = -I m4
EXTRA_DIST += m4/sac-general.m4 m4/sac-su.m4 \
m4/sac-su2.m4 m4/sac-tport.m4 m4/sac-openssl.m4
EXTRA_DIST += m4/sac-general.m4 m4/sac-su.m4 m4/sac-coverage.m4 \
m4/sac-su2.m4 m4/sac-tport.m4 m4/sac-openssl.m4
EXTRA_DIST += docs/build_system.txt \
docs/devel_platform_notes.txt \
docs/release_management.txt
EXTRA_DIST += scripts/lcov-report scripts/uncovered
dist_man_MANS = man/man1/sip-date.1 man/man1/sip-options.1 \
man/man1/localinfo.1 man/man1/addrinfo.1 \
man/man1/stunc.1 man/man1/sip-dig.1
......@@ -51,7 +53,7 @@ endif
CLEANFILES = $(dist_man_MANS)
coverage built-sources clean-built-sources valcheck doxygen:
built-sources clean-built-sources valcheck doxygen:
@failcom='exit 1'; for f in x $$MAKEFLAGS; do \
case $$f in *=* | --[!k]*);; *k*) failcom='fail=yes';; esac; done; \
for i in libsofia-sip-ua $(GLIB_SUBDIRS) ; do \
......@@ -59,10 +61,15 @@ coverage built-sources clean-built-sources valcheck doxygen:
done ; \
test -z "$$fail"
PHONY = coverage built-sources clean-built-sources valcheck doxygen manpages
PHONY = built-sources clean-built-sources valcheck doxygen manpages
if HAVE_LCOV
include $(top_srcdir)/rules/lcov.am
lcov-upload: lcov
rsync -rvz -e ssh --delete lcov/* sofia-sip.org:/var/www/coverage/lcov/
if ENABLE_COVERAGE
include rules/coverage.am
endif
.PHONY: $(PHONY)
......@@ -46,4 +46,8 @@ PHONY = doxygen
include $(top_srcdir)/rules/recursive.am
.PHONY = $(PHONY)
\ No newline at end of file
if HAVE_LCOV
include $(top_srcdir)/rules/lcov.am
endif
.PHONY = $(PHONY)
......@@ -55,7 +55,7 @@ libsofia_sip_ua_la_LIBADD = bnf/libbnf.la \
libsofia_sip_ua_la_LDFLAGS = \
-version-info $(LIBVER_SOFIA_SIP_UA_CUR):$(LIBVER_SOFIA_SIP_UA_REV):$(LIBVER_SOFIA_SIP_UA_AGE)
PHONY = doxygen
PHONY = doxygen built-sources
include $(top_srcdir)/rules/recursive.am
......@@ -99,7 +99,7 @@ doxygen: built-sources
${srcdir}/docs/hide_emails.sh docs/html
if HAVE_LCOV
include $(top_srcdir)/rules/covcheck.am
include $(top_srcdir)/rules/lcov.am
endif
.PHONY: $(PHONY)
dnl =====================================================================
dnl This file contains autoconf macros shared by Sofia modules.
dnl
dnl Author: Pekka Pessi <Pekka.Pessi@nokia.com>
dnl
dnl License:
dnl
dnl Copyright (c) 2001,2004 Nokia and others. All Rights Reserved.
dnl
dnl Please note that every macro contained in this file is copyrighted by
dnl its respective author, unless the macro source explicitely says
dnl otherwise. Permission has been granted, though, to use and distribute
dnl all macros under the following license, which is a modified version of
dnl the GNU General Public License version 2:
dnl
dnl Each Autoconf macro in this file is free software; you can redistribute it
dnl and/or modify it under the terms of the GNU General Public License as
dnl published by the Free Software Foundation; either version 2, or (at your
dnl option) any later version.
dnl
dnl They are distributed in the hope that they will be useful, but WITHOUT ANY
dnl WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
dnl FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
dnl details. (You should have received a copy of the GNU General Public License
dnl along with this program; if not, write to the Free Software Foundation,
dnl Inc., 59 Temple Place -- Suite 330, Boston, MA 02111-1307, USA.)
dnl
dnl As a special exception, the Free Software Foundation gives unlimited
dnl permission to copy, distribute and modify the configure scripts that are
dnl the output of Autoconf. You need not follow the terms of the GNU General
dnl Public License when using or distributing such scripts, even though
dnl portions of the text of Autoconf appear in them. The GNU General Public
dnl License (GPL) does govern all other use of the material that constitutes
dnl the Autoconf program.
dnl
dnl Certain portions of the Autoconf source text are designed to be copied
dnl (in certain cases, depending on the input) into the output of Autoconf.
dnl We call these the "data" portions. The rest of the Autoconf source text
dnl consists of comments plus executable code that decides which of the data
dnl portions to output in any given case. We call these comments and
dnl executable code the "non-data" portions. Autoconf never copies any of
dnl the non-data portions into its output.
dnl
dnl This special exception to the GPL applies to versions of Autoconf
dnl released by the Free Software Foundation. When you make and distribute a
dnl modified version of Autoconf, you may extend this special exception to
dnl the GPL to apply to your modified version as well, *unless* your
dnl modified version has the potential to copy into its output some of the
dnl text that was the non-data portion of the version that you started with.
dnl (In other words, unless your change moves or copies text from the
dnl non-data portions to the data portions.) If your modification has such
dnl potential, you must delete any notice of this special exception to the
dnl GPL from your modified version.
dnl
dnl =====================================================================
dnl ===================================================================
dnl Define --enable-coverage, enable coverage in Makefile.am
dnl ===================================================================
AC_DEFUN([SAC_COVERAGE], [
AC_REQUIRE([AC_PROG_CC])
#
# GCoverage
#
AC_ARG_ENABLE(coverage,
[ --enable-coverage compile test-coverage [[disabled]]],
, enable_coverage=no)
if test X$enable_coverage = Xno ; then
:
elif test X$GCC != Xyes ; then
AC_MSG_ERROR([--enable-coverage requires gcc])
else
COVERAGE_FLAGS="-fprofile-arcs -ftest-coverage"
dnl old_CFLAGS=$CFLAGS
dnl CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
dnl AC_SEARCH_LIBS(__gcov_init, gcov)
dnl CFLAGS=$old_CFLAGS
dnl
dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
dnl links in -lgcov, so we do it explicitly here for the same effect
dnl
AC_CHECK_LIB(gcov, __gcov_init)
dnl GCOV is part of GCC suite
GCOV=`echo $CC | sed s/gcc/gcov/g`
AC_DEFINE([HAVE_COVERAGE], 1,
[Defined when gcov is enabled to force by changing config.h])
dnl Check for lcov utility
AC_CHECK_PROG([LCOV], [lcov], [lcov], [false])
if test X$LCOV != Xfalse ; then
AC_MSG_CHECKING([whether $LCOV accepts --compat-libtool])
if $LCOV --compat-libtool --help > /dev/null 2>&1 ; then
AC_MSG_RESULT(ok)
else
AC_MSG_RESULT(not supported)
AC_MSG_WARN([lcov option --compat-libtool is not supported])
AC_MSG_WARN([Update lcov to version > 1.5])
LCOV=false
fi
fi
AC_CHECK_PROG([GENHTML], [genhtml], [genhtml], [false])
AC_CHECK_PROG([GENPNG], [genpng], [genpng], [false])
if test X$LCOV != Xfalse ; then
AC_MSG_CHECKING([whether $GENPNG has all required modules])
if $GENPNG --help > /dev/null 2>&1 ; then
AC_MSG_RESULT(ok)
else
AC_MSG_RESULT(not supported)
AC_MSG_WARN([GD.pm perl module is not installed])
GENPNG=false
fi
fi
fi
AM_CONDITIONAL([ENABLE_COVERAGE], test X$enable_coverage != Xno)
AM_CONDITIONAL([HAVE_LCOV], test X$LCOV != Xfalse)
AM_CONDITIONAL([HAVE_GENPNG], test X$GENPNG != Xfalse)
AC_SUBST([GCOV])
AC_SUBST([COVERAGE_FLAGS])
AC_SUBST([MOSTLYCLEANFILES], "*.bb *.bbg *.da *.gcov *.gcda *.gcno")
])
\ No newline at end of file
......@@ -123,66 +123,7 @@ AC_SUBST([CWFLAG], [$ac_cv_cwflag])
AC_ARG_VAR([SOFIA_CFLAGS], [CFLAGS not used during configure])
#
# GCoverage
#
AC_ARG_ENABLE(coverage,
[ --enable-coverage compile test-coverage [[disabled]]],
, enable_coverage=no)
if test X$enable_coverage = Xno ; then
:
elif test X$GCC != Xyes ; then
AC_MSG_ERROR([--enable-coverage requires gcc])
else
AC_SUBST([SOFIA_COVERAGE], ["-fprofile-arcs -ftest-coverage"])
dnl old_CFLAGS=$CFLAGS
dnl CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
dnl AC_SEARCH_LIBS(_gcov_init, gcov)
dnl CFLAGS=$old_CFLAGS
dnl
dnl libtool 1.5.22 and lower strip -fprofile-arcs from the flags
dnl passed to the linker, which is a bug; -fprofile-arcs implicitly
dnl links in -lgcov, so we do it explicitly here for the same effect
dnl
AC_CHECK_LIB(gcov, __gcov_init)
GCOV=`echo $CC | sed s/gcc/gcov/g`
AC_SUBST(GCOV)
AC_DEFINE([HAVE_COVERAGE], 1,
[Defined when gcov is enabled to force by changing config.h])
dnl Check for lcov utility
AC_CHECK_PROG([LCOV], [lcov], [lcov], [false])
if test X$LCOV != Xfalse ; then
AC_MSG_CHECKING([whether $LCOV accepts --compat-libtool])
if $LCOV --compat-libtool --help > /dev/null 2>&1 ; then
AC_MSG_RESULT(ok)
else
AC_MSG_RESULT(not supported)
AC_MSG_WARN([lcov option --compat-libtool is not supported])
AC_MSG_WARN([Update lcov to version > 1.5])
LCOV=false
fi
fi
AC_CHECK_PROG([GENHTML], [genhtml], [genhtml], [false])
AC_CHECK_PROG([GENPNG], [genpng], [genpng], [false])
if test X$LCOV != Xfalse ; then
AC_MSG_CHECKING([whether $GENPNG has all required modules])
if $GENPNG --help > /dev/null 2>&1 ; then
AC_MSG_RESULT(ok)
else
AC_MSG_RESULT(not supported)
AC_MSG_WARN([GD.pm perl module is not installed])
GENPNG=false
fi
fi
fi
AM_CONDITIONAL([ENABLE_COVERAGE], test X$enable_coverage != Xno)
AM_CONDITIONAL([HAVE_LCOV], test X$LCOV != Xfalse)
AM_CONDITIONAL([HAVE_GENPNG], test X$GENPNG != Xfalse)
AC_SUBST([MOSTLYCLEANFILES], "*.bb *.bbg *.da *.gcov *.gcda *.gcno")
SAC_COVERAGE
])
dnl ======================================================================
......
#
# covcheck.am run tests - show results of lcov as error log
#
#
# Copyright (C) 2007 Nokia Corporation
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
# Licensed under LGPL. See file COPYING.
#
# Run check in current dir and show all uncovered lines as errors
covcheck:
-find . -name *.gcda | xargs rm -rf
$(MAKE) $(AM_MAKEFLAGS) check
${top_srcdir}/scripts/add-coverage --top_builddir=${top_builddir}
${top_srcdir}/scripts/uncovered --top_builddir=${top_builddir}
# Run check in current dir and show all uncovered lines as errors
uncovered:
@${top_srcdir}/scripts/uncovered --top_builddir=${top_builddir}
#
# Generate lcov output
#
#
# Copyright (C) 2007 Nokia Corporation
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
# Licensed under LGPL. See file COPYING.
#
if HAVE_LCOV
LCOV_SUBDIRS=libsofia-sip-ua libsofia-sip-ua-glib
include rules/lcov.am
lcov-upload: lcov
rsync -rvz -e ssh --delete lcov/* sofia-sip.org:/var/www/coverage/lcov/
include rules/covcheck.am
endif
#
# Generate lcov output
#
# Generate coverage report
#
# Copyright (C) 2007 Nokia Corporation
# Contact: Pekka Pessi <pekka.pessi@nokia.com>
# Licensed under LGPL. See file COPYING.
#
lcov:
make lcov-report
# rerun checks before lcov
lcov-rerun: clean-lcov
$(MAKE) $(AM_MAKEFLAGS) check
$(MAKE) $(AM_MAKEFLAGS) lcov-report
# Scripts
LCOV_UNCOVERED=${top_srcdir}/scripts/uncovered
LCOV_REPORT=${top_srcdir}/scripts/lcov-report
clean:: clean-lcov
clean-lcov:
-rm -rf lcov
find . -name "*.gcda" | xargs rm -f || true
# Report directory
lcovdir=${top_builddir}/lcov
# Options
GENHTML_OPTIONS = --show-details --legend
if HAVE_GENPNG
GENHTML_FRAMES = --frames
else
GENHTML_FIX = true
GENHTML_OPTIONS += --frames
endif
GENHTML_OPTIONS = --show-details --legend $(GENHTML_FRAMES)
# Fancy shell command that expands to directory relative to top_builddir
expand_subdir=`pwd|sed "s'\`cd ${top_builddir};pwd\`''"`
#
# generate report based on current coverage data
# Generate pretty coverage report (unless it has been already done)
#
lcov:
@-test -r ${lcovdir}${expand_subdir}/lcov.info \
|| make lcov-report
# Generate pretty coverage report based on current coverage data
lcov-report:
@-rm -rf lcov
mkdir lcov
for sub in ${LCOV_SUBDIRS}; do \
${LCOV} --compat-libtool --directory $$sub --capture --output-file lcov/$$sub.info0 && \
{ : remove system includes with with inlined functions ; \
${LCOV} -l lcov/$$sub.info0 | grep -v "`cd ${top_srcdir} && pwd`" ; \
: remove source files in builddir ; \
test ${top_srcdir} = ${top_builddir} || \
${LCOV} -l lcov/$$sub.info0 | grep "`cd ${top_builddir} && pwd`" ; \
: remove test programs ; \
${LCOV} -l lcov/$$sub.info0 | grep "/test\|/torture\|_test[.]c$$" ; } | cut -d: -f1 | \
xargs ${LCOV} -r lcov/$$sub.info0 > lcov/$$sub.info && \
${GENHTML} ${GENHTML_OPTIONS} --title "${PACKAGE_NAME}-${PACKAGE_VERSION}/$$sub" \
--output-directory lcov/$$sub lcov/$$sub.info || \
break; \
done
if HAVE_GENPNG
find lcov -name '*.overview.html' | \
xargs perl -pi.bak -e 's/usemap="[#]overview"/usemap="overview"/;'
find lcov -name '*.bak' | xargs rm -f
endif
sub=${expand_subdir} odir=${lcovdir}$$sub ; \
rm -rf $$odir ; mkdir -p $$odir && \
${LCOV_REPORT} ${GENHTML_OPTIONS} \
--title "${PACKAGE_NAME}-${PACKAGE_VERSION}$$sub" \
--srcdir=${srcdir} -o $$odir
# Rerun checks before generating report
lcov-rerun: clean-lcov
$(MAKE) $(AM_MAKEFLAGS) check
$(MAKE) $(AM_MAKEFLAGS) lcov-report
# Show all uncovered lines as errors
uncovered:
${LCOV_UNCOVERED} --lcov-dir=${lcovdir} --srcdir=${srcdir}
# Run check in current dir and show all uncovered lines as errors
covcheck:
-find . -name "*.gcda" | xargs rm -rf
$(MAKE) $(AM_MAKEFLAGS) check
${LCOV_UNCOVERED} --lcov-dir=${lcovdir} --srcdir=${srcdir}
clean:: clean-lcov
clean-lcov:
-rm -rf ${lcovdir}`pwd|sed "s'\`cd ${top_builddir};pwd\`''"`
find . -name "*.gcda" | xargs rm -f || true
PHONY += lcov-report lcov-rerun clean-lcov
PHONY += lcov lcov-report lcov-rerun clean-lcov covcheck uncovered
# Recursive Makefile targets
# --------------------------
if ENABLE_COVERAGE
COVERAGE_RECURSIVE = coverage-recursive
coverage: $(COVERAGE_RECURSIVE)
endif
all-recursive: built-sources-recursive
built-sources: built-sources-recursive
clean-built-sources: clean-built-sources-recursive
valcheck: valcheck-recursive
SOFIA_RECURSIVE = \
valcheck-recursive \
$(COVERAGE_RECURSIVE)
valcheck-recursive
SOFIA_DIST_RECURSIVE = \
built-sources-recursive \
......
......@@ -3,6 +3,8 @@
AM_CFLAGS = $(CWFLAG) $(SOFIA_COVERAGE) $(SOFIA_CFLAGS) $(openssl_CFLAGS)
SOFIA_COVERAGE = $(COVERAGE_FLAGS)
# Use with --enable-ndebug
if NDEBUG
AM_CFLAGS += -DNDEBUG
......@@ -26,11 +28,6 @@ SUFFIXES = _tag_ref.c _tag.c
_tag.c_tag_ref.c:
$(AWK) -f $(TAG_AWK) NODLL=1 $(TAG_DLL_FLAGS) REF=$@ $<
if ENABLE_COVERAGE
coverage:
@$(top_srcdir)/scripts/coverage $(COVERAGE_FLAGS) $(COVERAGE_INPUT)
endif
../bnf/libbnf.la ../http/libhttp.la ../ipt/libipt.la ../iptsec/libiptsec.la \
../msg/libmsg.la ../nea/libnea.la ../nta/libnta.la ../nth/libnth.la \
../nua/libnua.la ../sdp/libsdp.la ../sip/libsip.la ../soa/libsoa.la \
......@@ -59,7 +56,11 @@ INTERNAL_INCLUDES = \
-I$(srcdir)/../url -I../url \
-I$(srcdir)/../su -I../su
PHONY = built-sources clean-built-sources
include $(top_srcdir)/rules/valcheck.am
if HAVE_LCOV
include $(top_srcdir)/rules/covcheck.am
include $(top_srcdir)/rules/lcov.am
endif
#! /bin/sh
#
# Add lcov results from last check run to ${top_srcdir}/lcov/module
#
# 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
echo usage: add-coverage [--top_builddir=DIR] [--top_srcdir=DIR] [PATH]
exit $1;
}
bdir=`pwd`;
prefix=lcov/
top=.
case $0 in */*) top=${0%/scripts/*} top_srcdir=$top;; esac
while test $# -gt 0;
do
case $1 in
--top_builddir ) test -z "$2" && usage 1; shift; top=$1; shift; ;;
--top_builddir=* ) top=${1#--top_builddir=}; shift ;;
--top_srcdir ) test -z "$2" && usage 1; shift; top=$1; shift; ;;
--top_srcdir=* ) top=${1#--top_srcdir=}; shift ;;
- ) shift; break ;;
-* ) usage 1; ;;
* ) break ;;
esac
done
abs_srcdir=`cd $top_srcdir; pwd`
cd $top
tdir=`pwd`;
if test $tdir != $bdir; then
prefix=lcov${bdir#$tdir}
fi
p=$prefix/$1
mkdir -p lcov
case $p in
lcov/ )
echo libsofia-sip-ua lcov/libsofia-sip-ua.info
echo libsofia-sip-ua-glib lcov/libsofia-sip-ua-glib.info
;;
lcov/?* )
base=${p#lcov/}
echo ${base%/} lcov/${base%%/*}.info
;;
* )
echo $0:$LINENO: internal error >& 2
exit 2
;;
esac | tee /dev/tty |
while read directory outputfile
do
# Remove changed source files
if test -r ${outputfile}0 ; then
find ${abs_srcdir}/${directory} -name '*.[hc]' -newer ${outputfile}0 |
xargs lcov -r ${outputfile}0 > ${outputfile}1 &&
mv ${outputfile}1 ${outputfile}0
fi
lcov --capture --compat-libtool \
--directory ${directory} --output-file ${outputfile}0 &&
{
# remove test programs and system includes with inlined functions
lcov -l ${outputfile}0 | grep -v "`cd ${top_srcdir} && pwd`"
lcov -l ${outputfile}0 | grep "/test\|/torture\|_test[.]c$"
} | cut -d: -f1 |
xargs lcov -r ${outputfile}0 > ${outputfile} &&
genhtml --title "sofia-sip-current/$directory" \
--output-directory lcov/${directory%%/*} ${outputfile}
done
#! /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
case $1 in
--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 ;;
--prefix | --title )
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}
case ${GENHTML_OPTIONS} in *--prefix* ) ;; *)
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
lcov -l ${info} | grep "/test\|/torture\|_test[.][ch][+xp]*$"
} |
cut -d: -f1 |
xargs lcov -r ${info} > ${geninfo}
genhtml ${GENHTML_OPTIONS} --output-directory $o ${geninfo} &&
case ${GENHTML_OPTIONS} in
*--frames* )
: Fix broken links
find $o -name '*.overview.html' |
xargs perl -pi.bak -e 's/usemap="[#]overview"/usemap="overview"/;' &&
find $o -name '*.bak' | xargs rm -f
;;
esac
#! /bin/sh
#
# mark uncovered lines as errors
# show uncovered lines as errors
#
#
......@@ -12,49 +12,67 @@
usage()
{
test X$1 == X0 || exec >&2
echo usage: uncovered [--top_builddir=DIR] [PATH...]
cat <<EOF
usage: uncovered OPTIONS
where OPTIONS are
--srcdir=DIR specify source directory
--lcov-dir=DIR | -l DIR specify directory for lcov.info files
EOF
exit $1;
}
bdir=`pwd`;
prefix=lcov/
top=.
case $0 in */*) top=${0%/scripts/*};; esac
GENHTML_OPTIONS= o= ldir=
while test $# -gt 0;
do
case $1 in
--top_builddir ) test -z "$2" && usage 1 ; shift; top=$1; shift; ;;
--top_builddir=* ) top=${1#--top_builddir=}; shift ;;
--lcov-dir | -l ) test -z "$2" && usage 1; shift; ldir=$1; shift; ;;
--lcov-dir=* ) ldir=${1#--ldir=}; shift ;;
--srcdir | -s )
test -z "$2" && usage 1; shift; srcdir=$1; shift; ;;
--srcdir=* )
srcdir=${1#--srcdir=}; shift ;;
--help | '-?' | -h ) usage 0 ;;
- ) shift; break ;;
-* ) usage 1; ;;
* ) break;
* ) break ;;
esac
done
cd $top
tdir=`pwd`;
cwd=`pwd`
if test $tdir != $bdir; then
prefix=lcov${bdir#$tdir}
fi
tdir=${TMPDIR:-/tmp}/$USER.uncovered.$$
info=${tdir}/lcov.info geninfo=${tdir}/genhtml.info
if test $# -gt 0; then
for p in $@
do
if test -d $bdir/$p ; then
find $prefix/$p -name '*.gcov.html'
else
echo $prefix/$p.gcov.html
fi
done
else
find $prefix/ -name '*.gcov.html'
fi |
xargs perl -e '
$base="'${prefix}/'";
test -d ${tdir} && { echo ${tdir}: already exists ; exit 2 ; }
mkdir -p ${tdir} &&
{
# Find all lcov.info0 under -t DIR
test -d ${ldir} &&
find ${ldir} -name lcov.info |
while read s
do
find $cwd -type f -not -newer $s | xargs lcov -q -e $s
done
lcov -q -c -d . --compat-libtool
} > ${info}
test -e ${info} || exit 1
{
# remove system includes with with inlined functions
lcov -q -l ${info} | grep -v "`cd ${srcdir:-.} && pwd`"
# remove test programs
lcov -q -l ${info} | grep "/test\|/torture\|_test[.]c$"
} |
cut -d: -f1 |
xargs lcov -q -r ${info} > ${geninfo} &&
cd ${tdir} &&
genhtml -q --prefix=$cwd/ --output-directory . ${geninfo} &&
find . -name '*.gcov.html' |
xargs perl -e '
while (<>) {
if (m:<pre[^>]*>:) { $pre=1; }
if ($pre && m:</pre[^>]*>:) {
......@@ -87,7 +105,7 @@ while (<>) {
}
elsif (m/^ *\d+ *0 :/) {
for ($f = $ARGV) {
s:^${base}/?::o;
s:^[.]'$cwd/'::o;
s:[.]gcov[.]html$::;
}
s/^ +(\d+)[^:]+:/$1:/;
......@@ -97,3 +115,8 @@ while (<>) {
}
}
' /dev/null
rc=$?
cd /
rm -rf $tdir
exit $rc
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment