mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-21 09:42:10 +01:00
tests: Isolate directory access for gdbus-server-auth test
When multiple tests were run in parallel, this would race on its access to `~/.dbus-keyrings` to authenticate with the D-Bus server, since the keyring directory was not appropriately sandboxed to the unit test. Use `G_TEST_OPTION_ISOLATE_DIRS` to automatically isolate each unit test’s directory usage. Signed-off-by: Philip Withnall <withnall@endlessm.com> Fixes: #1954
This commit is contained in:
parent
de0fae3d49
commit
1a35d27f1b
@ -398,6 +398,14 @@ do_test_server_auth (InteropFlags flags)
|
|||||||
LibdbusCall libdbus_call = { DBUS_ERROR_INIT, NULL, NULL, NULL };
|
LibdbusCall libdbus_call = { DBUS_ERROR_INIT, NULL, NULL, NULL };
|
||||||
GTask *task;
|
GTask *task;
|
||||||
|
|
||||||
|
/* The test suite uses %G_TEST_OPTION_ISOLATE_DIRS, which sets
|
||||||
|
* `HOME=/dev/null` and leaves g_get_home_dir() pointing to the per-test
|
||||||
|
* temp home directory. Unfortunately, libdbus doesn’t allow the home dir
|
||||||
|
* to be overridden except using the environment, so copy the per-test
|
||||||
|
* temp home directory back there so that libdbus uses the same
|
||||||
|
* `$HOME/.dbus-keyrings` path as GLib. This is not thread-safe. */
|
||||||
|
g_setenv ("HOME", g_get_home_dir (), TRUE);
|
||||||
|
|
||||||
libdbus_call.conn = dbus_connection_open_private (connectable_address,
|
libdbus_call.conn = dbus_connection_open_private (connectable_address,
|
||||||
&libdbus_call.error);
|
&libdbus_call.error);
|
||||||
g_assert_cmpstr (libdbus_call.error.name, ==, NULL);
|
g_assert_cmpstr (libdbus_call.error.name, ==, NULL);
|
||||||
@ -516,10 +524,7 @@ int
|
|||||||
main (int argc,
|
main (int argc,
|
||||||
char *argv[])
|
char *argv[])
|
||||||
{
|
{
|
||||||
/* FIXME: Add debug for https://gitlab.gnome.org/GNOME/glib/issues/1954 */
|
g_test_init (&argc, &argv, G_TEST_OPTION_ISOLATE_DIRS, NULL);
|
||||||
g_setenv ("G_DBUS_DEBUG", "all", TRUE);
|
|
||||||
|
|
||||||
g_test_init (&argc, &argv, NULL);
|
|
||||||
|
|
||||||
g_test_add_func ("/gdbus/server-auth", test_server_auth);
|
g_test_add_func ("/gdbus/server-auth", test_server_auth);
|
||||||
g_test_add_func ("/gdbus/server-auth/abstract", test_server_auth_abstract);
|
g_test_add_func ("/gdbus/server-auth/abstract", test_server_auth_abstract);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user