mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-01-03 11:30:27 +01:00
tests: always use libdbus-internal for main loop, never dbus-glib
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>
This commit is contained in:
parent
267c69ac90
commit
dbd731491b
5 changed files with 20 additions and 102 deletions
|
|
@ -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 )
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue