test raw logging

This commit is contained in:
root
2012-11-08 23:33:17 +01:00
parent 8f53cc6563
commit c582a33365
2 changed files with 40 additions and 1 deletions
+8 -1
View File
@@ -46,8 +46,15 @@ int main(int argc, char *argv[])
UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d\n", 2); UC_LOGF( UC_LL_WARNING, HO, "Test HO warning%d\n", 2);
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info \n" ); UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN info \n" );
UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning\n" ); UC_LOGF( UC_LL_WARNING, MAIN, "Test MAIN warning\n" );
uc_log_module_set_loglevel(MAIN, UC_LL_INFO); uc_log_module_set_loglevel(MAIN, UC_LL_INFO);
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN warning 2\n" ); UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 2\n" );
UC_LOGFR(UC_LL_INFO, MAIN, "Test RAW logging 1\n" );
uc_log_module_set_loglevel(MAIN, UC_LL_WARNING);
UC_LOGF( UC_LL_INFO, MAIN, "Test MAIN INFO 3\n" );
return 1; return 1;
} }
+32
View File
@@ -331,6 +331,36 @@ START_TEST (test_logfile_invalid_file_after_repoen)
END_TEST END_TEST
START_TEST (test_logfile_raw)
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_DEBUG, 1);
fail_if(dest == NULL);
uc_log_add_destination(dest);
UC_LOGFR(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
UC_LOGFR(UC_LL_DEBUG, 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 != 14*2, "was %ld\n", (long)st.st_size);
END_TEST
Suite *logging_suite(void) Suite *logging_suite(void)
{ {
@@ -351,6 +381,8 @@ Suite *logging_suite(void)
} }
tcase_add_test(tc1, test_logfile_invalid_file); tcase_add_test(tc1, test_logfile_invalid_file);
tcase_add_test(tc2, test_logfile_invalid_file_after_repoen); tcase_add_test(tc2, test_logfile_invalid_file_after_repoen);
tcase_add_test(tc2, test_logfile_raw);
tcase_add_checked_fixture(tc1, logging_rm_files, logging_rm_files); tcase_add_checked_fixture(tc1, logging_rm_files, logging_rm_files);
tcase_add_checked_fixture(tc2, logging_setup_subdir, logging_rm_subdir); tcase_add_checked_fixture(tc2, logging_setup_subdir, logging_rm_subdir);