summaryrefslogtreecommitdiff
path: root/dbus-gmain/tests/test-thread-client.c
diff options
context:
space:
mode:
authorSimon McVittie <smcv@debian.org>2018-01-29 08:49:48 +0000
committerSimon McVittie <smcv@debian.org>2018-01-29 08:54:18 +0000
commitd354239ff42d972e6fe1448aae2db52e1af90aa7 (patch)
tree3c8ddaa11c7c36f5f1627b02293618ad7782db9a /dbus-gmain/tests/test-thread-client.c
parentc80ae773e1cc50b6acde492b1b6f83f49f6e53c8 (diff)
Move dbus-gmain to root directory
Signed-off-by: Simon McVittie <smcv@debian.org>
Diffstat (limited to 'dbus-gmain/tests/test-thread-client.c')
-rw-r--r--dbus-gmain/tests/test-thread-client.c121
1 files changed, 0 insertions, 121 deletions
diff --git a/dbus-gmain/tests/test-thread-client.c b/dbus-gmain/tests/test-thread-client.c
deleted file mode 100644
index 79de541..0000000
--- a/dbus-gmain/tests/test-thread-client.c
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright © 2003 Red Hat Inc.
- * Copyright © 2006-2018 Collabora Ltd.
- *
- * Licensed under the Academic Free License version 2.1
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
- *
- */
-
-#ifdef HAVE_CONFIG_H
-#include <config.h>
-#endif
-
-#include <glib.h>
-#include <dbus-gmain/dbus-gmain.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "test-thread.h"
-
-DBusConnection *connection;
-
-static gpointer
-thread_func (gpointer data)
-{
- gint32 threadnr = GPOINTER_TO_INT (data);
- guint32 counter = 0;
- DBusMessageIter iter;
- DBusMessage *message;
- char *str;
-
- while (1)
- {
- message = dbus_message_new_method_call (NULL,
- "/org/freedesktop/DBus/GLib/ThreadTest",
- "org.freedesktop.DBus.GLib.ThreadTest",
- "TestMethod");
-
- dbus_message_iter_init_append (message, &iter);
-
- if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &threadnr))
- {
- g_print ("thread %d: append threadnr failed\n", threadnr);
- }
-
- if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_INT32, &counter))
- {
- g_print ("thread %d: append counter (%d) failed\n", threadnr, counter);
- }
-
- str = g_strdup_printf ("Thread %d-%d\n", threadnr, counter);
- if (!dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING, &str))
- {
- g_print ("thread %d: append string (%s) failed\n", threadnr, str);
- }
- g_free (str);
-
- if (!dbus_connection_send (connection,
- message,
- NULL))
- {
- g_print ("thread %d: send message failed\n", threadnr);
- }
-
- dbus_message_unref (message);
-
- counter ++;
- }
-
- return NULL;
-}
-
-int
-main (int argc, char *argv[])
-{
- GMainLoop *loop;
- DBusError error;
- int i;
-
- if(argc < 2)
- {
- g_error("Need an address as argv[1]\n");
- return 1;
- }
-
- dbus_error_init (&error);
- connection = dbus_connection_open (argv[1], &error);
- if (connection == NULL)
- {
- g_printerr ("could not open connection: %s\n", error.message);
- dbus_error_free (&error);
- return 1;
- }
-
- DBUS_GMAIN_FUNCTION_NAME (set_up_connection) (connection, NULL);
-
- for (i = 0; i < N_TEST_THREADS; i++)
- {
- g_thread_create (thread_func, GINT_TO_POINTER (i), FALSE, NULL);
- }
-
- loop = g_main_loop_new (NULL, FALSE);
- g_main_loop_run (loop);
-
- return 0;
-}
-