1 /* GLib testing framework examples and tests
3 * Copyright (C) 2008-2010 Red Hat, Inc.
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General
16 * Public License along with this library; if not, write to the
17 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
18 * Boston, MA 02111-1307, USA.
20 * Author: David Zeuthen <davidz@redhat.com>
27 #include "gdbus-tests.h"
29 /* all tests rely on a shared mainloop */
30 static GMainLoop *loop = NULL;
32 /* ---------------------------------------------------------------------------------------------------- */
35 nuke_session_bus_cb (gpointer data)
37 g_main_loop_quit (loop);
42 test_exit_on_close (void)
44 if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR))
48 c = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
50 g_assert (!g_dbus_connection_is_closed (c));
54 g_main_loop_run (loop);
56 g_main_loop_run (loop);
58 g_test_trap_assert_stdout ("*Remote peer vanished with error: Underlying GIOStream returned 0 bytes on an async read (g-io-error-quark, 0). Exiting.*");
59 g_test_trap_assert_failed();
62 /* ---------------------------------------------------------------------------------------------------- */
69 g_test_init (&argc, &argv, NULL);
71 /* all the tests rely on a shared main loop */
72 loop = g_main_loop_new (NULL, FALSE);
74 /* all the tests use a session bus with a well-known address that we can bring up and down
75 * using session_bus_up() and session_bus_down().
77 g_unsetenv ("DISPLAY");
78 g_setenv ("DBUS_SESSION_BUS_ADDRESS", session_bus_get_temporary_address (), TRUE);
80 g_test_add_func ("/gdbus/exit-on-close", test_exit_on_close);