1 /* Utility functions for tests that rely on GLib
3 * Copyright © 2010-2011 Nokia Corporation
4 * Copyright © 2013-2015 Collabora Ltd.
6 * Permission is hereby granted, free of charge, to any person
7 * obtaining a copy of this software and associated documentation files
8 * (the "Software"), to deal in the Software without restriction,
9 * including without limitation the rights to use, copy, modify, merge,
10 * publish, distribute, sublicense, and/or sell copies of the Software,
11 * and to permit persons to whom the Software is furnished to do so,
12 * subject to the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
21 * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
22 * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
23 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
27 #ifndef TEST_UTILS_GLIB_H
28 #define TEST_UTILS_GLIB_H
30 #include <dbus/dbus.h>
34 #include "test-utils.h"
37 * Multi-user support for regression tests run with root privileges in
38 * a continuous integration system.
40 * A developer would normally run the tests as their own uid. Tests run
41 * as TEST_USER_ME are run, and the others are skipped.
43 * In a CI system that has access to root privileges, most tests should still
44 * be run as an arbitrary non-root user, as above.
46 * Certain tests can usefully be run again, as root. When this is done,
47 * tests using TEST_USER_ROOT, TEST_USER_MESSAGEBUS and/or TEST_USER_OTHER
48 * can exercise situations that only arise when there's more than one uid.
51 /* Whatever user happens to be running the regression test;
52 * such tests also work on Windows */
54 /* Must be uid 0 on Unix; the test is skipped on Windows */
56 /* The user who would normally run the system bus. This is the DBUS_USER
57 * from configure.ac, usually 'messagebus' but perhaps 'dbus' or
60 /* An unprivileged user who is neither root nor DBUS_USER.
61 * This is DBUS_TEST_USER from configure.ac, usually 'nobody'. */
65 #define test_assert_no_error(e) _test_assert_no_error (e, __FILE__, __LINE__)
66 void _test_assert_no_error (const DBusError *e,
70 gchar *test_get_dbus_daemon (const gchar *config_file,
72 const gchar *runtime_dir,
75 DBusConnection *test_connect_to_bus (TestMainContext *ctx,
76 const gchar *address);
77 DBusConnection *test_connect_to_bus_as_user (TestMainContext *ctx,
81 void test_kill_pid (GPid pid);
83 void test_init (int *argcp, char ***argvp);
85 void test_progress (char symbol);
87 void test_remove_if_exists (const gchar *path);
88 void test_rmdir_must_exist (const gchar *path);
89 void test_rmdir_if_exists (const gchar *path);
90 void test_mkdir (const gchar *path, gint mode);
92 void test_timeout_reset (guint factor);
94 #if !GLIB_CHECK_VERSION(2, 44, 0)
95 #define g_steal_pointer(x) backported_g_steal_pointer (x)
96 /* A simplified version of g_steal_pointer without type-safety. */
97 static inline gpointer
98 backported_g_steal_pointer (gpointer pointer_to_pointer)
100 gpointer *pp = pointer_to_pointer;
109 gboolean test_check_tcp_works (void);