summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorHavoc Pennington <hp@redhat.com>2003-04-07 23:28:16 +0000
committerHavoc Pennington <hp@redhat.com>2003-04-07 23:28:16 +0000
commitfe22b2194d53061fefe64d48ff6a53e6a762279d (patch)
tree590e2096930716d80fb2ba1ebfce10c10e08efda /test
parent1617fbe36c0bc2952093fc167b6edffdf32c445e (diff)
2003-04-07 Havoc Pennington <hp@redhat.com>
* doc/dbus-specification.sgml: require that base service names start with ':' and that the base service is created/deleted as first and last things a connection does on the bus * bus/dispatch.c (check_existent_service_activation): lots more work on the activation test; it doesn't fully pass yet... * test/test-service.c (main): fix so we don't memleak the connection to the message bus (filter_func): accept a message asking us to exit
Diffstat (limited to 'test')
-rw-r--r--test/test-service.c26
-rw-r--r--test/test-utils.c20
-rw-r--r--test/test-utils.h3
3 files changed, 45 insertions, 4 deletions
diff --git a/test/test-service.c b/test/test-service.c
index a1f2ae34..a9a960a1 100644
--- a/test/test-service.c
+++ b/test/test-service.c
@@ -2,6 +2,17 @@
#include "test-utils.h"
static DBusLoop *loop;
+static dbus_bool_t already_quit;
+
+static void
+quit (void)
+{
+ if (!already_quit)
+ {
+ _dbus_loop_quit (loop);
+ already_quit = TRUE;
+ }
+}
static void
die (const char *message)
@@ -62,12 +73,14 @@ filter_func (DBusMessageHandler *handler,
DBusConnection *connection,
DBusMessage *message,
void *user_data)
-{
+{
if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteEcho"))
return handle_echo (connection, message);
- else if (dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
+ else if (dbus_message_name_is (message, "org.freedesktop.DBus.TestSuiteExit") ||
+ dbus_message_name_is (message, DBUS_MESSAGE_LOCAL_DISCONNECT))
{
- _dbus_loop_quit (loop);
+ dbus_connection_disconnect (connection);
+ quit ();
return DBUS_HANDLER_RESULT_ALLOW_MORE_HANDLERS;
}
else
@@ -85,6 +98,7 @@ main (int argc,
DBusMessageHandler *handler;
const char *to_handle[] = {
"org.freedesktop.DBus.TestSuiteEcho",
+ "org.freedesktop.DBus.TestSuiteExit",
DBUS_MESSAGE_LOCAL_DISCONNECT,
};
int result;
@@ -121,11 +135,13 @@ main (int argc,
fprintf (stderr, "Failed to acquire service: %s\n",
error.message);
dbus_error_free (&error);
- return 1;
+ exit (1);
}
_dbus_loop_run (loop);
+ test_connection_shutdown (loop, connection);
+
dbus_connection_unref (connection);
dbus_message_handler_unref (handler);
@@ -134,6 +150,8 @@ main (int argc,
loop = NULL;
dbus_shutdown ();
+
+ printf ("*** Test service exiting\n");
return 0;
}
diff --git a/test/test-utils.c b/test/test-utils.c
index d7ccd931..62963f38 100644
--- a/test/test-utils.c
+++ b/test/test-utils.c
@@ -176,3 +176,23 @@ test_connection_setup (DBusLoop *loop,
cdata_free (cd);
return FALSE;
}
+
+void
+test_connection_shutdown (DBusLoop *loop,
+ DBusConnection *connection)
+{
+ if (!dbus_connection_set_watch_functions (connection,
+ NULL,
+ NULL,
+ NULL,
+ NULL, NULL))
+ _dbus_assert_not_reached ("setting watch functions to NULL failed");
+
+ if (!dbus_connection_set_timeout_functions (connection,
+ NULL,
+ NULL,
+ NULL,
+ NULL, NULL))
+ _dbus_assert_not_reached ("setting timeout functions to NULL failed");
+
+}
diff --git a/test/test-utils.h b/test/test-utils.h
index 2f115c7f..f00a7181 100644
--- a/test/test-utils.h
+++ b/test/test-utils.h
@@ -11,7 +11,10 @@
dbus_bool_t test_connection_setup (DBusLoop *loop,
DBusConnection *connection);
+void test_connection_shutdown (DBusLoop *loop,
+ DBusConnection *connection);
void test_connection_dispatch_all_messages (DBusConnection *connection);
dbus_bool_t test_connection_dispatch_one_message (DBusConnection *connection);
+
#endif