]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tests: always use libdbus-internal for main loop, never dbus-glib
authorSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 20 Feb 2015 15:07:23 +0000 (15:07 +0000)
committerSimon McVittie <simon.mcvittie@collabora.co.uk>
Fri, 20 Feb 2015 20:49:32 +0000 (20:49 +0000)
This gets rid of a potential circular dependency, which is annoying
when bootstrapping. It is nice to have the regression tests use
the shared libdbus, but we're about to make it possible to
do that anyway, even though some of them use internal symbols.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=83115
Reviewed-by: Ralf Habacker <ralf.habacker@freenet.de>
cmake/CMakeLists.txt
test/Makefile.am
test/name-test/Makefile.am
test/test-utils.c
test/test-utils.h

index 45b7d06d865725c53f71f9ca60a999e9f0e66a1d..9a1be6c480f42e83a38b2f41ee76137959faaf7f 100644 (file)
@@ -481,7 +481,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 )
 
index 5d49b68e69a382b122d4eaf8d6eda1ba1b2e83b3..92fbdefb8c491cfcb4e5319e84245e2d15094e63 100644 (file)
@@ -9,7 +9,6 @@ AM_CPPFLAGS = \
        -I$(top_srcdir) \
        $(DBUS_STATIC_BUILD_CPPFLAGS) \
        $(GLIB_CFLAGS) \
-       $(DBUS_GLIB_CFLAGS) \
        $(NULL)
 
 # improve backtraces from test stuff
@@ -20,10 +19,9 @@ static_cppflags = \
        $(AM_CPPFLAGS) \
        -DDBUS_STATIC_BUILD \
        -DDBUS_COMPILATION \
-       -DDBUS_TEST_USE_INTERNAL \
        $(NULL)
 
-noinst_LTLIBRARIES = libdbus-testutils-internal.la
+noinst_LTLIBRARIES = libdbus-testutils.la
 
 libdbus_testutils_la_SOURCES = \
        test-utils.c \
@@ -37,30 +35,13 @@ libdbus_testutils_la_SOURCES += \
        $(NULL)
 endif
 
-# You can link either libdbus-testutils, dbus-glib and libdbus-1,
-# or libdbus-testutils-internal and libdbus-internal - never both in the
-# same binary.
-if DBUS_WITH_DBUS_GLIB
-noinst_LTLIBRARIES += libdbus-testutils.la
-libdbus_testutils_la_LIBADD = \
-       $(top_builddir)/dbus/libdbus-1.la \
-       $(GLIB_LIBS) \
-       $(DBUS_GLIB_LIBS) \
-       $(NULL)
-testutils_shared_if_possible_cppflags = $(AM_CPPFLAGS)
-testutils_shared_if_possible_libs = libdbus-testutils.la
-else
 testutils_shared_if_possible_cppflags = $(static_cppflags)
-testutils_shared_if_possible_libs = libdbus-testutils-internal.la
-endif
+testutils_shared_if_possible_libs = libdbus-testutils.la
 
-libdbus_testutils_internal_la_CPPFLAGS = \
+libdbus_testutils_la_CPPFLAGS = \
        $(static_cppflags) \
        $(NULL)
-libdbus_testutils_internal_la_SOURCES = \
-       $(libdbus_testutils_la_SOURCES) \
-       $(NULL)
-libdbus_testutils_internal_la_LIBADD = \
+libdbus_testutils_la_LIBADD = \
        $(top_builddir)/dbus/libdbus-internal.la \
        $(NULL)
 
@@ -100,16 +81,16 @@ endif !DBUS_ENABLE_EMBEDDED_TESTS
 noinst_PROGRAMS= $(TEST_BINARIES)
 
 test_service_CPPFLAGS = $(static_cppflags)
-test_service_LDADD = libdbus-testutils-internal.la
+test_service_LDADD = libdbus-testutils.la
 test_names_CPPFLAGS = $(static_cppflags)
-test_names_LDADD = libdbus-testutils-internal.la
+test_names_LDADD = libdbus-testutils.la
 ## break_loader_CPPFLAGS = $(static_cppflags)
 ## break_loader_LDADD = $(top_builddir)/dbus/libdbus-internal.la
 test_shell_service_CPPFLAGS = $(static_cppflags)
-test_shell_service_LDADD = libdbus-testutils-internal.la
+test_shell_service_LDADD = libdbus-testutils.la
 test_shell_SOURCES = shell-test.c
 test_shell_CPPFLAGS = $(static_cppflags)
-test_shell_LDADD = libdbus-testutils-internal.la
+test_shell_LDADD = libdbus-testutils.la
 test_spawn_SOURCES = spawn-test.c
 test_spawn_CPPFLAGS = $(static_cppflags)
 test_spawn_LDADD = $(top_builddir)/dbus/libdbus-internal.la
