Update tests for cmake
This commit is contained in:
+16
-17
@@ -10,7 +10,7 @@
|
||||
#define FILE_NAME "logfile_test.log"
|
||||
#define SUBDIR "log_subdir"
|
||||
#define SUBDIR_FILE_NAME SUBDIR "/" FILE_NAME
|
||||
//Note that these tests are comewhat fragile as they depend on the
|
||||
//Note that these tests are comewhat fragile as they depend on the
|
||||
//file sizes that are created, which depends on the (relative)paths of this file.
|
||||
//for cleaning the created log files..
|
||||
static void logging_rm_files(void)
|
||||
@@ -62,7 +62,6 @@ START_TEST (test_logfile_location)
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
||||
}
|
||||
END_TEST
|
||||
|
||||
@@ -85,7 +84,7 @@ START_TEST (test_logfile_delete_destination)
|
||||
|
||||
uc_log_init(&mods);
|
||||
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1);
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 0);
|
||||
fail_if(dest == NULL);
|
||||
uc_log_add_destination(dest);
|
||||
uc_log_add_destination(dest); //adding this twice should do nothing
|
||||
@@ -98,7 +97,7 @@ START_TEST (test_logfile_delete_destination)
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
||||
fail_if(st.st_size != 260, "was %ld", (long)st.st_size);
|
||||
|
||||
uc_log_delete_destination(dest);
|
||||
|
||||
@@ -111,7 +110,7 @@ START_TEST (test_logfile_delete_destination)
|
||||
//since we deleted destinatiion, no more logging should appear in the file
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
||||
fail_if(st.st_size != 260, "was %ld", (long)st.st_size);
|
||||
|
||||
}
|
||||
END_TEST
|
||||
@@ -169,7 +168,7 @@ START_TEST (test_logfile_loglevel_surpressed_dest)
|
||||
|
||||
|
||||
//file destination have UC_LL_WARNING, so nothing should be logged
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_WARNING, 10);
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_WARNING, 10);
|
||||
fail_if(dest == NULL);
|
||||
uc_log_add_destination(dest);
|
||||
|
||||
@@ -203,7 +202,7 @@ START_TEST (test_logfile_loglevel_surpressed_module)
|
||||
uc_log_init(&mods);
|
||||
|
||||
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1);
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1);
|
||||
fail_if(dest == NULL);
|
||||
uc_log_add_destination(dest);
|
||||
|
||||
@@ -235,7 +234,7 @@ START_TEST (test_logfile_reopen_files)
|
||||
|
||||
uc_log_init(&mods);
|
||||
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1);
|
||||
dest = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 0);
|
||||
fail_if(dest == NULL);
|
||||
uc_log_add_destination(dest);
|
||||
|
||||
@@ -244,11 +243,11 @@ START_TEST (test_logfile_reopen_files)
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);
|
||||
fail_if(st.st_size != 104, "was %ld", (long)st.st_size);
|
||||
|
||||
rc = remove(FILE_NAME);
|
||||
fail_if(rc != 0, "Remove failed %s", strerror(errno));
|
||||
|
||||
|
||||
rc = uc_log_reopen_files();
|
||||
fail_if(rc != 0, "uc_log_reopen_files failed: %d", rc);
|
||||
|
||||
@@ -256,7 +255,7 @@ START_TEST (test_logfile_reopen_files)
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 77, "was %ld", (long)st.st_size);//should only one line there now
|
||||
fail_if(st.st_size != 52, "was %ld", (long)st.st_size);//should only one line there now
|
||||
|
||||
}
|
||||
END_TEST
|
||||
@@ -281,10 +280,10 @@ START_TEST (test_logfile_remove_dest)
|
||||
uc_log_init(&mods);
|
||||
|
||||
|
||||
dest1 = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 1);
|
||||
dest1 = uc_log_new_file(FILE_NAME, UC_LL_DEBUG, 0);
|
||||
fail_if(dest1 == NULL);
|
||||
|
||||
dest2 = uc_log_new_stderr(UC_LL_WARNING, 1);
|
||||
dest2 = uc_log_new_stderr(UC_LL_WARNING, 0);
|
||||
fail_if(dest2 == NULL);
|
||||
|
||||
uc_log_add_destination(dest1);
|
||||
@@ -295,7 +294,7 @@ START_TEST (test_logfile_remove_dest)
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);
|
||||
fail_if(st.st_size != 104, "was %ld", (long)st.st_size);
|
||||
|
||||
uc_log_remove_destination(dest1);
|
||||
|
||||
@@ -303,16 +302,16 @@ START_TEST (test_logfile_remove_dest)
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size
|
||||
fail_if(st.st_size != 104, "was %ld", (long)st.st_size);//should be same size
|
||||
|
||||
//removing the last destination should be fine too
|
||||
uc_log_remove_destination(dest2);
|
||||
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||
UC_LOGF(UC_LL_DEBUG, 0, "Lorum ipson %d", 1);
|
||||
|
||||
rc = stat(FILE_NAME, &st);
|
||||
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
||||
fail_if(st.st_size != 77*2, "was %ld", (long)st.st_size);//should be same size
|
||||
fail_if(st.st_size != 104, "was %ld", (long)st.st_size);//should be same size
|
||||
|
||||
}
|
||||
END_TEST
|
||||
|
||||
Reference in New Issue
Block a user