diff options
author | Simon McVittie <smcv@collabora.com> | 2017-11-21 16:01:02 +0000 |
---|---|---|
committer | Simon McVittie <smcv@collabora.com> | 2017-11-24 12:19:16 +0000 |
commit | e36873d98162e5f8a1fcb57766749937925a15c2 (patch) | |
tree | 72dc5d14faf5c1434844c52760b79e57f2ae5286 /test/sd-activation.c | |
parent | 05c04704f9801b732d7372e5ef14e181019257bc (diff) | |
download | dbus-e36873d98162e5f8a1fcb57766749937925a15c2.tar.gz |
tests: Use test_main_context_call_and_wait
Also use test_oom() where the relevant lines are changing anyway.
Signed-off-by: Simon McVittie <smcv@collabora.com>
Reviewed-by: Philip Withnall <withnall@endlessm.com>
Bug: https://bugs.freedesktop.org/show_bug.cgi?id=103600
Diffstat (limited to 'test/sd-activation.c')
-rw-r--r-- | test/sd-activation.c | 68 |
1 files changed, 12 insertions, 56 deletions
diff --git a/test/sd-activation.c b/test/sd-activation.c index c8e41225..add2c264 100644 --- a/test/sd-activation.c +++ b/test/sd-activation.c @@ -524,7 +524,6 @@ test_uae (Fixture *f, { DBusMessage *m = NULL; DBusMessage *reply = NULL; - DBusPendingCall *pc = NULL; DBusMessageIter args_iter, arr_iter, entry_iter; const char *s; @@ -545,22 +544,11 @@ test_uae (Fixture *f, !dbus_message_iter_close_container (&args_iter, &arr_iter)) g_error ("OOM"); - if (!dbus_connection_send_with_reply (f->caller, m, &pc, - DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL) - g_error ("OOM"); - - if (dbus_pending_call_get_completed (pc)) - test_pending_call_store_reply (pc, &reply); - else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply, - &reply, NULL)) - g_error ("OOM"); - - while (reply == NULL) - test_main_context_iterate (f->ctx, TRUE); + reply = test_main_context_call_and_wait (f->ctx, f->caller, m, + DBUS_TIMEOUT_USE_DEFAULT); assert_method_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, ""); - dbus_clear_pending_call (&pc); dbus_clear_message (&reply); dbus_clear_message (&m); @@ -630,22 +618,11 @@ test_uae (Fixture *f, g_error ("OOM"); } - if (!dbus_connection_send_with_reply (f->caller, m, &pc, - DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL) - g_error ("OOM"); - - if (dbus_pending_call_get_completed (pc)) - test_pending_call_store_reply (pc, &reply); - else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply, - &reply, NULL)) - g_error ("OOM"); - - while (reply == NULL) - test_main_context_iterate (f->ctx, TRUE); + reply = test_main_context_call_and_wait (f->ctx, f->caller, m, + DBUS_TIMEOUT_USE_DEFAULT); assert_method_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, ""); - dbus_clear_pending_call (&pc); dbus_clear_message (&reply); dbus_clear_message (&m); @@ -876,26 +853,15 @@ test_transient_services (Fixture *f, m = dbus_message_new_method_call (config->bus_name, "/foo", "com.example.bar", "Activate"); - if (m == NULL || - !dbus_connection_send_with_reply (f->caller, m, &pc, - DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL) - g_error ("OOM"); + if (m == NULL) + test_oom (); /* It fails. */ - - if (dbus_pending_call_get_completed (pc)) - test_pending_call_store_reply (pc, &reply); - else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply, - &reply, NULL)) - g_error ("OOM"); - - while (reply == NULL) - test_main_context_iterate (f->ctx, TRUE); - + reply = test_main_context_call_and_wait (f->ctx, f->caller, m, + DBUS_TIMEOUT_USE_DEFAULT); assert_error_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, DBUS_ERROR_SERVICE_UNKNOWN); - dbus_clear_pending_call (&pc); dbus_clear_message (&reply); dbus_clear_message (&m); @@ -909,23 +875,13 @@ test_transient_services (Fixture *f, m = dbus_message_new_method_call (DBUS_SERVICE_DBUS, DBUS_PATH_DBUS, DBUS_INTERFACE_DBUS, "ReloadConfig"); - if (m == NULL || - !dbus_connection_send_with_reply (f->caller, m, &pc, - DBUS_TIMEOUT_USE_DEFAULT) || pc == NULL) - g_error ("OOM"); - - if (dbus_pending_call_get_completed (pc)) - test_pending_call_store_reply (pc, &reply); - else if (!dbus_pending_call_set_notify (pc, test_pending_call_store_reply, - &reply, NULL)) - g_error ("OOM"); - - while (reply == NULL) - test_main_context_iterate (f->ctx, TRUE); + if (m == NULL) + test_oom (); + reply = test_main_context_call_and_wait (f->ctx, f->caller, m, + DBUS_TIMEOUT_USE_DEFAULT); assert_method_reply (reply, DBUS_SERVICE_DBUS, f->caller_name, ""); - dbus_clear_pending_call (&pc); dbus_clear_message (&reply); dbus_clear_message (&m); } |