mirror of
https://github.com/brl/mutter.git
synced 2024-11-25 09:30:45 -05:00
Add gcov support to the build
Using gcov it's possible to get a coverage report, that is a break down of how much the exposed API is exercised by the conformance test suite.
This commit is contained in:
parent
5322546a4e
commit
948db40c87
2
.gitignore
vendored
2
.gitignore
vendored
@ -11,11 +11,13 @@ clutter.pc
|
||||
*.o
|
||||
*.lo
|
||||
*.la
|
||||
*.gcov
|
||||
ChangeLog*
|
||||
clutter/clutter-enum-types.[ch]
|
||||
clutter/clutter-marshal.[ch]
|
||||
clutter/clutter-version.h
|
||||
clutter/stamp-*
|
||||
/clutter/gcov-report.txt
|
||||
/clutter/clutter-json.h
|
||||
/clutter/cogl/cogl/cogl-defines.h
|
||||
/clutter/cogl/cogl/*.pc
|
||||
|
@ -48,3 +48,6 @@ MAINTAINERCLEANFILES = \
|
||||
$(NULL)
|
||||
|
||||
include $(top_srcdir)/build/autotools/Makefile.am.changelog
|
||||
|
||||
gcov:
|
||||
@( cd clutter && $(MAKE) $(AM_MAKEFLAGS) $@ ) || exit $$?
|
||||
|
@ -5,6 +5,7 @@ EXTRA_DIST = \
|
||||
Makefile.am.marshal \
|
||||
Makefile.am.enums \
|
||||
Makefile.am.changelog \
|
||||
Makefile.am.gcov \
|
||||
dolt.m4 \
|
||||
introspection.m4 \
|
||||
gtk-doc.m4 \
|
||||
|
33
build/autotools/Makefile.am.gcov
Normal file
33
build/autotools/Makefile.am.gcov
Normal file
@ -0,0 +1,33 @@
|
||||
if GCOV_ENABLED
|
||||
gcov-report.txt: gcov-clean
|
||||
$(QUIET_GEN)(rm -f $@; \
|
||||
echo -e "Test coverage for Clutter:\n" >> $@; \
|
||||
total_covered=0; total_actual=0; \
|
||||
for file in $(filter %.c,$(gcov_sources)); do \
|
||||
gcov -o .libs/$${file/.c/.gcda} $$file > /dev/null; \
|
||||
if test -f $$file.gcov; then \
|
||||
actual=`grep -v ' -:' $$file.gcov | wc -l`; \
|
||||
uncovered=`grep '#####:' $$file.gcov | wc -l`; \
|
||||
covered=$$((actual - uncovered)); \
|
||||
total_covered=$$((total_covered + covered)); \
|
||||
total_actual=$$((total_actual + actual)); \
|
||||
echo -e "$$file: \t$$covered / $$actual\t($$((($$covered * 100) / $$actual))%)"; \
|
||||
fi \
|
||||
done >> $@; \
|
||||
cd $(abs_srcdir); \
|
||||
echo -e "\nSource lines: $$total_actual\nCovered statements: $$total_covered\nTotal coverage: $$((($$total_covered * 100) / $$total_actual))%" >> $@)
|
||||
|
||||
gcov: gcov-report.txt
|
||||
@echo ""; cat gcov-report.txt
|
||||
gcov-clean:
|
||||
@find . -name "*.gcda" -o -name "*.gcov" -delete
|
||||
else
|
||||
gcov-report.txt:
|
||||
@true
|
||||
gcov-clean:
|
||||
@true
|
||||
gcov:
|
||||
@echo "Need to reconfigure with --enable-gcov"
|
||||
endif # GCOV_ENABLED
|
||||
|
||||
.PHONY: gcov gcov-clean gcov-report.txt
|
@ -41,14 +41,7 @@ AM_CPPFLAGS = \
|
||||
$(CLUTTER_DEBUG_CFLAGS) \
|
||||
$(NULL)
|
||||
|
||||
AM_CFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS)
|
||||
|
||||
LDADD = \
|
||||
$(CLUTTER_LT_LDFLAGS) \
|
||||
-export-dynamic \
|
||||
-export-symbols-regex "^(clutter|cogl|json).*" \
|
||||
-rpath $(libdir) \
|
||||
$(NULL)
|
||||
AM_CFLAGS = $(CLUTTER_CFLAGS) $(MAINTAINER_CFLAGS) $(GCOV_CFLAGS)
|
||||
|
||||
# please, keep this sorted alphabetically
|
||||
source_h = \
|
||||
@ -220,7 +213,13 @@ libclutter_@CLUTTER_WINSYS@_@CLUTTER_API_VERSION@_la_SOURCES = \
|
||||
$(source_c_priv) \
|
||||
$(source_h_priv)
|
||||
|
||||
libclutter_@CLUTTER_WINSYS@_@CLUTTER_API_VERSION@_la_LDFLAGS = $(LDADD)
|
||||
libclutter_@CLUTTER_WINSYS@_@CLUTTER_API_VERSION@_la_LDFLAGS = \
|
||||
$(CLUTTER_LT_LDFLAGS) \
|
||||
$(GCOV_LDFLAGS) \
|
||||
-export-dynamic \
|
||||
-export-symbols-regex "^(clutter|cogl|json).*" \
|
||||
-rpath $(libdir) \
|
||||
$(NULL)
|
||||
|
||||
lib_LTLIBRARIES = $(CLUTTER_WINSYS_LIB)
|
||||
|
||||
@ -322,3 +321,6 @@ typelibs_DATA = $(BUILT_GIRSOURCES:.gir=.typelib)
|
||||
|
||||
CLEANFILES += $(BUILT_GIRSOURCES) $(typelibs_DATA)
|
||||
endif # HAVE_INTROSPECTION
|
||||
|
||||
gcov_sources = $(source_c)
|
||||
include $(top_srcdir)/build/autotools/Makefile.am.gcov
|
||||
|
26
configure.ac
26
configure.ac
@ -720,6 +720,31 @@ AM_CONDITIONAL(PROFILE, test "x$enable_profile" != "xno")
|
||||
AC_SUBST(CLUTTER_PROFILE_CFLAGS)
|
||||
AC_SUBST(CLUTTER_PROFILE_LDFLAGS)
|
||||
|
||||
dnl === Coverage report =======================================================
|
||||
|
||||
AC_PATH_PROG([GCOV], [gcov], [enable_gcov=no])
|
||||
|
||||
AC_MSG_CHECKING([whether to build with gcov testing])
|
||||
|
||||
AC_ARG_ENABLE([gcov],
|
||||
[AS_HELP_STRING([--enable-gcov],
|
||||
[Whether to enable coverage testing (requires gcc
|
||||
and gcov)])],
|
||||
[],
|
||||
[enable_gcov=no])
|
||||
|
||||
AS_IF([test "x$enable_gcov" = "xyes" && test "x$GCC" = "xyes"],
|
||||
[
|
||||
GCOV_CFLAGS="-g -O0 -fprofile-arcs -ftest-coverage"
|
||||
GCOV_LDFLAGS="-lgcov"
|
||||
]
|
||||
)
|
||||
|
||||
AM_CONDITIONAL([GCOV_ENABLED], [test "x$enable_gcov" = "xyes"])
|
||||
AC_SUBST([GCOV_CFLAGS])
|
||||
AC_SUBST([GCOV_LDFLAGS])
|
||||
AC_MSG_RESULT([$enable_gcov])
|
||||
|
||||
dnl === Enable strict compiler flags ==========================================
|
||||
|
||||
# use strict compiler flags only on development releases
|
||||
@ -908,6 +933,7 @@ echo " Clutter debug level: ${enable_debug}"
|
||||
echo " COGL debug level: ${enable_cogl_debug}"
|
||||
echo " Compiler flags: ${MAINTAINER_CFLAGS}"
|
||||
echo " Profiling enabled: ${enable_profile}"
|
||||
echo " Enable coverage tests: ${enable_gcov}"
|
||||
|
||||
# Documentation
|
||||
echo ""
|
||||
|
Loading…
Reference in New Issue
Block a user