mirror of
https://gitlab.freedesktop.org/dbus/dbus.git
synced 2026-05-09 08:28:02 +02:00
Add a common test_init() for GLib tests which prevents hanging forever
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=46787 Reviewed-by: Philip Withnall <philip.withnall@collabora.co.uk>
This commit is contained in:
parent
1a28f82926
commit
94610d7de6
17 changed files with 54 additions and 30 deletions
|
|
@ -77,7 +77,7 @@ if(DBUS_WITH_GLIB)
|
|||
${CMAKE_SOURCE_DIR}/../test/test-utils-glib.h
|
||||
${CMAKE_SOURCE_DIR}/../test/test-utils-glib.c
|
||||
)
|
||||
target_link_libraries(dbus-testutils-glib ${DBUS_INTERNAL_LIBRARIES})
|
||||
target_link_libraries(dbus-testutils-glib dbus-testutils ${DBUS_INTERNAL_LIBRARIES})
|
||||
|
||||
add_definitions(
|
||||
${GLIB2_DEFINITIONS}
|
||||
|
|
|
|||
|
|
@ -242,7 +242,7 @@ test_sd_activation_LDADD = \
|
|||
|
||||
test_marshal_SOURCES = marshal.c
|
||||
test_marshal_LDADD = \
|
||||
$(top_builddir)/dbus/libdbus-1.la \
|
||||
$(testutils_shared_if_possible_libs) \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
|
@ -257,7 +257,7 @@ test_monitor_LDADD = \
|
|||
|
||||
test_syntax_SOURCES = syntax.c
|
||||
test_syntax_LDADD = \
|
||||
$(top_builddir)/dbus/libdbus-1.la \
|
||||
$(testutils_shared_if_possible_libs) \
|
||||
$(GLIB_LIBS) \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "test-utils.h"
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
typedef struct {
|
||||
DBusError e;
|
||||
|
|
@ -379,7 +379,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/corrupt/tcp", Fixture, "tcp:host=127.0.0.1", setup,
|
||||
test_corrupt, teardown);
|
||||
|
|
|
|||
|
|
@ -413,8 +413,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/eavedrop/match_keyword/broadcast", Fixture, NULL,
|
||||
setup, test_eavesdrop_broadcast, teardown);
|
||||
|
|
|
|||
|
|
@ -608,8 +608,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/echo/session", Fixture, NULL, setup, test_echo, teardown);
|
||||
g_test_add ("/echo/limited", Fixture, &limited_config,
|
||||
|
|
|
|||
|
|
@ -807,8 +807,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/relay", Fixture, NULL, setup,
|
||||
test_relay, teardown);
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
#include <dbus/dbus-message-internal.h>
|
||||
#include <dbus/dbus-pending-call-internal.h>
|
||||
#include <dbus/dbus-server-protected.h>
|
||||
#include "test-utils.h"
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
static void
|
||||
assert_no_error (const DBusError *e)
|
||||
|
|
@ -585,8 +585,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/refs/connection", Fixture, NULL, setup_connection,
|
||||
test_connection, teardown);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@
|
|||
#include <dbus/dbus.h>
|
||||
#include <dbus/dbus-sysdeps.h>
|
||||
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
typedef struct {
|
||||
int dummy;
|
||||
} Fixture;
|
||||
|
|
@ -93,8 +95,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/syslog", Fixture, NULL, setup, test_syslog, teardown);
|
||||
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include <string.h>
|
||||
|
||||
#include "test-utils.h"
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
typedef struct {
|
||||
TestMainContext *ctx;
|
||||
|
|
@ -255,8 +255,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/connect/tcp", Fixture, "tcp:host=127.0.0.1", setup,
|
||||
test_connect, teardown);
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@
|
|||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
typedef struct {
|
||||
DBusError e;
|
||||
} Fixture;
|
||||
|
|
@ -248,7 +250,7 @@ main (int argc,
|
|||
char *aligned_le_blob;
|
||||
char *aligned_be_blob;
|
||||
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
test_init (&argc, &argv);
|
||||
|
||||
/* We have to pass in a buffer that's at least "default aligned",
|
||||
* i.e. on GNU systems to 8 or 16. The linker may have only given
|
||||
|
|
|
|||
|
|
@ -1461,8 +1461,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/monitor/become", Fixture, &side_effects_config,
|
||||
setup, test_become_monitor, teardown);
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "test-utils.h"
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
/* This is basically a miniature dbus-daemon. We relay messages from the client
|
||||
* on the left to the client on the right.
|
||||
|
|
@ -313,8 +313,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/connect", Fixture, NULL, setup,
|
||||
test_connect, teardown);
|
||||
|
|
|
|||
|
|
@ -309,8 +309,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/sd-activation", Fixture, NULL,
|
||||
setup, test_activation, teardown);
|
||||
|
|
|
|||
|
|
@ -30,6 +30,8 @@
|
|||
|
||||
#include <dbus/dbus.h>
|
||||
|
||||
#include "test-utils-glib.h"
|
||||
|
||||
typedef struct {
|
||||
DBusError e;
|
||||
} Fixture;
|
||||
|
|
@ -269,7 +271,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/syntax/path", Fixture, &paths, setup, test_syntax, teardown);
|
||||
g_test_add ("/syntax/interface", Fixture, &interfaces,
|
||||
|
|
|
|||
|
|
@ -385,3 +385,29 @@ test_kill_pid (GPid pid)
|
|||
kill (pid, SIGTERM);
|
||||
#endif
|
||||
}
|
||||
|
||||
static gboolean
|
||||
time_out (gpointer data)
|
||||
{
|
||||
g_error ("timed out");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
void
|
||||
test_init (int *argcp, char ***argvp)
|
||||
{
|
||||
g_test_init (argcp, argvp, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
|
||||
/* Prevent tests from hanging forever. This is intended to be long enough
|
||||
* that any reasonable regression test on any reasonable hardware would
|
||||
* have finished. */
|
||||
#define TIMEOUT 60
|
||||
|
||||
g_timeout_add_seconds (TIMEOUT, time_out, NULL);
|
||||
#ifdef G_OS_UNIX
|
||||
/* The GLib main loop might not be running (we don't use it in every
|
||||
* test). Die with SIGALRM shortly after if necessary. */
|
||||
alarm (TIMEOUT + 10);
|
||||
#endif
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,4 +79,6 @@ DBusConnection *test_connect_to_bus_as_user (TestMainContext *ctx,
|
|||
|
||||
void test_kill_pid (GPid pid);
|
||||
|
||||
void test_init (int *argcp, char ***argvp);
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -186,8 +186,7 @@ int
|
|||
main (int argc,
|
||||
char **argv)
|
||||
{
|
||||
g_test_init (&argc, &argv, NULL);
|
||||
g_test_bug_base ("https://bugs.freedesktop.org/show_bug.cgi?id=");
|
||||
test_init (&argc, &argv);
|
||||
|
||||
g_test_add ("/uid-permissions/uae/root", Fixture, &root_ok_config,
|
||||
setup, test_uae, teardown);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue