508
509
dbus_shutdown ();
512
/* Check that we can create a proxy to Upstart's private internal
513
* server in user mode, and that this is the default behaviour if we don't
514
* fiddle with the other options. The returned proxy should
515
* hold the only reference to the connection.
517
TEST_FEATURE ("with user-mode");
522
dest_address = DBUS_ADDRESS_UPSTART;
525
assert0 (setenv ("UPSTART_SESSION",
526
"unix:abstract=/com/ubuntu/upstart/test-session",
530
server = nih_dbus_server (getenv ("UPSTART_SESSION"),
533
assert (server != NULL);
536
my_connect_handler_called = FALSE;
537
last_connection = NULL;
539
TEST_DIVERT_STDERR (output) {
540
proxy = upstart_open (NULL);
544
if (test_alloc_failed
545
&& (proxy == NULL)) {
546
TEST_FILE_EQ (output, "test: Cannot allocate memory\n");
547
TEST_FILE_END (output);
548
TEST_FILE_RESET (output);
550
if (last_connection) {
551
dbus_connection_close (last_connection);
552
dbus_connection_unref (last_connection);
555
dbus_server_disconnect (server);
556
dbus_server_unref (server);
564
TEST_TRUE (my_connect_handler_called);
565
TEST_NE_P (last_connection, NULL);
567
TEST_NE_P (proxy, NULL);
568
TEST_ALLOC_SIZE (proxy, sizeof (NihDBusProxy));
570
TEST_NE_P (proxy->connection, NULL);
571
TEST_EQ_P (proxy->name, NULL);
572
TEST_EQ_P (proxy->owner, NULL);
573
TEST_EQ_STR (proxy->path, DBUS_PATH_UPSTART);
574
TEST_ALLOC_PARENT (proxy->path, proxy);
575
TEST_FALSE (proxy->auto_start);
577
TEST_EQ_P (proxy->lost_handler, NULL);
578
TEST_EQ_P (proxy->data, NULL);
582
TEST_FILE_END (output);
583
TEST_FILE_RESET (output);
585
dbus_connection_close (last_connection);
586
dbus_connection_unref (last_connection);
588
dbus_server_disconnect (server);
589
dbus_server_unref (server);
593
unsetenv ("UPSTART_SESSION");
512
598
/* Check that we can create a connection to Upstart via the system
513
599
* bus. The returned proxy should use the default name on that
808
/* Check that when we attempt to connect to Upstart in user mode but
809
* without UPSTART_SESSION set in the environment, an appropriate
812
TEST_FEATURE ("with user-mode and no target");
817
dest_address = DBUS_ADDRESS_UPSTART;
820
unsetenv ("UPSTART_SESSION");
822
TEST_DIVERT_STDERR (output) {
823
proxy = upstart_open (NULL);
827
TEST_EQ_P (proxy, NULL);
829
TEST_FILE_EQ (output, ("test: UPSTART_SESSION isn't set in the environment. "
830
"Unable to locate the Upstart instance.\n"));
831
TEST_FILE_END (output);
832
TEST_FILE_RESET (output);