Test removing a destination
This commit is contained in:
@@ -63,6 +63,54 @@ START_TEST (test_logfile_location)
|
||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_logfile_delete_destination)
|
||||
|
||||
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_log_add_destination(dest); //adding this twice should do nothing
|
||||
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n");
|
||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n");
|
||||
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n");
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
||||
|
||||
uc_log_delete_destination(dest);
|
||||
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d\n", 1);
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson 2\n");
|
||||
UC_LOGF(UC_LL_INFO, 0, "Lorum ipson 3\n");
|
||||
UC_LOGF(UC_LL_WARNING, 0, "Lorum ipson 4\n");
|
||||
UC_LOGF(UC_LL_ERROR, 0, "Lorum ipson 5\n");
|
||||
|
||||
//since we deleted destinatiion, no more logging should appear in the file
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s\n", strerror(errno));
|
||||
fail_if(st.st_size != 380, "was %ld\n", (long)st.st_size);
|
||||
|
||||
END_TEST
|
||||
|
||||
START_TEST (test_logfile_no_location)
|
||||
|
||||
struct uc_log_module m = {
|
||||
@@ -477,6 +525,7 @@ Suite *logging_suite(void)
|
||||
TCase *tc2 = tcase_create("ucore_logging2");
|
||||
|
||||
tcase_add_test(tc1, test_logfile_location);
|
||||
tcase_add_test(tc1, test_logfile_delete_destination);
|
||||
tcase_add_test(tc1, test_logfile_no_location);
|
||||
tcase_add_test(tc1, test_logfile_loglevel_surpressed_dest);
|
||||
tcase_add_test(tc1, test_logfile_loglevel_surpressed_module);
|
||||
|
||||
Reference in New Issue
Block a user