@@ -120,11 +101,11 @@ test_printf_LDADD = $(top_builddir)/dbus/libdbus-internal.la
 
 test_refs_SOURCES = internals/refs.c
 test_refs_CPPFLAGS = $(static_cppflags)
-test_refs_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS)
+test_refs_LDADD = libdbus-testutils.la $(GLIB_LIBS)
 
 test_syslog_SOURCES = internals/syslog.c
 test_syslog_CPPFLAGS = $(static_cppflags)
-test_syslog_LDADD = libdbus-testutils-internal.la $(GLIB_LIBS)
+test_syslog_LDADD = libdbus-testutils.la $(GLIB_LIBS)
 
 manual_dir_iter_SOURCES = manual-dir-iter.c
 manual_dir_iter_CPPFLAGS = $(static_cppflags)
@@ -288,7 +269,7 @@ test_fdpass_CPPFLAGS = \
     $(static_cppflags) \
     $(NULL)
 test_fdpass_LDADD = \
-    libdbus-testutils-internal.la \
+    libdbus-testutils.la \
     $(GLIB_LIBS) \
     $(NULL)
 
index 8ed1e1604cdfb866ae7ee8352a2183ac96c74c7a..8df98990335828772305406cf259bd357e2c9c5a 100644 (file)
@@ -3,7 +3,6 @@ AM_CPPFLAGS = \
        -I$(top_srcdir) \
        -DDBUS_COMPILATION \
        -DDBUS_STATIC_BUILD \
-       -DDBUS_TEST_USE_INTERNAL \
        $(NULL)
 
 # if assertions are enabled, improve backtraces
@@ -40,9 +39,9 @@ test_pending_call_timeout_LDADD=$(top_builddir)/dbus/libdbus-internal.la
 test_threads_init_LDADD=$(top_builddir)/dbus/libdbus-internal.la
 test_ids_LDADD=$(top_builddir)/dbus/libdbus-internal.la
 
-test_shutdown_LDADD=../libdbus-testutils-internal.la
-test_privserver_LDADD=../libdbus-testutils-internal.la
-test_privserver_client_LDADD=../libdbus-testutils-internal.la
-test_autolaunch_LDADD=../libdbus-testutils-internal.la
+test_shutdown_LDADD=../libdbus-testutils.la
+test_privserver_LDADD=../libdbus-testutils.la
+test_privserver_client_LDADD=../libdbus-testutils.la
+test_autolaunch_LDADD=../libdbus-testutils.la
 
 endif
index 9686a9a8b9ff1edc62776c8ea6c5273ebb277487..cb6cf1fb71f36d673d145b53aa181ec65c130487 100644 (file)
@@ -1,21 +1,6 @@
 #include <config.h>
 #include "test-utils.h"
 
-#ifndef DBUS_TEST_USE_INTERNAL
-# include <dbus/dbus.h>
-# include <dbus/dbus-glib-lowlevel.h>
-#endif
-
-#ifdef DBUS_TEST_USE_INTERNAL
-# define test_assert(x) _dbus_assert(x)
-#elif defined(g_assert_true)
-# define test_assert(x) g_assert_true(x)
-#else
-# define test_assert(x) g_assert(x)
-#endif
-
-#ifdef DBUS_TEST_USE_INTERNAL
-
 typedef struct
 {
   DBusLoop *loop;
@@ -112,13 +97,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;
 
@@ -167,12 +149,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
@@ -203,8 +179,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;
@@ -286,13 +260,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;
 
@@ -331,13 +302,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
@@ -362,41 +326,24 @@ 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
 }
 
 void
@@ -406,5 +353,5 @@ test_pending_call_store_reply (DBusPendingCall *pc,
   DBusMessage **message_p = data;
 
   *message_p = dbus_pending_call_steal_reply (pc);
-  test_assert (*message_p != NULL);
+  _dbus_assert (*message_p != NULL);
 }
index b526e927cd653f908b58252508c601822f3ee2e8..39fae77b119493b67bb9fa9a3c4f4dbd42281c75 100644 (file)
@@ -6,18 +6,9 @@
 
 #include <dbus/dbus.h>
 
-#ifdef DBUS_TEST_USE_INTERNAL
-
-# include <dbus/dbus-mainloop.h>
-# include <dbus/dbus-internals.h>
-  typedef DBusLoop TestMainContext;
-
-#else /* !DBUS_TEST_USE_INTERNAL */
-
-# include <glib.h>
-  typedef GMainContext TestMainContext;
-
-#endif /* !DBUS_TEST_USE_INTERNAL */
+#include <dbus/dbus-mainloop.h>
+#include <dbus/dbus-internals.h>
+typedef DBusLoop TestMainContext;
 
 TestMainContext *test_main_context_get            (void);
 TestMainContext *test_main_context_ref            (TestMainContext *ctx);