2 #include "test-utils.h"
6 static void die (const char *message) _DBUS_GNUC_NORETURN;
9 die (const char *message)
11 fprintf (stderr, "*** test-names: %s", message);
16 TestName(DBusConnection *connection, const char *name, int expectedSuccess)
19 dbus_error_init (&error);
21 (void) dbus_bus_request_name (connection, name, 0, &error);
22 if (dbus_error_is_set (&error))
25 fprintf (stderr, "Error acquiring name '%s': %s\n", name, error.message);
27 fprintf (stdout, "Expected Error acquiring name '%s': %s\n", name, error.message);
28 _dbus_verbose ("*** Failed to acquire name '%s': %s\n", name,
30 dbus_error_free (&error);
37 fprintf (stderr, "Unexpected Success acquiring name '%s'\n", name);
39 fprintf (stdout, "Successfully acquired name '%s'\n", name);
40 _dbus_verbose ("*** Managed to acquire name '%s'\n", name);
51 DBusConnection *connection;
53 dbus_error_init (&error);
54 connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
55 if (connection == NULL)
57 fprintf (stderr, "*** Failed to open connection to system bus: %s\n",
59 dbus_error_free (&error);
63 loop = _dbus_loop_new ();
67 if (!test_connection_setup (loop, connection))
70 TestName(connection, "org.freedesktop.DBus.Test", TRUE);
71 TestName(connection, "org.freedesktop.DBus.Test-2", TRUE);
72 TestName(connection, "org.freedesktop.DBus.Test_2", TRUE);
74 TestName(connection, "Test_2", TRUE);
77 _dbus_verbose ("*** Test service name exiting\n");