From bcf0d66e4ea39e464bd7ad1e2c3e4cf4cdfbfdb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nils=20O=2E=20Sel=C3=A5sdal?= Date: Thu, 20 Jun 2013 20:15:19 +0200 Subject: [PATCH] Add LL_NONE test --- test/test_logging.c | 61 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/test/test_logging.c b/test/test_logging.c index d0ad57f..76d1919 100644 --- a/test/test_logging.c +++ b/test/test_logging.c @@ -410,6 +410,64 @@ START_TEST (test_logfile_dest_mask) fail_if(st.st_size != 14*2, "was %ld\n", (long)st.st_size); END_TEST +START_TEST (test_loglevel_module_none) + + struct uc_log_module m = { + .id = 0, + .short_name = "MOD1", + .long_name = "Module 1", + .log_level = UC_LL_NONE, + }; + struct uc_log_modules mods = { + .mods = &m, + .cnt = 1, + }; + struct stat st; + struct uc_log_destination *dest; + int rc; + + uc_log_init(&mods); + + dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1); + fail_if(dest == NULL); + uc_log_add_destination(dest); + + UC_LOGFR(UC_LL_ERROR, 0, "Lorum ipson %d\n", 1); + + rc = stat(FILE_NAME, &st); + fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); + fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); +END_TEST + +START_TEST (test_loglevel_dest_none) + + struct uc_log_module m = { + .id = 0, + .short_name = "MOD1", + .long_name = "Module 1", + .log_level = UC_LL_DEBUG, + }; + struct uc_log_modules mods = { + .mods = &m, + .cnt = 1, + }; + struct stat st; + struct uc_log_destination *dest; + int rc; + + uc_log_init(&mods); + + dest = uc_log_new_file(FILE_NAME, UC_LL_NONE, 1); + fail_if(dest == NULL); + uc_log_add_destination(dest); + + UC_LOGFR(UC_LL_WARNING, 0, "Lorum ipson %d\n", 1); + + rc = stat(FILE_NAME, &st); + fail_if(rc != 0, "stat failed: %s\n", strerror(errno)); + fail_if(st.st_size != 0, "was %ld\n", (long)st.st_size); +END_TEST + Suite *logging_suite(void) { @@ -435,6 +493,9 @@ Suite *logging_suite(void) tcase_add_test(tc2, test_logfile_invalid_file_after_reopen); tcase_add_test(tc1, test_logfile_raw); + tcase_add_test(tc1, test_loglevel_module_none); + tcase_add_test(tc1, test_loglevel_dest_none); + tcase_add_checked_fixture(tc1, logging_rm_files, logging_rm_files); tcase_add_checked_fixture(tc2, logging_setup_subdir, logging_rm_subdir);