6 #include <dbus/dbus-connection-internal.h>
11 static void die (const char *message) _DBUS_GNUC_NORETURN;
14 die (const char *message)
16 printf ("Bail out! test-ids: %s\n", message);
20 static int test_num = 0;
22 /* This test outputs TAP syntax: http://testanything.org/ */
28 DBusConnection *connection;
32 dbus_error_init (&error);
33 connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
34 if (connection == NULL)
36 fprintf (stderr, "*** Failed to open connection to system bus: %s\n",
38 dbus_error_free (&error);
41 printf ("ok %d - connected to session bus\n", ++test_num);
43 server_id = dbus_connection_get_server_id (connection);
45 if (server_id == NULL)
46 die ("No bus server ID retrieved\n");
48 printf ("ok %d - session bus server ID is %s\n", ++test_num, server_id);
50 if (strlen (server_id) != 32)
51 die ("Bus server id should have length 32\n");
53 printf ("ok %d - session bus server ID length is 32\n", ++test_num);
55 dbus_free (server_id);
57 id = dbus_bus_get_id (connection, NULL);
59 die ("No bus ID retrieved\n");
61 printf ("ok %d - session bus ID is %s\n", ++test_num, id);
63 if (strlen (id) != 32)
64 die ("Bus ID should have length 32\n");
66 printf ("ok %d - session bus ID length is 32\n", ++test_num);
70 printf ("1..%d\n", test_num);