blob: 8f63d0442076ac4ad534853dc1db664cccdd7073 [file] [log] [blame]
Emeric Vigier2f625822012-08-06 11:09:52 -04001#include <config.h>
2#include <stdio.h>
3#include <stdlib.h>
4#include <string.h>
5#include <dbus/dbus.h>
6#include <dbus/dbus-connection-internal.h>
7#ifdef HAVE_UNISTD_H
8#include <unistd.h>
9#endif
10
11static void
12die (const char *message)
13{
14 fprintf (stderr, "*** test-ids: %s", message);
15 exit (1);
16}
17
18int
19main (int argc,
20 char **argv)
21{
22 DBusError error;
23 DBusConnection *connection;
24 char *id;
25 char *server_id;
26
27 dbus_error_init (&error);
28 connection = dbus_bus_get (DBUS_BUS_SESSION, &error);
29 if (connection == NULL)
30 {
31 fprintf (stderr, "*** Failed to open connection to system bus: %s\n",
32 error.message);
33 dbus_error_free (&error);
34 return 1;
35 }
36
37 server_id = dbus_connection_get_server_id (connection);
38 if (server_id == NULL)
39 die ("No bus server ID retrieved\n");
40 /* printf("'%s'\n", server_id); */
41 if (strlen (server_id) != 32)
42 die ("Bus server id should have length 32\n");
43 dbus_free (server_id);
44
45 id = dbus_bus_get_id (connection, NULL);
46 if (id == NULL)
47 die ("No bus ID retrieved\n");
48 /* printf("'%s'\n", id); */
49 if (strlen (id) != 32)
50 die ("Bus ID should have length 32\n");
51 dbus_free (id);
52
53 _dbus_verbose ("*** Test IDs exiting\n");
54
55 return 0;
56}