From 537ce96fa2f8dd66618844b1ada55e4f11d5e964 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 16 Feb 2015 15:31:05 +0100 Subject: [PATCH] config/tests: inject NMDBusManager for tests in NMDevice stub We don't need the bus for the tests and the manager may warn when it is not available. $ (cd src/tests/config/; env -i DBUS_SYSTEM_BUS_ADDRESS=meow ./test-config) /config/parse-error: OK /config/no-auto-default: NetworkManager-Message: Could not connect to the system bus; only the private D-Bus socket will be available. /bin/sh: line 5: 29997 Trace/breakpoint trap ${dir}$tst FAIL: test-config This reverts commit 6994454461100d45a7e2f063bd1f473652d4839d for the most part. It's not sufficient to disable logging warnings. Creating a DBus Manager might affect the system in undesired ways. (cherry picked from commit 5040a8a8515b01642bd3425aae27d5b20374b8f3) --- src/tests/config/test-config.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/tests/config/test-config.c b/src/tests/config/test-config.c index 4d99506c28..6b1d3e36bb 100644 --- a/src/tests/config/test-config.c +++ b/src/tests/config/test-config.c @@ -28,6 +28,7 @@ #include "nm-test-device.h" #include "nm-fake-platform.h" #include "nm-logging.h" +#include "nm-dbus-manager.h" #include "nm-test-utils.h" @@ -289,6 +290,13 @@ main (int argc, char **argv) { nmtst_init_assert_logging (&argc, &argv); + /* Initialize the DBus manager singleton explicitly, because it is accessed by + * the class initializer of NMDevice (used by the NMTestDevice stub). + * This way, we skip calling nm_dbus_manager_init_bus() which would + * either fail and/or cause unexpected actions in the test. + * */ + nm_dbus_manager_setup (g_object_new (NM_TYPE_DBUS_MANAGER, NULL)); + nm_fake_platform_setup (); g_test_add_func ("/config/simple", test_config_simple);