diff options
author | Thomas Haller <thaller@redhat.com> | 2015-02-16 16:02:59 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2015-02-16 16:09:40 +0100 |
commit | 5e74891b58688a19c43fb8e50880166d94a4e901 (patch) | |
tree | 0be985c66d4c393774d2d38ee9d5979ec9201f8d | |
parent | 96b8b99c7ddc9320af8f5df6407f3b19e2db8175 (diff) | |
download | NetworkManager-5e74891b58688a19c43fb8e50880166d94a4e901.tar.gz |
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/
-rw-r--r-- | include/nm-test-utils.h | 12 |
1 files changed, 12 insertions, 0 deletions
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 |