From bfd6be8555945c01da8772643f71ba511c52cc34 Mon Sep 17 00:00:00 2001 From: Havoc Pennington Date: Thu, 14 Jun 2007 22:02:10 +0000 Subject: 2007-06-14 Havoc Pennington MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * bus/dispatch.c (check_get_connection_unix_process_id): mop up getpid() (noticed by Peter KKümmel) and adapt the test to expect a "pid unknown" error when running on Windows. --- bus/dispatch.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'bus') diff --git a/bus/dispatch.c b/bus/dispatch.c index ef75933f..ed457dc4 100644 --- a/bus/dispatch.c +++ b/bus/dispatch.c @@ -399,10 +399,6 @@ bus_dispatch_remove_connection (DBusConnection *connection) #ifdef DBUS_BUILD_TESTS #include -#ifdef DBUS_UNIX -#include -#include -#endif /* This is used to know whether we need to block in order to finish * sending a message, or whether the initial dbus_connection_send() @@ -1268,15 +1264,28 @@ check_get_connection_unix_process_id (BusContext *context, { ; /* good, this is a valid response */ } +#ifdef DBUS_WIN + else if (dbus_message_is_error (message, DBUS_ERROR_UNIX_PROCESS_ID_UNKNOWN)) + { + /* We are expecting this error, since we know in the test suite we aren't + * talking to a client running on UNIX + */ + _dbus_verbose ("Windows correctly does not support GetConnectionUnixProcessID\n"); + } +#endif else { warn_unexpected (connection, message, "not this error"); - + goto out; } } else { +#ifdef DBUS_WIN + warn_unexpected (connection, message, "GetConnectionUnixProcessID to fail on Windows"); + goto out; +#else if (dbus_message_get_type (message) == DBUS_MESSAGE_TYPE_METHOD_RETURN) { ; /* good, expected */ @@ -1308,8 +1317,9 @@ check_get_connection_unix_process_id (BusContext *context, _dbus_warn ("Did not get the expected DBUS_TYPE_UINT32 from GetConnectionUnixProcessID\n"); goto out; } - } else { - + } + else + { /* test if returned pid is the same as our own pid * * @todo It would probably be good to restructure the tests @@ -1317,13 +1327,14 @@ check_get_connection_unix_process_id (BusContext *context, * cause then we can test that the pid returned matches * getppid() */ - if (pid != (dbus_uint32_t) getpid ()) + if (pid != (dbus_uint32_t) _dbus_getpid ()) { _dbus_assert (dbus_error_is_set (&error)); _dbus_warn ("Result from GetConnectionUnixProcessID is not our own pid\n"); goto out; } } +#endif /* !DBUS_WIN */ } if (!check_no_leftovers (context)) -- cgit