Commit 9a97f820 authored by Simon McVittie's avatar Simon McVittie

Import compiler.m4 and lcov.am from telepathy-glib, and use them to replace gcov

Reviewed-by: Colin Walters's avatarColin Walters <walters@verbum.org>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=10887
parent f6e2c958
......@@ -33,6 +33,11 @@ config.h.in
*.bbg
*.da
*.gcov
*.gcda
*.gcno
tags
/dbus-1.*/
/dbus-1.*.tar.*
/lcov.html/
/lcov.info
/lcov.info.tmp
......@@ -289,10 +289,8 @@ is to add a test in here.
"make check" runs all the deterministic test programs (i.e. not break-loader).
"make check-coverage" is available if you configure with --enable-gcov and
gives a complete report on test suite coverage. You can also run
"test/decode-gcov foo.c" on any source file to get annotated source,
after running make check with a gcov-enabled tree.
"make lcov-check" is available if you configure with --enable-compiler-coverage
and gives a complete report on test suite coverage.
Patches
===
......
......@@ -23,46 +23,6 @@ EXTRA_DIST = \
all-local: Doxyfile
if DBUS_GCOV_ENABLED
clean-gcov:
find -name "*.da" -o -name "*.gcov" | xargs rm || true
clean-bbg:
find -name "*.bbg" -o -name "*.bb" | xargs rm || true
GCOV_DIRS=dbus bus
## .PHONY so it always rebuilds it
.PHONY: coverage-report.txt
coverage-report.txt:
BBG_FILES=`find $(GCOV_DIRS) -name "*.bbg" -o -name "*.gcno"` ; \
C_FILES= ; \
for F in $$BBG_FILES ; do \
F_nolibs=`echo $$F | sed -e 's/.libs\///g'` ; \
C=`echo $$F_nolibs | sed -e 's/.bbg/.c/g' | sed -e 's/.gcno/.c/g'` ; \
B=`basename $$F .bbg` ; \
D=`dirname $$F` ; \
DA=`echo $$F | sed -e 's/.bbg/.da/g'` ; \
DA_libs=`echo $$D/.libs/$$B/.da` ; \
if test -e $$DA || test -e $$DA_libs; then \
C_FILES="$$C_FILES $$C" ; \
fi ; \
done ; \
echo $$C_FILES ; \
$(top_builddir)/test/decode-gcov --report $$C_FILES > coverage-report.txt
check-coverage: clean-gcov all check coverage-report.txt
cat coverage-report.txt
else
coverage-report.txt:
echo "Need to reconfigure with --enable-gcov"
check-coverage:
echo "Need to reconfigure with --enable-gcov"
endif
update-authors:
git shortlog -s -e | cut -c 8- | sort > AUTHORS
......@@ -70,3 +30,5 @@ DISTCHECK_CONFIGURE_FLAGS = \
--with-systemdsystemunitdir=$$dc_install_base/$(systemdsystemunitdir)
ACLOCAL_AMFLAGS = -I m4
include tools/lcov.am
......@@ -83,7 +83,7 @@ the ./configure program are these
--enable-checks include sanity checks on public API
--enable-xml-docs build XML documentation (requires xmlto)
--enable-doxygen-docs build DOXYGEN documentation (requires Doxygen)
--enable-gcov compile with coverage profiling instrumentation (gcc only)
--enable-compiler-coverage compile with coverage profiling instrumentation (gcc only)
--enable-abstract-sockets use abstract socket namespace (linux only)
--enable-selinux build with SELinux support
--enable-dnotify build with dnotify support (linux only)
......
......@@ -52,10 +52,6 @@ set (test-sleep-forever_SOURCES
${CMAKE_SOURCE_DIR}/../test/test-sleep-forever.c
)
set (decode_gcov_SOURCES
${CMAKE_SOURCE_DIR}/../test/decode-gcov.c
)
add_executable(test-service ${test-service_SOURCES})
target_link_libraries(test-service ${DBUS_INTERNAL_LIBRARIES})
......@@ -81,9 +77,6 @@ target_link_libraries(test-segfault ${DBUS_INTERNAL_LIBRARIES})
add_executable(test-sleep-forever ${test-sleep-forever_SOURCES})
target_link_libraries(test-sleep-forever ${DBUS_INTERNAL_LIBRARIES})
#add_executable(decode-gcov ${decode_gcov_SOURCES})
#target_link_libraries(decode-gcov ${DBUS_INTERNAL_LIBRARIES})
### keep these in creation order, i.e. uppermost dirs first
set (TESTDIRS
test/data
......
......@@ -71,6 +71,8 @@ AC_HEADER_STDC
AC_C_INLINE
AM_PROG_LIBTOOL
AC_PROG_MKDIR_P
COMPILER_COVERAGE
COMPILER_OPTIMISATIONS
# Set some internal variables depending on the platform for later use.
dbus_win=no
......@@ -128,7 +130,6 @@ AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion chec
AC_ARG_ENABLE(checks, AS_HELP_STRING([--enable-checks],[include sanity checks on public API]),enable_checks=$enableval,enable_checks=yes)
AC_ARG_ENABLE(xml-docs, AS_HELP_STRING([--enable-xml-docs],[build XML documentation (requires xmlto)]),enable_xml_docs=$enableval,enable_xml_docs=auto)
AC_ARG_ENABLE(doxygen-docs, AS_HELP_STRING([--enable-doxygen-docs],[build DOXYGEN documentation (requires Doxygen)]),enable_doxygen_docs=$enableval,enable_doxygen_docs=auto)
AC_ARG_ENABLE(gcov, AS_HELP_STRING([--enable-gcov],[compile with coverage profiling instrumentation (gcc only)]),enable_gcov=$enableval,enable_gcov=no)
AC_ARG_ENABLE(abstract-sockets, AS_HELP_STRING([--enable-abstract-sockets],[use abstract socket namespace (linux only)]),enable_abstract_sockets=$enableval,enable_abstract_sockets=auto)
AC_ARG_ENABLE(selinux, AS_HELP_STRING([--enable-selinux],[build with SELinux support]),enable_selinux=$enableval,enable_selinux=auto)
AC_ARG_ENABLE(libaudit,AS_HELP_STRING([--enable-libaudit],[build audit daemon support for SELinux]),enable_libaudit=$enableval,enable_libaudit=auto)
......@@ -202,20 +203,10 @@ if test x$enable_userdb_cache = xyes; then
AC_DEFINE(DBUS_ENABLE_USERDB_CACHE,1,[Build with caching of user data])
fi
if test x$enable_gcov = xyes; then
if test x$enable_compiler_coverage = xyes; then
## so that config.h changes when you toggle gcov support
AC_DEFINE_UNQUOTED(DBUS_GCOV_ENABLED, 1, [Defined if gcov is enabled to force a rebuild due to config.h changing])
AC_MSG_CHECKING([for gcc 3.3 version of gcov file format])
have_gcc33_gcov=no
AC_RUN_IFELSE( [AC_LANG_PROGRAM( , [[ if (__GNUC__ >=3 && __GNUC_MINOR__ >= 3) exit (0); else exit (1); ]])],
have_gcc33_gcov=yes)
if test x$have_gcc33_gcov = xyes ; then
AC_DEFINE_UNQUOTED(DBUS_HAVE_GCC33_GCOV, 1, [Defined if we have gcc 3.3 and thus the new gcov format])
fi
AC_MSG_RESULT($have_gcc33_gcov)
fi
AM_CONDITIONAL(DBUS_GCOV_ENABLED, test x$enable_gcov = xyes)
# glibc21.m4 serial 3
dnl Copyright (C) 2000-2002, 2004 Free Software Foundation, Inc.
......@@ -1295,24 +1286,7 @@ if test "x$GCC" = "xyes"; then
*) CFLAGS="$CFLAGS -pedantic" ;;
esac
fi
if test x$enable_gcov = xyes; then
case " $CFLAGS " in
*[\ \ ]-fprofile-arcs[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -fprofile-arcs" ;;
esac
case " $CFLAGS " in
*[\ \ ]-ftest-coverage[\ \ ]*) ;;
*) CFLAGS="$CFLAGS -ftest-coverage" ;;
esac
## remove optimization
CFLAGS=`echo "$CFLAGS" | sed -e 's/-O[0-9]*//g'`
fi
changequote([,])dnl
else
if test x$enable_gcov = xyes; then
AC_MSG_ERROR([--enable-gcov can only be used with gcc])
fi
fi
AC_SUBST(PIC_CFLAGS)
......@@ -1704,7 +1678,7 @@ echo "
echo "
Maintainer mode: ${USE_MAINTAINER_MODE}
gcc coverage profiling: ${enable_gcov}
gcc coverage profiling: ${enable_compiler_coverage}
Building unit tests: ${enable_tests}
Building verbose mode: ${enable_verbose_mode}
Building assertions: ${enable_asserts}
......@@ -1743,7 +1717,7 @@ fi
if test x$enable_tests = xyes -a x$enable_asserts = xno; then
echo "NOTE: building with unit tests but without assertions means tests may not properly report failures (this configuration is only useful when doing something like profiling the tests)"
fi
if test x$enable_gcov = xyes; then
if test x$enable_compiler_coverage = xyes; then
echo "NOTE: building with coverage profiling is definitely for developers only."
fi
if test x$enable_verbose_mode = xyes; then
......
# compiler.m4 - autoconf macros for compiler settings
#
# Copyright © 2005 Scott James Remnant <scott@netsplit.com>.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be
# included in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
# ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
# CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
# COMPILER_WARNINGS
# ----------------------
# Add configure option to enable additional compiler warnings and treat
# them as errors.
AC_DEFUN([COMPILER_WARNINGS],
[AC_ARG_ENABLE(compiler-warnings,
AS_HELP_STRING([--enable-compiler-warnings],
[Enable additional compiler warnings]),
[if test "x$enable_compiler_warnings" = "xyes"; then
if test "x$GCC" = "xyes"; then
CFLAGS="-Wall -Werror $CFLAGS"
fi
if test "x$GXX" = "xyes"; then
CXXFLAGS="-Wall -Werror $CXXFLAGS"
fi
fi])dnl
])# COMPILER_WARNINGS
# COMPILER_OPTIMISATIONS
# ---------------------------
# Add configure option to disable optimisations.
AC_DEFUN([COMPILER_OPTIMISATIONS],
[AC_ARG_ENABLE(compiler-optimisations,
AS_HELP_STRING([--disable-compiler-optimisations],
[Disable compiler optimisations]),
[if test "x$enable_compiler_optimisations" = "xno"; then
[CFLAGS=`echo "$CFLAGS" | sed -e "s/ -O[1-9]*\b/ -O0/g"`]
fi])dnl
])# COMPILER_OPTIMISATIONS
# COMPILER_COVERAGE
# ----------------------
# Add configure option to enable coverage data.
AC_DEFUN([COMPILER_COVERAGE],
[AC_ARG_ENABLE(compiler-coverage,
AS_HELP_STRING([--enable-compiler-coverage],
[Enable generation of coverage data]),
[if test "x$enable_compiler_coverage" = "xyes"; then
if test "x$GCC" = "xyes"; then
CFLAGS="$CFLAGS -fprofile-arcs -ftest-coverage"
fi
fi])dnl
])# COMPILER_COVERAGE
......@@ -23,13 +23,7 @@ TEST_BINARIES=
TESTS=
endif
if DBUS_GCOV_ENABLED
GCOV_BINARIES=decode-gcov
else
GCOV_BINARIES=
endif
noinst_PROGRAMS= $(TEST_BINARIES) $(GCOV_BINARIES)
noinst_PROGRAMS= $(TEST_BINARIES)
test_service_SOURCES= \
test-service.c
......@@ -58,9 +52,6 @@ test_segfault_SOURCES = \
test_sleep_forever_SOURCES = \
test-sleep-forever.c
decode_gcov_SOURCES= \
decode-gcov.c
# When any programs are not linked to libdbus-internal, fix this.
AM_CPPFLAGS=-DDBUS_STATIC_BUILD
TEST_LIBS=$(top_builddir)/dbus/libdbus-internal.la $(DBUS_TEST_LIBS)
......@@ -77,8 +68,6 @@ shell_test_LDADD=libdbus-testutils.la $(TEST_LIBS)
shell_test_LDFLAGS=@R_DYNAMIC_LDFLAG@
spawn_test_LDADD=$(TEST_LIBS)
spawn_test_LDFLAGS=@R_DYNAMIC_LDFLAG@
decode_gcov_LDADD=$(TEST_LIBS)
decode_gcov_LDFLAGS=@R_DYNAMIC_LDFLAG@
EXTRA_DIST=
......
This diff is collapsed.
# Copyright © 2008-2011 Collabora Ltd.
# Copyright © 2008-2011 Nokia Corporation
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of this software and associated documentation files (the
# "Software"), to deal in the Software without restriction, including
# without limitation the rights to use, copy, modify, merge, publish,
# distribute, sublicense, and/or sell copies of the Software, and to
# permit persons to whom the Software is furnished to do so, subject to
# the following conditions:
#
# The above copyright notice and this permission notice shall be included
# in all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
# IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
# CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
# TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
# SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
lcov-reset:
lcov --directory @abs_top_srcdir@ --zerocounters
# gcov takes ~forever to process config-parser.c for some reason?
lcov-report:
true > bus/bus_test-config-parser.gcno
true > bus/dbus_daemon-config-parser.gcno
lcov --directory @abs_top_srcdir@ --capture \
--output-file @abs_top_builddir@/lcov.info
$(mkdir_p) @abs_top_builddir@/lcov.html
git_commit=`GIT_DIR=@abs_top_srcdir@/.git git log -1 --pretty=format:%h 2>/dev/null`;\
genhtml --title "@PACKAGE_STRING@ $$git_commit" \
--output-directory @abs_top_builddir@/lcov.html lcov.info
@echo
@echo 'lcov report can be found in:'
@echo 'file://@abs_top_builddir@/lcov.html/index.html'
@echo
lcov-check:
$(MAKE) lcov-reset
$(MAKE) check $(LCOV_CHECK_ARGS)
$(MAKE) lcov-report
## vim:set ft=automake:
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