From: Fabiano Rosas <[email protected]> TLDR: GLib is bugged, the dbus-vmstate-test spams debug messages unconditionally. Mute them.
GLib is trying to protect against the lack of thread-safety of setenv/unsetsenv functions by warning when those functions were invoked after a thread has been started. https://gitlab.gnome.org/GNOME/glib/issues/715 Unfortunately: 1) GLib itself starts a thread pool via _g_dbus_initialize when working around a bug in its type dependency chain. This happens in many places, but the test triggers it via g_dbus_address_get_for_bus_sync. https://bugzilla.gnome.org/show_bug.cgi?id=627724 2) GLib itself calls g_unsetenv after the test calls g_test_dbus_up. 3) The debug message at g_unsetenv is issued to the G_LOG_DOMAIN defined while compiling the library, i.e "GLib", but this domain is never initialized, so the log functions go into a fallback chain that results in ignoring the G_MESSAGES_DEBUG environment variable, causing the debug messages to not be suppressed when they should. Mute the messages by implementing a handler for G_LOG_LEVEL_DEBUG in the "GLib" log domain and honoring G_MESSAGES_DEBUG. Signed-off-by: Fabiano Rosas <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Message-ID: <[email protected]> --- tests/qtest/dbus-vmstate-test.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/qtest/dbus-vmstate-test.c b/tests/qtest/dbus-vmstate-test.c index 90c050b4480..51c5fdb995a 100644 --- a/tests/qtest/dbus-vmstate-test.c +++ b/tests/qtest/dbus-vmstate-test.c @@ -357,12 +357,33 @@ test_dbus_vmstate_missing_dst(char *name, MigrateCommon *args) g_test_trap_assert_passed(); } +static void log_func(const gchar *log_domain, GLogLevelFlags log_level, + const gchar *message, gpointer user_data) +{ + const gchar *domains; + + assert(log_level & G_LOG_LEVEL_DEBUG); + + domains = getenv("G_MESSAGES_DEBUG"); + if (!domains || (!strstr(domains, "GLib") && !strstr(domains, "all"))) { + return; + } + g_log_default_handler("GLib", G_LOG_LEVEL_DEBUG, message, NULL); +} + int main(int argc, char **argv) { GError *err = NULL; int ret; + /* + * GLib currently emits debug messages that ignore + * G_MESSAGES_DEBUG. Set a custom log handler to work around the + * issue. + */ + g_log_set_handler("GLib", G_LOG_LEVEL_DEBUG, log_func, NULL); + g_test_init(&argc, &argv, NULL); workdir = g_dir_make_tmp("dbus-vmstate-test-XXXXXX", &err); -- 2.54.0
