mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-05 14:38:09 +02:00
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: <info> 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 6994454461 for the
most part. It's not sufficient to disable logging warnings. Creating
a DBus Manager might affect the system in undesired ways.
This commit is contained in:
parent
9b16e85ece
commit
5040a8a851
1 changed files with 7 additions and 17 deletions
|
|
@ -289,28 +289,18 @@ test_config_confdir_parse_error (void)
|
|||
|
||||
NMTST_DEFINE ();
|
||||
|
||||
|
||||
static void
|
||||
ignore_log (const gchar *log_domain,
|
||||
GLogLevelFlags log_level,
|
||||
const gchar *message,
|
||||
gpointer user_data)
|
||||
{
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, char **argv)
|
||||
{
|
||||
/* Initialize the DBus manager singleton in advance, ignoring the warnings.
|
||||
* Otherwise it would attempt to initialize as soon as nm_test_device_new()
|
||||
* would cause NMDevice class to register its type on the bus. We don't care
|
||||
* about that and the warnings would mess up with the testing.
|
||||
* */
|
||||
g_log_set_default_handler (ignore_log, NULL);
|
||||
nm_dbus_manager_get ();
|
||||
|
||||
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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue