From a945af14b8f24abafe328d7bb8fe4393bd0fec26 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Thu, 11 Sep 2014 16:52:30 +0100 Subject: [PATCH 4/4] Remove support for using dbus-glib for the regression tests This was an annoying circular dependency, and doesn't actually work any more now that tests are relying on being able to see private symbols in the just-compiled libdbus. Use DBusLoop unconditionally instead. --- cmake/CMakeLists.txt | 2 +- configure.ac | 19 +------------------ test/Makefile.am | 38 +------------------------------------- test/name-test/Makefile.am | 1 - test/test-utils.c | 44 -------------------------------------------- test/test-utils.h | 15 +++------------ 6 files changed, 6 insertions(+), 113 deletions(-) diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 41882d7..819838b 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -488,7 +488,7 @@ set (DBUS_INTERNAL_ADD_LIBRARY_OPTIONS STATIC) set (DBUS_INTERNAL_LIBRARY_DEFINITIONS "-DDBUS_STATIC_BUILD") # For now, the CMake build system doesn't support replacing the internal # main loop with dbus-glib -set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD -DDBUS_COMPILATION -DDBUS_TEST_USE_INTERNAL") +set (DBUS_INTERNAL_CLIENT_DEFINITIONS "-DDBUS_STATIC_BUILD -DDBUS_COMPILATION") configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h ) diff --git a/configure.ac b/configure.ac index 0490cc8..d90a165 100644 --- a/configure.ac +++ b/configure.ac @@ -188,7 +188,7 @@ AC_ARG_ENABLE([tests], [ if test "x$enableval" = xyes; then AC_MSG_NOTICE([Full test coverage was requested with --enable-tests=yes]) - AC_MSG_NOTICE([This has many dependencies (GLib, dbus-glib, Python)]) + AC_MSG_NOTICE([This has many dependencies (GLib, Python)]) fi enable_embedded_tests=$enableval enable_modular_tests=$enableval @@ -227,22 +227,6 @@ AS_IF([test "x$enable_modular_tests" != xno], ], [with_glib=no]) -# Not required, because we can use internal APIs (but that makes the -# "installable tests" less useful as integration tests) -AC_ARG_WITH([dbus_glib], - [AS_HELP_STRING([--with-dbus-glib], [Use dbus-glib for regression tests])], - [], - [with_dbus_glib=auto]) -AS_IF([test "x$with_dbus_glib" != xno], - [PKG_CHECK_MODULES([DBUS_GLIB], [dbus-glib-1], - [], - [AS_IF([test "x$with_dbus_glib" = xyes], - dnl specifically requested, but not found - [AC_MSG_ERROR([$DBUS_GLIB_ERRORS])], - dnl else: assumed to be "auto" - [with_dbus_glib=no])])]) -AM_CONDITIONAL([DBUS_WITH_DBUS_GLIB], [test "x$with_dbus_glib" != xno]) - if test "x$enable_modular_tests" != xno; then AC_DEFINE([DBUS_ENABLE_MODULAR_TESTS], [1], [Define to build independent test binaries]) @@ -1839,7 +1823,6 @@ echo " Building embedded tests: ${enable_embedded_tests} Building modular tests: ${enable_modular_tests} - with GLib: ${with_glib} - - with dbus-glib: ${with_dbus_glib} Building verbose mode: ${enable_verbose_mode} Building assertions: ${enable_asserts} Building checks: ${enable_checks} diff --git a/test/Makefile.am b/test/Makefile.am index 068e33a..c7ba3e2 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -7,20 +7,13 @@ DIST_SUBDIRS=name-test # CPPFLAGS for binaries that only use public libdbus interfaces AM_CPPFLAGS = \ -I$(top_srcdir) \ + -DDBUS_COMPILATION \ $(GLIB_CFLAGS) \ - $(DBUS_GLIB_CFLAGS) \ $(NULL) # improve backtraces from test stuff AM_LDFLAGS = @R_DYNAMIC_LDFLAG@ -# CPPFLAGS for binaries that use libdbus internals, and used to be static -internal_cppflags = \ - $(AM_CPPFLAGS) \ - -DDBUS_COMPILATION \ - -DDBUS_TEST_USE_INTERNAL \ - $(NULL) - noinst_LTLIBRARIES = libdbus-testutils.la libdbus_testutils_la_SOURCES = \ test-utils.c \ @@ -31,19 +24,6 @@ libdbus_testutils_la_LIBADD = \ $(top_builddir)/dbus/libdbus-internal.la \ $(NULL) -if DBUS_WITH_DBUS_GLIB -libdbus_testutils_la_LIBADD += \ - $(GLIB_LIBS) \ - $(DBUS_GLIB_LIBS) \ - $(NULL) - -testutils_shared_if_possible_cppflags = $(AM_CPPFLAGS) -else -testutils_shared_if_possible_cppflags = $(internal_cppflags) -endif - -libdbus_testutils_la_CPPFLAGS = $(testutils_shared_if_possible_cppflags) - if DBUS_ENABLE_EMBEDDED_TESTS ## break-loader removed for now ## these binaries are used in tests but are not themselves tests @@ -79,35 +59,25 @@ endif !DBUS_ENABLE_EMBEDDED_TESTS noinst_PROGRAMS= $(TEST_BINARIES) -test_service_CPPFLAGS = $(internal_cppflags) test_service_LDADD = libdbus-testutils.la -test_names_CPPFLAGS = $(internal_cppflags) test_names_LDADD = libdbus-testutils.la -## break_loader_CPPFLAGS = $(internal_cppflags) ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la -test_shell_service_CPPFLAGS = $(internal_cppflags) test_shell_service_LDADD = libdbus-testutils.la test_shell_SOURCES = shell-test.c -test_shell_CPPFLAGS = $(internal_cppflags) test_shell_LDADD = libdbus-testutils.la test_spawn_SOURCES = spawn-test.c -test_spawn_CPPFLAGS = $(internal_cppflags) test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la test_printf_SOURCES = internals/printf.c -test_printf_CPPFLAGS = $(internal_cppflags) test_printf_LDADD = $(top_builddir)/dbus/libdbus-1.la test_refs_SOURCES = internals/refs.c -test_refs_CPPFLAGS = $(internal_cppflags) test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS) test_syslog_SOURCES = internals/syslog.c -test_syslog_CPPFLAGS = $(internal_cppflags) test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS) manual_dir_iter_SOURCES = manual-dir-iter.c -manual_dir_iter_CPPFLAGS = $(internal_cppflags) manual_dir_iter_LDADD = $(top_builddir)/dbus/libdbus-internal.la EXTRA_DIST = dbus-test-runner @@ -162,27 +132,21 @@ testutils_with_glib = \ $(NULL) manual_authz_SOURCES = manual-authz.c -manual_authz_CPPFLAGS = $(testutils_shared_if_possible_cppflags) manual_authz_LDADD = $(testutils_with_glib) test_corrupt_SOURCES = corrupt.c -test_corrupt_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_corrupt_LDADD = $(testutils_with_glib) test_loopback_SOURCES = loopback.c -test_loopback_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_loopback_LDADD = $(testutils_with_glib) test_relay_SOURCES = relay.c -test_relay_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_relay_LDADD = $(testutils_with_glib) test_dbus_daemon_SOURCES = dbus-daemon.c -test_dbus_daemon_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_dbus_daemon_LDADD = $(testutils_with_glib) test_dbus_daemon_eavesdrop_SOURCES = dbus-daemon-eavesdrop.c -test_dbus_daemon_eavesdrop_CPPFLAGS = $(testutils_shared_if_possible_cppflags) test_dbus_daemon_eavesdrop_LDADD = $(testutils_with_glib) test_marshal_SOURCES = marshal.c diff --git a/test/name-test/Makefile.am b/test/name-test/Makefile.am index 29fa2d3..b28a7e8 100644 --- a/test/name-test/Makefile.am +++ b/test/name-test/Makefile.am @@ -1,7 +1,6 @@ AM_CPPFLAGS = \ -I$(top_srcdir) \ -DDBUS_COMPILATION \ - -DDBUS_TEST_USE_INTERNAL \ $(NULL) # if assertions are enabled, improve backtraces diff --git a/test/test-utils.c b/test/test-utils.c index 9a4f358..b8278f3 100644 --- a/test/test-utils.c +++ b/test/test-utils.c @@ -1,12 +1,6 @@ #include #include "test-utils.h" -#ifndef DBUS_TEST_USE_INTERNAL -# include -# include -#endif - -#ifdef DBUS_TEST_USE_INTERNAL typedef struct { @@ -104,13 +98,10 @@ cdata_new (DBusLoop *loop, return cd; } -#endif /* DBUS_TEST_USE_INTERNAL */ - dbus_bool_t test_connection_setup (TestMainContext *ctx, DBusConnection *connection) { -#ifdef DBUS_TEST_USE_INTERNAL DBusLoop *loop = ctx; CData *cd; @@ -159,12 +150,6 @@ test_connection_setup (TestMainContext *ctx, dbus_connection_set_timeout_functions (connection, NULL, NULL, NULL, NULL, NULL); return FALSE; -#else /* !DBUS_TEST_USE_INTERNAL */ - - dbus_connection_setup_with_g_main (connection, ctx); - return TRUE; - -#endif /* !DBUS_TEST_USE_INTERNAL */ } static void @@ -195,8 +180,6 @@ test_connection_shutdown (TestMainContext *ctx, dbus_connection_set_dispatch_status_function (connection, NULL, NULL, NULL); } -#ifdef DBUS_TEST_USE_INTERNAL - typedef struct { DBusLoop *loop; @@ -278,13 +261,10 @@ remove_server_timeout (DBusTimeout *timeout, _dbus_loop_remove_timeout (context->loop, timeout); } -#endif /* DBUS_TEST_USE_INTERNAL */ - dbus_bool_t test_server_setup (TestMainContext *ctx, DBusServer *server) { -#ifdef DBUS_TEST_USE_INTERNAL DBusLoop *loop = ctx; ServerData *sd; @@ -323,13 +303,6 @@ test_server_setup (TestMainContext *ctx, test_server_shutdown (loop, server); return FALSE; - -#else /* !DBUS_TEST_USE_INTERNAL */ - - dbus_server_setup_with_g_main (server, ctx); - return TRUE; - -#endif /* !DBUS_TEST_USE_INTERNAL */ } void @@ -354,39 +327,22 @@ test_server_shutdown (TestMainContext *ctx, TestMainContext * test_main_context_get (void) { -#ifdef DBUS_TEST_USE_INTERNAL return _dbus_loop_new (); -#else - /* I suspect dbus-glib relies the default main context in some places */ - return g_main_context_ref (g_main_context_default ()); -#endif } TestMainContext * test_main_context_ref (TestMainContext *ctx) { -#ifdef DBUS_TEST_USE_INTERNAL return _dbus_loop_ref (ctx); -#else - return g_main_context_ref (ctx); -#endif } void test_main_context_unref (TestMainContext *ctx) { -#ifdef DBUS_TEST_USE_INTERNAL _dbus_loop_unref (ctx); -#else - g_main_context_unref (ctx); -#endif } void test_main_context_iterate (TestMainContext *ctx, dbus_bool_t may_block) { -#ifdef DBUS_TEST_USE_INTERNAL _dbus_loop_iterate (ctx, may_block); -#else - g_main_context_iteration (ctx, may_block); -#endif } diff --git a/test/test-utils.h b/test/test-utils.h index 0d3f369..2ac9c17 100644 --- a/test/test-utils.h +++ b/test/test-utils.h @@ -6,18 +6,9 @@ #include -#ifdef DBUS_TEST_USE_INTERNAL - -# include -# include - typedef DBusLoop TestMainContext; - -#else /* !DBUS_TEST_USE_INTERNAL */ - -# include - typedef GMainContext TestMainContext; - -#endif /* !DBUS_TEST_USE_INTERNAL */ +#include +#include +typedef DBusLoop TestMainContext; TestMainContext *test_main_context_get (void); TestMainContext *test_main_context_ref (TestMainContext *ctx); -- 2.1.0