• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 
2 #include <config.h>
3 #include "../test-utils.h"
4 
5 static DBusLoop *loop;
6 
7 static void
die(const char * message)8 die (const char *message)
9 {
10   fprintf (stderr, "*** test-shutdown: %s", message);
11   exit (1);
12 }
13 
14 static void
open_destroy_shared_session_bus_connection(void)15 open_destroy_shared_session_bus_connection (void)
16 {
17   DBusError error;
18   DBusConnection *connection;
19   char *session_addr_no_guid;
20   char *comma;
21 
22   dbus_error_init (&error);
23 
24   session_addr_no_guid = strdup (getenv ("DBUS_SESSION_BUS_ADDRESS"));
25   comma = strchr (session_addr_no_guid, ',');
26   if (comma == NULL)
27     die ("Couldn't find GUID in session bus address");
28   *comma = '\0';
29 
30   connection = dbus_connection_open (session_addr_no_guid, &error);
31   free (session_addr_no_guid);
32   if (connection == NULL)
33     die ("Failed to open connection to temp session bus\n");
34 
35   loop = _dbus_loop_new ();
36   if (loop == NULL)
37     die ("No memory\n");
38 
39   if (!test_connection_setup (loop, connection))
40     die ("No memory\n");
41 
42   test_connection_shutdown (loop, connection);
43 
44   _dbus_loop_unref (loop);
45 
46   dbus_connection_unref (connection);
47 }
48 
49 int
main(int argc,char ** argv)50 main (int    argc,
51       char **argv)
52 {
53   open_destroy_shared_session_bus_connection ();
54 
55   dbus_shutdown ();
56 
57   open_destroy_shared_session_bus_connection ();
58 
59   dbus_shutdown ();
60 
61   open_destroy_shared_session_bus_connection ();
62 
63   dbus_shutdown ();
64 
65   _dbus_verbose ("*** Test shutdown exiting\n");
66 
67   return 0;
68 }
69