summaryrefslogtreecommitdiff
path: root/test/test-service.c
diff options
context:
space:
mode:
authorScott James Remnant <scott@ubuntu.com>2009-05-11 23:29:52 +0100
committerColin Walters <walters@verbum.org>2009-07-14 15:38:42 -0400
commit0539a23c661f028da63526996b6463ef342bb4f3 (patch)
treea02a4c05a9dfe230dbdfdc39577ab6e23b7be6e8 /test/test-service.c
parent21b0ff273a69d19e505b71c263725302aa5b025f (diff)
downloaddbus-0539a23c661f028da63526996b6463ef342bb4f3.tar.gz
Add tests for pending call timeouts
* test/test-service.c (handle_delay_echo, path_message_func): Add a variant of the Echo method which sleeps for a short time. * test/name-test/test-pending-call-timeout.c: Run tests with default, specified and infinite timeout to make sure we get the reply. * test/name-test/run-test.sh: Run the new test * test/name-test/Makefile.am: Build the new test Signed-off-by: Scott James Remnant <scott@ubuntu.com> (cherry picked from commit c1f165261afcc3bafa9b24ff916bb231628e3782)
Diffstat (limited to 'test/test-service.c')
-rw-r--r--test/test-service.c60
1 files changed, 60 insertions, 0 deletions
diff --git a/test/test-service.c b/test/test-service.c
index bd2a4638..57ece0fa 100644
--- a/test/test-service.c
+++ b/test/test-service.c
@@ -223,6 +223,62 @@ handle_echo (DBusConnection *connection,
return DBUS_HANDLER_RESULT_HANDLED;
}
+static DBusHandlerResult
+handle_delay_echo (DBusConnection *connection,
+ DBusMessage *message)
+{
+ DBusError error;
+ DBusMessage *reply;
+ char *s;
+
+ _dbus_verbose ("sleeping for a short time\n");
+
+ usleep (50000);
+
+ _dbus_verbose ("sending reply to DelayEcho method\n");
+
+ dbus_error_init (&error);
+
+ if (!dbus_message_get_args (message,
+ &error,
+ DBUS_TYPE_STRING, &s,
+ DBUS_TYPE_INVALID))
+ {
+ reply = dbus_message_new_error (message,
+ error.name,
+ error.message);
+
+ if (reply == NULL)
+ die ("No memory\n");
+
+ if (!dbus_connection_send (connection, reply, NULL))
+ die ("No memory\n");
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_NOT_YET_HANDLED;
+ }
+
+ reply = dbus_message_new_method_return (message);
+ if (reply == NULL)
+ die ("No memory\n");
+
+ if (!dbus_message_append_args (reply,
+ DBUS_TYPE_STRING, &s,
+ DBUS_TYPE_INVALID))
+ die ("No memory");
+
+ if (!dbus_connection_send (connection, reply, NULL))
+ die ("No memory\n");
+
+ fprintf (stderr, "DelayEcho service echoed string: \"%s\"\n", s);
+
+ dbus_message_unref (reply);
+
+ return DBUS_HANDLER_RESULT_HANDLED;
+}
+
+
static void
path_unregistered_func (DBusConnection *connection,
void *user_data)
@@ -241,6 +297,10 @@ path_message_func (DBusConnection *connection,
return handle_echo (connection, message);
else if (dbus_message_is_method_call (message,
"org.freedesktop.TestSuite",
+ "DelayEcho"))
+ return handle_delay_echo (connection, message);
+ else if (dbus_message_is_method_call (message,
+ "org.freedesktop.TestSuite",
"Exit"))
{
quit ();