2 #include "test-utils.h"
7 die (const char *message)
9 fprintf (stderr, "*** test-names: %s", message);
14 TestName(DBusConnection *connection, const char *name, int expectedSuccess)
17 dbus_error_init (&error);
19 (void) dbus_bus_request_name (connection, name, 0, &error);
20 if (dbus_error_is_set (&error))
23 fprintf (stderr, "Error acquiring name '%s': %s\n", name, error.message);
25 fprintf (stdout, "Expected Error acquiring name '%s': %s\n", name, error.message);
26 _dbus_verbose ("*** Failed to acquire name '%s': %s\n", name,
28 dbus_error_free (&error);
35 fprintf (stderr, "Unexpected Success acquiring name '%s'\n", name);
37 fprintf (stdout, "Successfully acquired name '%s'\n", name);
38 _dbus_verbose ("*** Managed to acquire name '%s'\n", name);
49 DBusConnection *connection;
51 dbus_error_init (&error);
52 connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
53 if (connection == NULL)
55 fprintf (stderr, "*** Failed to open connection to system bus: %s\n",
57 dbus_error_free (&error);
61 loop = _dbus_loop_new ();
65 if (!test_connection_setup (loop, connection))
68 TestName(connection, "org.freedesktop.DBus.Test", TRUE);
69 TestName(connection, "org.freedesktop.DBus.Test-2", TRUE);
70 TestName(connection, "org.freedesktop.DBus.Test_2", TRUE);
72 TestName(connection, "Test_2", TRUE);
75 _dbus_verbose ("*** Test service name exiting\n");