diff options
author | Havoc Pennington <hp@redhat.com> | 2003-04-04 00:39:22 +0000 |
---|---|---|
committer | Havoc Pennington <hp@redhat.com> | 2003-04-04 00:39:22 +0000 |
commit | 1b08036103a70159e7a67b2349306710edcd6654 (patch) | |
tree | 6c6469bc51f9abcd2cf69036aabc71dea75c03b2 /bus/dispatch.c | |
parent | f216e81432ddf04889202c33a6e68113f94d7611 (diff) |
2003-04-03 Havoc Pennington <hp@redhat.com>
* bus/loop.h, bus/loop.c: make the mainloop an object so we can
have multiple ones
* bus/*.[hc]: adapt to mainloop change
Diffstat (limited to 'bus/dispatch.c')
-rw-r--r-- | bus/dispatch.c | 127 |
1 files changed, 121 insertions, 6 deletions
diff --git a/bus/dispatch.c b/bus/dispatch.c index 7c65ac42..21d57ae1 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -537,8 +537,8 @@ kill_client_connection (BusContext *context, /* kick in the disconnect handler that unrefs the connection */ dbus_connection_disconnect (connection); - bus_test_flush_bus (context); - + bus_test_run_everything (context); + _dbus_assert (bus_test_client_listed (connection)); /* Run disconnect handler in test.c */ @@ -729,8 +729,8 @@ check_hello_message (BusContext *context, dbus_message_unref (message); message = NULL; - - bus_test_flush_bus (context); + + bus_test_run_everything (context); if (!dbus_connection_get_is_connected (connection)) { @@ -963,8 +963,8 @@ check_nonexistent_service_activation (BusContext *context, dbus_message_unref (message); message = NULL; - - bus_test_flush_bus (context); + + bus_test_run_everything (context); if (!dbus_connection_get_is_connected (connection)) { @@ -1028,6 +1028,116 @@ check_nonexistent_service_activation (BusContext *context, return retval; } +#define EXISTENT_SERVICE_NAME "org.freedesktop.DBus.TestSuiteEchoService" + +/* returns TRUE if the correct thing happens, + * but the correct thing may include OOM errors. + */ +static dbus_bool_t +check_existent_service_activation (BusContext *context, + DBusConnection *connection) +{ + DBusMessage *message; + dbus_int32_t serial; + dbus_bool_t retval; + DBusError error; + + dbus_error_init (&error); + + message = dbus_message_new (DBUS_SERVICE_DBUS, + DBUS_MESSAGE_ACTIVATE_SERVICE); + + if (message == NULL) + return TRUE; + + if (!dbus_message_append_args (message, + DBUS_TYPE_STRING, EXISTENT_SERVICE_NAME, + DBUS_TYPE_UINT32, 0, + DBUS_TYPE_INVALID)) + { + dbus_message_unref (message); + return TRUE; + } + + if (!dbus_connection_send (connection, message, &serial)) + { + dbus_message_unref (message); + return TRUE; + } + + dbus_message_unref (message); + message = NULL; + + bus_test_run_everything (context); + + /* now wait for the message bus to hear back from the activated service */ + bus_test_run_bus_loop (context); + + /* and process everything again */ + bus_test_run_everything (context); + + if (!dbus_connection_get_is_connected (connection)) + { + _dbus_verbose ("connection was disconnected\n"); + return TRUE; + } + + retval = FALSE; + + message = dbus_connection_pop_message (connection); + if (message == NULL) + { + _dbus_warn ("Did not receive a reply to %s %d on %p\n", + DBUS_MESSAGE_ACTIVATE_SERVICE, serial, connection); + goto out; + } + + _dbus_verbose ("Received %s on %p\n", + dbus_message_get_name (message), connection); + + if (dbus_message_get_is_error (message)) + { + if (!dbus_message_sender_is (message, DBUS_SERVICE_DBUS)) + { + _dbus_warn ("Message has wrong sender %s\n", + dbus_message_get_sender (message) ? + dbus_message_get_sender (message) : "(none)"); + goto out; + } + + if (dbus_message_name_is (message, + DBUS_ERROR_NO_MEMORY)) + { + ; /* good, this is a valid response */ + } + else if (dbus_message_name_is (message, + DBUS_ERROR_ACTIVATE_SERVICE_NOT_FOUND)) + { + ; /* good, this is expected also */ + } + else + { + _dbus_warn ("Did not expect error %s\n", + dbus_message_get_name (message)); + goto out; + } + } + else + { + _dbus_warn ("Did not expect to successfully activate %s\n", + EXISTENT_SERVICE_NAME); + goto out; + } + + retval = TRUE; + + out: + if (message) + dbus_message_unref (message); + + return retval; +} + typedef struct { Check1Func func; @@ -1153,6 +1263,11 @@ bus_dispatch_test (const DBusString *test_data_dir) if (!check_hello_message (context, baz)) _dbus_assert_not_reached ("hello message failed"); +#if 0 + check2_try_iterations (context, foo, "existent_service_activation", + check_existent_service_activation); +#endif + check2_try_iterations (context, foo, "nonexistent_service_activation", check_nonexistent_service_activation); |