mirror of
https://github.com/brl/mutter.git
synced 2024-12-23 11:32:04 +00:00
build: Add coverage support using lcov
Unlike gcov, lcov provides a nice HTML output that allows immediate visualization of the current coverage. The updates of the build system have been taken from GLib, which has been using lcov for a while with good results.
This commit is contained in:
parent
c4acae7752
commit
5eb3fbf3cf
4
.gitignore
vendored
4
.gitignore
vendored
@ -23,12 +23,16 @@ stamp-marshal
|
|||||||
/clutter/gcov-report.txt
|
/clutter/gcov-report.txt
|
||||||
/clutter/clutter-json.h
|
/clutter/clutter-json.h
|
||||||
/clutter/cex100/clutter-cex100.h
|
/clutter/cex100/clutter-cex100.h
|
||||||
|
/clutter-lcov.info
|
||||||
|
/clutter-lcov
|
||||||
/build/autotools/*.m4
|
/build/autotools/*.m4
|
||||||
!/build/autotools/introspection.m4
|
!/build/autotools/introspection.m4
|
||||||
!/build/autotools/as-linguas.m4
|
!/build/autotools/as-linguas.m4
|
||||||
!/build/autotools/as-compiler-flag.m4
|
!/build/autotools/as-compiler-flag.m4
|
||||||
*.gir
|
*.gir
|
||||||
*.typelib
|
*.typelib
|
||||||
|
*.gcda
|
||||||
|
*.gcno
|
||||||
config.*
|
config.*
|
||||||
configure
|
configure
|
||||||
depcomp
|
depcomp
|
||||||
|
26
Makefile.am
26
Makefile.am
@ -44,4 +44,28 @@ test-report full-report:
|
|||||||
perf-report:
|
perf-report:
|
||||||
$(MAKE) -C tests/performance $(@)
|
$(MAKE) -C tests/performance $(@)
|
||||||
|
|
||||||
.PHONY: test-report full-report perf-report
|
if ENABLE_GCOV
|
||||||
|
# use recursive makes in order to ignore errors during check/perf
|
||||||
|
lcov:
|
||||||
|
-$(MAKE) $(AM_MAKEFLAGS) -C clutter check
|
||||||
|
-$(MAKE) $(AM_MAKEFLAGS) -C tests/conform test
|
||||||
|
$(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
|
||||||
|
genlcov:
|
||||||
|
$(LTP) --directory $(top_builddir) --capture --output-file clutter-lcov.info --test-name CLUTTER_TEST --no-checksum
|
||||||
|
$(SED) -e 's#.libs/##' < clutter-lcov.info > clutter-lcov.info.tmp
|
||||||
|
LANG=C $(LTP_GENHTML) --prefix $(top_builddir) --output-directory clutter-lcov --title "Clutter Code Coverage" --show-details clutter-lcov.info.tmp
|
||||||
|
rm -f clutter-lcov.info.tmp
|
||||||
|
|
||||||
|
lcov-clean:
|
||||||
|
-$(LTP) --directory $(top_builddir) -z
|
||||||
|
-$(RM) -rf clutter-lcov.info clutter-lcov
|
||||||
|
else
|
||||||
|
lcov genlcov lcov-clean:
|
||||||
|
@echo You need to configure Clutter with support for gcov enabled.
|
||||||
|
@echo e.g., ./configure --enable-gcov
|
||||||
|
endif
|
||||||
|
|
||||||
|
.PHONY: test-report full-report perf-report lcov genlcov lcov-clean
|
||||||
|
77
configure.ac
77
configure.ac
@ -870,7 +870,6 @@ AS_CASE([$enable_deprecated],
|
|||||||
|
|
||||||
AC_SUBST([CLUTTER_DEPRECATED_CFLAGS])
|
AC_SUBST([CLUTTER_DEPRECATED_CFLAGS])
|
||||||
|
|
||||||
|
|
||||||
dnl === Profiling =============================================================
|
dnl === Profiling =============================================================
|
||||||
|
|
||||||
m4_define([profile_default], [no])
|
m4_define([profile_default], [no])
|
||||||
@ -981,6 +980,80 @@ CLUTTER_LIBS="$FLAVOUR_LIBS $CLUTTER_DEPS_LIBS $CLUTTER_DEPS_PRIVATE_LIBS $CLUTT
|
|||||||
AC_SUBST(CLUTTER_CFLAGS)
|
AC_SUBST(CLUTTER_CFLAGS)
|
||||||
AC_SUBST(CLUTTER_LIBS)
|
AC_SUBST(CLUTTER_LIBS)
|
||||||
|
|
||||||
|
dnl === Test coverage =========================================================
|
||||||
|
|
||||||
|
AC_ARG_ENABLE([gcov],
|
||||||
|
[AS_HELP_STRING([--enable-gcov], [Enable gcov])],
|
||||||
|
[use_gcov=$enableval],
|
||||||
|
[use_gcov=no])
|
||||||
|
|
||||||
|
AS_IF([test "x$use_gcov" = "xyes"],
|
||||||
|
[
|
||||||
|
dnl we need gcc:
|
||||||
|
AS_IF([test "$GCC" != "yes"], [AC_MSG_ERROR([GCC is required for --enable-gcov])])
|
||||||
|
|
||||||
|
dnl Check if ccache is being used
|
||||||
|
AC_CHECK_PROG(SHTOOL, shtool, shtool)
|
||||||
|
AS_CASE([`$SHTOOL path $CC`],
|
||||||
|
[*ccache*], [gcc_ccache=yes],
|
||||||
|
[gcc_ccache=no])
|
||||||
|
|
||||||
|
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 1.9"
|
||||||
|
AC_CHECK_PROG(LTP, lcov, lcov)
|
||||||
|
AC_CHECK_PROG(LTP_GENHTML, genhtml, genhtml)
|
||||||
|
|
||||||
|
if test "$LTP"; then
|
||||||
|
AC_CACHE_CHECK([for ltp version], clutter_cv_ltp_version,
|
||||||
|
[
|
||||||
|
clutter_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
|
||||||
|
clutter_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 $clutter_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'`
|
||||||
|
CLUTTER_CFLAGS=`echo "$CLUTTER_CFLAGS" | $SED -e 's/-O[0-9]*//g'`
|
||||||
|
changequote([,])
|
||||||
|
|
||||||
|
dnl Define the special gcc flags
|
||||||
|
CLUTTER_GCOV_CFLAGS="-O0 -fprofile-arcs -ftest-coverage"
|
||||||
|
CLUTTER_GCOV_LDADD="-lgcov"
|
||||||
|
|
||||||
|
AC_SUBST(CLUTTER_GCOV_CFLAGS)
|
||||||
|
AC_SUBST(CLUTTER_GCOV_LDADD)
|
||||||
|
|
||||||
|
CLUTTER_CFLAGS="$CLUTTER_CFLAGS $CLUTTER_GCOV_CFLAGS"
|
||||||
|
CLUTTER_LIBS="$CLUTTER_LIBS $CLUTTER_GCOV_LDADD"
|
||||||
|
])
|
||||||
|
|
||||||
|
AM_CONDITIONAL(ENABLE_GCOV, test "x$use_gcov" = "xyes")
|
||||||
|
|
||||||
dnl === GObject-Introspection check ===========================================
|
dnl === GObject-Introspection check ===========================================
|
||||||
|
|
||||||
@ -1143,7 +1216,7 @@ echo " • Compiler options:"
|
|||||||
echo " Clutter debug level: ${enable_debug}"
|
echo " Clutter debug level: ${enable_debug}"
|
||||||
echo " Compiler flags: ${CFLAGS} ${MAINTAINER_CFLAGS}"
|
echo " Compiler flags: ${CFLAGS} ${MAINTAINER_CFLAGS}"
|
||||||
echo " Profiling enabled: ${enable_profile}"
|
echo " Profiling enabled: ${enable_profile}"
|
||||||
echo " Enable coverage tests: ${enable_gcov}"
|
echo " Enable coverage tests: ${use_gcov}"
|
||||||
echo " Enable deprecated symbols: ${enable_deprecated}"
|
echo " Enable deprecated symbols: ${enable_deprecated}"
|
||||||
|
|
||||||
# Documentation
|
# Documentation
|
||||||
|
Loading…
Reference in New Issue
Block a user