Commit 90f36efb authored by Simon McVittie's avatar Simon McVittie

Add support for building "modular" tests, which require GLib and dbus-glib

For the moment, the CMake build system only knows about the existing
"embedded tests"; make it define both symbols, though.

We use GLib because it has GTester (and life's too short to write yet another
JUnit clone), and dbus-glib for the main-loop integration only (see
fd.o #31515 for thoughts on incorporating just those two functions in a
separate library in the dbus tarball).

I'm not using DBusLoop for the main loop because I specifically don't
want to use non-public API or ABI of libdbus in the modular tests. If we make
sure they work against a shared libdbus, we can use them to test the
installed system, with "make installcheck".
Reviewed-by: default avatarWill Thompson <will.thompson@collabora.co.uk>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=34570
parent 77e208ac
......@@ -226,7 +226,7 @@ ENABLE_TESTING()
OPTION(DBUS_BUILD_TESTS "enable unit test code" ON)
if(DBUS_BUILD_TESTS)
add_definitions(-DDBUS_BUILD_TESTS)
add_definitions(-DDBUS_BUILD_TESTS -DDBUS_ENABLE_EMBEDDED_TESTS)
endif(DBUS_BUILD_TESTS)
OPTION(DBUS_USE_OUTPUT_DEBUG_STRING "enable win32 debug port for message output" OFF)
......
......@@ -122,7 +122,6 @@ AM_CONDITIONAL(DBUS_WINCE, test "$dbus_wince" = yes)
AM_CONDITIONAL(DBUS_UNIX, test "$dbus_unix" = yes)
AM_CONDITIONAL(DBUS_CYGWIN, test "$dbus_cygwin" = yes)
AC_ARG_ENABLE(tests, AS_HELP_STRING([--enable-tests],[enable unit test code in the library and binaries]),enable_tests=$enableval,enable_tests=$USE_MAINTAINER_MODE)
AC_ARG_ENABLE(ansi, AS_HELP_STRING([--enable-ansi],[enable -ansi -pedantic gcc flags]),enable_ansi=$enableval,enable_ansi=no)
AC_ARG_ENABLE(verbose-mode, AS_HELP_STRING([--enable-verbose-mode],[support verbose debug mode]),enable_verbose_mode=$enableval,enable_verbose_mode=$USE_MAINTAINER_MODE)
AC_ARG_ENABLE(asserts, AS_HELP_STRING([--enable-asserts],[include assertion checks]),enable_asserts=$enableval,enable_asserts=$USE_MAINTAINER_MODE)
......@@ -151,12 +150,66 @@ AC_ARG_WITH(launchd-agent-dir, AS_HELP_STRING([--with-launchd-agent-dir=[dirname
AC_ARG_WITH(dbus_user, AS_HELP_STRING([--with-dbus-user=<user>],[User for running the DBUS daemon (messagebus)]))
AC_ARG_WITH(dbus_daemondir, AS_HELP_STRING([--with-dbus-daemondir=[dirname]],[Directory for installing the DBUS daemon]))
dnl DBUS_BUILD_TESTS controls unit tests built in to .c files
dnl and also some stuff in the test/ subdir
AM_CONDITIONAL(DBUS_BUILD_TESTS, test x$enable_tests = xyes)
if test x$enable_tests = xyes; then
AC_DEFINE(DBUS_BUILD_TESTS,1,[Build test code])
AC_ARG_ENABLE([embedded-tests],
AS_HELP_STRING([--enable-embedded-tests],
[enable unit test code in the library and binaries]),
[], [enable_embedded_tests=$USE_MAINTAINER_MODE])
AC_ARG_ENABLE([modular-tests],
AS_HELP_STRING([--enable-modular-tests],
[enable modular regression tests (requires GLib)]),
[], [enable_modular_tests=auto])
# --enable-tests overrides both --enable-embedded-tests and
# --enable-modular-tests
AC_ARG_ENABLE([tests],
AS_HELP_STRING([--enable-tests],
[enable/disable all tests, overriding embedded-tests/modular-tests]),
[enable_embedded_tests=$enableval; enable_modular_tests=$enableval],
[])
# DBUS_ENABLE_EMBEDDED_TESTS controls unit tests built in to .c files
# and also some stuff in the test/ subdir. DBUS_BUILD_TESTS was an older
# name for this.
AM_CONDITIONAL([DBUS_BUILD_TESTS], [test "x$enable_embedded_tests" = xyes])
AM_CONDITIONAL([DBUS_ENABLE_EMBEDDED_TESTS],
[test "x$enable_embedded_tests" = xyes])
if test "x$enable_embedded_tests" = xyes; then
AC_DEFINE([DBUS_ENABLE_EMBEDDED_TESTS], [1],
[Define to build test code into the library and binaries])
AC_DEFINE([DBUS_BUILD_TESTS], [1],
[Define to build test code into the library and binaries])
fi
# DBUS_ENABLE_MODULAR_TESTS controls tests that work based on public API.
# These use GTest, from GLib, because life's too short. They're enabled by
# default (unless you don't have GLib), because they don't bloat the library
# or binaries.
if test "x$enable_modular_tests" != xno; then
PKG_CHECK_MODULES([GLIB], [glib-2.0 >= 2.18],
[],
[if test "x$enable_modular_tests" = xyes; then
AC_MSG_ERROR([GLib is required by the modular tests])
else # assumed to be "auto"
enable_modular_tests=no
fi])
# If dbus-gmain.[ch] returned to libdbus then we wouldn't need this
PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1],
[],
[if test "x$enable_modular_tests" = xyes; then
AC_MSG_ERROR([dbus-glib is required by the modular tests (for now)])
else # assumed to be "auto"
enable_modular_tests=no
fi])
if test "x$enable_modular_tests" != xno; then
# dependencies checked, switch from auto to yes
enable_modular_tests=yes
fi
fi
if test "x$enable_modular_tests" = xyes; then
AC_DEFINE([DBUS_ENABLE_MODULAR_TESTS], [1],
[Define to build independent test binaries (requires GLib)])
fi
AM_CONDITIONAL([DBUS_ENABLE_MODULAR_TESTS],
[test "x$enable_modular_tests" = xyes])
if test x$enable_verbose_mode = xyes; then
AC_DEFINE(DBUS_ENABLE_VERBOSE_MODE,1,[Support a verbose mode])
......@@ -1543,7 +1596,8 @@ echo "
echo "
Maintainer mode: ${USE_MAINTAINER_MODE}
gcc coverage profiling: ${enable_compiler_coverage}
Building unit tests: ${enable_tests}
Building embedded tests: ${enable_embedded_tests}
Building modular tests: ${enable_modular_tests}
Building verbose mode: ${enable_verbose_mode}
Building assertions: ${enable_asserts}
Building checks: ${enable_checks}
......@@ -1575,11 +1629,11 @@ if test x$have_launchd = xyes; then
fi
echo
if test x$enable_tests = xyes; then
if test x$enable_embedded_tests = xyes; then
echo "NOTE: building with unit tests increases the size of the installed library and renders it insecure."
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)"
if test x$enable_embedded_tests = xyes -a x$enable_asserts = xno; then
echo "NOTE: building with embedded 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_compiler_coverage = xyes; then
echo "NOTE: building with coverage profiling is definitely for developers only."
......
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