mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-03-03 14:42:10 +01:00
Add support for coverage reports with lcov
Patch by Patrick Hulin, bug #501057.
This commit is contained in:
parent
bad7f1e54f
commit
cca48bd5b9
@ -123,7 +123,7 @@ DISTCHECK_CONFIGURE_FLAGS = --enable-debug --enable-gtk-doc --enable-man
|
|||||||
|
|
||||||
DISTCLEANFILES = glibconfig-sysdefs.h glibconfig.h stamp-gc-h config.lt
|
DISTCLEANFILES = glibconfig-sysdefs.h glibconfig.h stamp-gc-h config.lt
|
||||||
|
|
||||||
distclean-local:
|
distclean-local: lcov-clean
|
||||||
if test $(srcdir) = .; then :; else \
|
if test $(srcdir) = .; then :; else \
|
||||||
rm -f $(BUILT_EXTRA_DIST); \
|
rm -f $(BUILT_EXTRA_DIST); \
|
||||||
fi
|
fi
|
||||||
|
@ -61,5 +61,27 @@ test-report perf-report full-report: ${TEST_PROGS}
|
|||||||
${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
|
${GTESTER_REPORT} --version 2>/dev/null 1>&2 ; test "$$?" != 0 || ${GTESTER_REPORT} $@.xml >$@.html ; \
|
||||||
}
|
}
|
||||||
.PHONY: test test-report perf-report full-report
|
.PHONY: test test-report perf-report full-report
|
||||||
|
|
||||||
|
.PHONY: lcov genlcov lcov-clean
|
||||||
|
# use recursive makes in order to ignore errors during check
|
||||||
|
lcov:
|
||||||
|
-$(MAKE) $(AM_MAKEFLAGS) -k check
|
||||||
|
$(MAKE) $(AM_MAKEFLAGS) genlcov
|
||||||
|
|
||||||
|
# we have to massage the lcov.info file slightly to hide the effect of libtool
|
||||||
|
# placing the objects files in the .libs/ directory separate from the *.c
|
||||||
|
# we also have to delete tests/.libs/libmoduletestplugin_*.gcda
|
||||||
|
genlcov:
|
||||||
|
rm -f $(top_builddir)/tests/.libs/libmoduletestplugin_*.gcda
|
||||||
|
$(LTP) --directory $(top_builddir) --capture --output-file glib-lcov.info --test-name GLIB_PERF --no-checksum
|
||||||
|
$(SED) -e 's#.libs/##' < glib-lcov.info > glib-lcov.info.tmp
|
||||||
|
LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory glib-lcov --title "GLib Code Coverage" --legend --show-details glib-lcov.info.tmp
|
||||||
|
rm -f glib-lcov.info.tmp
|
||||||
|
|
||||||
|
lcov-clean:
|
||||||
|
-$(LTP) --directory $(top_builddir) -z
|
||||||
|
-rm -rf glib-lcov.info glib-lcov
|
||||||
|
-find -name '*.gcda' -print | xargs rm
|
||||||
|
|
||||||
# run make test as part of make check
|
# run make test as part of make check
|
||||||
check-local: test
|
check-local: test
|
||||||
|
69
configure.in
69
configure.in
@ -2831,6 +2831,75 @@ AC_ARG_WITH([tapset-install-dir],
|
|||||||
[ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"])
|
[ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"])
|
||||||
AC_SUBST(ABS_TAPSET_DIR)
|
AC_SUBST(ABS_TAPSET_DIR)
|
||||||
|
|
||||||
|
dnl ************************************
|
||||||
|
dnl *** Enable lcov coverage reports ***
|
||||||
|
dnl ************************************
|
||||||
|
|
||||||
|
AC_ARG_ENABLE(gcov,
|
||||||
|
AS_HELP_STRING([--enable-gcov],
|
||||||
|
[Enable gcov]),
|
||||||
|
[use_gcov=$enableval], [use_gcov=no])
|
||||||
|
|
||||||
|
if test "x$use_gcov" = "xyes"; then
|
||||||
|
dnl we need gcc:
|
||||||
|
if test "$GCC" != "yes"; then
|
||||||
|
AC_MSG_ERROR([GCC is required for --enable-gcov])
|
||||||
|
fi
|
||||||
|
|
||||||
|
dnl Check if ccache is being used
|
||||||
|
AC_CHECK_PROG(SHTOOL, shtool, shtool)
|
||||||
|
case `$SHTOOL path $CC` in
|
||||||
|
*ccache*[)] gcc_ccache=yes;;
|
||||||
|
*[)] gcc_ccache=no;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test "$gcc_ccache" = "yes" && (test -z "$CCACHE_DISABLE" || test "$CCACHE_DISABLE" != "1"); then
|
||||||
|
AC_MSG_ERROR([ccache must be disabled when --enable-gcov option is used. You can disable ccache by setting environment variable CCACHE_DISABLE=1.])
|
||||||
|
fi
|
||||||
|
|
||||||
|
ltp_version_list="1.6 1.7 1.8"
|
||||||
|
AC_CHECK_PROG(LTP, lcov, lcov)
|
||||||
|
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
|
||||||
|
|
||||||
|
if test "$LTP"; then
|
||||||
|
AC_CACHE_CHECK([for ltp version], glib_cv_ltp_version, [
|
||||||
|
glib_cv_ltp_version=invalid
|
||||||
|
ltp_version=`$LTP -v 2>/dev/null | $SED -e 's/^.* //'`
|
||||||
|
for ltp_check_version in $ltp_version_list; do
|
||||||
|
if test "$ltp_version" = "$ltp_check_version"; then
|
||||||
|
glib_cv_ltp_version="$ltp_check_version (ok)"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
])
|
||||||
|
else
|
||||||
|
ltp_msg="To enable code coverage reporting you must have one of the following LTP versions installed: $ltp_version_list"
|
||||||
|
AC_MSG_ERROR([$ltp_msg])
|
||||||
|
fi
|
||||||
|
|
||||||
|
case $glib_cv_ltp_version in
|
||||||
|
""|invalid[)]
|
||||||
|
ltp_msg="You must have one of the following versions of LTP: $ltp_version_list (found: $ltp_version)."
|
||||||
|
AC_MSG_ERROR([$ltp_msg])
|
||||||
|
LTP="exit 0;"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if test -z "$LTP_GENHTML"; then
|
||||||
|
AC_MSG_ERROR([Could not find genhtml from the LTP package])
|
||||||
|
fi
|
||||||
|
|
||||||
|
AC_DEFINE(HAVE_GCOV, 1, [Whether you have gcov])
|
||||||
|
|
||||||
|
dnl Remove all optimization flags from CFLAGS
|
||||||
|
changequote({,})
|
||||||
|
CFLAGS=`echo "$CFLAGS" | $SED -e 's/-O[0-9]*//g'`
|
||||||
|
changequote([,])
|
||||||
|
|
||||||
|
dnl Add the special gcc flags
|
||||||
|
CFLAGS="$CFLAGS -O0 -fprofile-arcs -ftest-coverage"
|
||||||
|
LDFLAGS="$LDFLAGS -lgcov"
|
||||||
|
fi
|
||||||
|
|
||||||
dnl ******************************
|
dnl ******************************
|
||||||
dnl *** output the whole stuff ***
|
dnl *** output the whole stuff ***
|
||||||
dnl ******************************
|
dnl ******************************
|
||||||
|
@ -259,6 +259,10 @@ How to compile GLib itself
|
|||||||
<arg>--disable-systemtap</arg>
|
<arg>--disable-systemtap</arg>
|
||||||
<arg>--enable-systemtap</arg>
|
<arg>--enable-systemtap</arg>
|
||||||
</group>
|
</group>
|
||||||
|
<group>
|
||||||
|
<arg>--enable-gcov</arg>
|
||||||
|
<arg>--disable-gcov</arg>
|
||||||
|
</group>
|
||||||
<group>
|
<group>
|
||||||
<arg>--with-runtime-libdir=RELPATH</arg>
|
<arg>--with-runtime-libdir=RELPATH</arg>
|
||||||
</group>
|
</group>
|
||||||
@ -605,6 +609,19 @@ How to compile GLib itself
|
|||||||
</para>
|
</para>
|
||||||
</formalpara>
|
</formalpara>
|
||||||
|
|
||||||
|
<formalpara>
|
||||||
|
<title><systemitem>--enable-gcov</systemitem> and
|
||||||
|
<systemitem>--disable-gcov</systemitem></title>
|
||||||
|
|
||||||
|
<para>
|
||||||
|
Enable the generation of coverage reports for the GLib tests.
|
||||||
|
This requires the lcov frontend to gcov from the
|
||||||
|
<ulink url="http://ltp.sourcforge.net">Linux Test Project</ulink>.
|
||||||
|
To generate a coverage report, use the lcov make target. The
|
||||||
|
report is placed in the <filename>glib-lcov</filename> directory.
|
||||||
|
</para>
|
||||||
|
</formalpara>
|
||||||
|
|
||||||
<formalpara>
|
<formalpara>
|
||||||
<title><systemitem>--with-runtime-libdir=RELPATH</systemitem></title>
|
<title><systemitem>--with-runtime-libdir=RELPATH</systemitem></title>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user