From 5e74891b58688a19c43fb8e50880166d94a4e901 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 16 Feb 2015 16:02:59 +0100 Subject: test: fix setup of logging for no-expect-message Tests with assert-logging would never overwrite the logging level, even if no-expect-message was set. Allow resetting the logging level if no-expect-message is mixed with explicitly setting up logging. NMTST_DEBUG='log-level=DEBUG,log-domains=ALL,no-expect-message' make check -C src/tests/config/ --- include/nm-test-utils.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index a9347e92ab..23273162df 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -281,6 +281,18 @@ __nmtst_init (int *argc, char ***argv, gboolean assert_logging, const char *log_ * This transforms g_test_expect_message() into a NOP, but we also have to relax * g_log_set_always_fatal(), which was set by g_test_init(). */ g_log_set_always_fatal (G_LOG_FATAL_MASK); +#ifdef __NETWORKMANAGER_LOGGING_H__ + if (c_log_domains || c_log_level) { + /* Normally, tests with assert_logging do not overwrite the logging level/domains because + * the logging statements are part of the assertions. But if the test is run with + * no-expect-message *and* the logging is set explicitly via environment variables, + * we still reset the logging. */ + gboolean success; + + success = nm_logging_setup (log_level, log_domains, NULL, NULL); + g_assert (success); + } +#endif } else { #if GLIB_CHECK_VERSION(2,34,0) /* We were called not to set logging levels. This means, that the user -- cgit v1.2.1