f->right_conn = dbus_bus_get_private (DBUS_BUS_SESSION, &f->e);
test_assert_no_error (&f->e);
- if (!test_connection_setup (f->ctx, f->right_conn))
- g_error ("OOM");
+ test_connection_setup (f->ctx, f->right_conn);
}
else
{
dbus_server_set_new_connection_function (f->server,
new_conn_cb, f, NULL);
- if (!test_server_setup (f->loop, f->server))
- g_error ("failed to set up server");
+ test_server_setup (f->loop, f->server);
address = dbus_server_get_address (f->server);
g_assert (address != NULL);
g_assert (f->connection != NULL);
dbus_free (address);
- if (!test_connection_setup (f->loop, f->connection))
- g_error ("failed to set up connection");
+ test_connection_setup (f->loop, f->connection);
while (f->server_connection == NULL)
_dbus_loop_iterate (f->loop, TRUE);
{
TestServiceData *testdata = data;
- if (!test_connection_setup (testdata->loop, new_connection))
+ if (!test_connection_try_setup (testdata->loop, new_connection))
dbus_connection_close (new_connection);
}
dbus_server_set_new_connection_function (server, new_connection_callback,
testdata, NULL);
- if (!test_server_setup (loop, server))
- die ("server setup failed");
+ test_server_setup (loop, server);
fprintf (stderr, "server running mainloop\n");
_dbus_loop_run (loop);
if (loop == NULL)
die ("No memory\n");
- if (!test_connection_setup (loop, connection))
- die ("No memory\n");
+ test_connection_setup (loop, connection);
test_connection_shutdown (loop, connection);
if (loop == NULL)
die ("No memory\n");
- if (!test_connection_setup (loop, connection))
- die ("No memory\n");
+ test_connection_setup (loop, connection);
TestName(connection, "org.freedesktop.DBus.Test", TRUE);
TestName(connection, "org.freedesktop.DBus.Test-2", TRUE);
loop = _dbus_loop_new ();
if (loop == NULL)
die ("No memory\n");
-
- if (!test_connection_setup (loop, connection))
- die ("No memory\n");
+
+ test_connection_setup (loop, connection);
if (!dbus_connection_add_filter (connection,
filter_func, NULL, NULL))
loop = _dbus_loop_new ();
if (loop == NULL)
die ("No memory\n");
-
- if (!test_connection_setup (loop, connection))
- die ("No memory\n");
+
+ test_connection_setup (loop, connection);
if (!dbus_connection_add_filter (connection,
filter_func, NULL, NULL))
g_assert (dbus_bus_get_unique_name (conn) != NULL);
- if (!test_connection_setup (ctx, conn))
+ if (!test_connection_try_setup (ctx, conn))
{
_DBUS_SET_OOM (&error);
goto fail;
}
dbus_bool_t
-test_connection_setup (TestMainContext *ctx,
- DBusConnection *connection)
+test_connection_try_setup (TestMainContext *ctx,
+ DBusConnection *connection)
{
DBusLoop *loop = ctx;
CData *cd;
exit (1);
}
+void
+test_connection_setup (TestMainContext *ctx,
+ DBusConnection *connection)
+{
+ if (!test_connection_try_setup (ctx, connection))
+ die ("Not enough memory to set up connection");
+}
+
void
test_connection_shutdown (TestMainContext *ctx,
DBusConnection *connection)
}
dbus_bool_t
-test_server_setup (TestMainContext *ctx,
- DBusServer *server)
+test_server_try_setup (TestMainContext *ctx,
+ DBusServer *server)
{
DBusLoop *loop = ctx;
ServerData *sd;
return FALSE;
}
+void
+test_server_setup (TestMainContext *ctx,
+ DBusServer *server)
+{
+ if (!test_server_try_setup (ctx, server))
+ die ("Not enough memory to set up server");
+}
+
void
test_server_shutdown (TestMainContext *ctx,
DBusServer *server)
TestMainContext *
test_main_context_get (void)
+{
+ TestMainContext *ret = _dbus_loop_new ();
+
+ if (ret == NULL)
+ die ("Out of memory");
+
+ return ret;
+}
+
+TestMainContext *
+test_main_context_try_get (void)
{
return _dbus_loop_new ();
}
#include <dbus/dbus-internals.h>
typedef DBusLoop TestMainContext;
+_DBUS_GNUC_WARN_UNUSED_RESULT
TestMainContext *test_main_context_get (void);
+_DBUS_GNUC_WARN_UNUSED_RESULT
+TestMainContext *test_main_context_try_get (void);
TestMainContext *test_main_context_ref (TestMainContext *ctx);
void test_main_context_unref (TestMainContext *ctx);
void test_main_context_iterate (TestMainContext *ctx,
dbus_bool_t may_block);
-dbus_bool_t test_connection_setup (TestMainContext *ctx,
+_DBUS_GNUC_WARN_UNUSED_RESULT
+dbus_bool_t test_connection_try_setup (TestMainContext *ctx,
+ DBusConnection *connection);
+void test_connection_setup (TestMainContext *ctx,
DBusConnection *connection);
void test_connection_shutdown (TestMainContext *ctx,
DBusConnection *connection);
-dbus_bool_t test_server_setup (TestMainContext *ctx,
+_DBUS_GNUC_WARN_UNUSED_RESULT
+dbus_bool_t test_server_try_setup (TestMainContext *ctx,
+ DBusServer *server);
+void test_server_setup (TestMainContext *ctx,
DBusServer *server);
void test_server_shutdown (TestMainContext *ctx,
DBusServer *server);