From 86693d237810d9380974bb7ca59ec5a420029020 Mon Sep 17 00:00:00 2001 From: Thomas Haller Date: Mon, 14 Apr 2014 12:03:05 +0200 Subject: [PATCH] nmtst: add parameter to nmtst_init to setup nm-logging Signed-off-by: Thomas Haller --- include/nm-test-utils.h | 10 +++++++++- src/logging/nm-logging.h | 4 ++++ src/tests/test-ip6-config.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/nm-test-utils.h b/include/nm-test-utils.h index 8de9d15861..20e867f0b8 100644 --- a/include/nm-test-utils.h +++ b/include/nm-test-utils.h @@ -41,7 +41,7 @@ extern struct __nmtst_internal __nmtst_internal; struct __nmtst_internal __nmtst_internal = { 0 }; inline static void -nmtst_init (int *argc, char ***argv) +nmtst_init (int *argc, char ***argv, const char *log_level, const char *log_domains) { g_assert (!__nmtst_internal.rand0); @@ -58,6 +58,14 @@ nmtst_init (int *argc, char ***argv) #endif __nmtst_internal.rand0 = g_rand_new_with_seed (0); + + if (log_level || log_domains) { + gboolean success = FALSE; +#ifdef NM_LOGGING_H + success = nm_logging_setup (log_level, log_domains, NULL, NULL); +#endif + g_assert (success); + } } inline static GRand * diff --git a/src/logging/nm-logging.h b/src/logging/nm-logging.h index c3984483e6..a53f93a55a 100644 --- a/src/logging/nm-logging.h +++ b/src/logging/nm-logging.h @@ -22,6 +22,10 @@ #ifndef NM_LOGGING_H #define NM_LOGGING_H +#ifdef __NM_TEST_UTILS_H__ +#error nm-test-utils.h must be included as last header +#endif + #include #include diff --git a/src/tests/test-ip6-config.c b/src/tests/test-ip6-config.c index 21fa9b0c7a..8d376aa3ac 100644 --- a/src/tests/test-ip6-config.c +++ b/src/tests/test-ip6-config.c @@ -324,7 +324,7 @@ NMTST_DEFINE(); int main (int argc, char **argv) { - nmtst_init (&argc, &argv); + nmtst_init (&argc, &argv, NULL, NULL); g_test_add_func ("/ip6-config/subtract", test_subtract); g_test_add_func ("/ip6-config/compare-with-source", test_compare_with_source);