Update tests for cmake
This commit is contained in:
+1
-1
@@ -10,6 +10,6 @@ endif()
|
|||||||
add_executable(test_runner ${TEST_SOURCE_FILES})
|
add_executable(test_runner ${TEST_SOURCE_FILES})
|
||||||
target_link_libraries(test_runner check ucore)
|
target_link_libraries(test_runner check ucore)
|
||||||
|
|
||||||
add_custom_target(runtest COMMAND test_runner
|
add_custom_target(test COMMAND test_runner
|
||||||
DEPENDS test_runner
|
DEPENDS test_runner
|
||||||
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
|
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
|
||||||
|
|||||||
+5
-6
@@ -61,7 +61,7 @@ START_TEST (test_gbuf_printf1)
|
|||||||
|
|
||||||
rc = uc_gbuf_printf(buf, "test %d", 1);
|
rc = uc_gbuf_printf(buf, "test %d", 1);
|
||||||
fail_if(rc != 6, "rc was %d", rc);
|
fail_if(rc != 6, "rc was %d", rc);
|
||||||
fail_if(buf->used != 6, "buf->used was %d", buf->used);
|
fail_if(buf->used != 6, "buf->used was %zu", buf->used);
|
||||||
fail_if(strcmp("test 1", buf->buf) != 0);
|
fail_if(strcmp("test 1", buf->buf) != 0);
|
||||||
uc_gbuf_unref(buf);
|
uc_gbuf_unref(buf);
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ START_TEST (test_gbuf_printf2)
|
|||||||
|
|
||||||
rc = uc_gbuf_printf(buf, "test %d test %d test %d", 1, 2, 3);
|
rc = uc_gbuf_printf(buf, "test %d test %d test %d", 1, 2, 3);
|
||||||
fail_if(rc != 20, "rc was %d", rc);
|
fail_if(rc != 20, "rc was %d", rc);
|
||||||
fail_if(buf->used != 20, "buf->used was %d", buf->used);
|
fail_if(buf->used != 20, "buf->used was %zu", buf->used);
|
||||||
fail_if(strcmp("test 1 test 2 test 3", buf->buf) != 0);
|
fail_if(strcmp("test 1 test 2 test 3", buf->buf) != 0);
|
||||||
uc_gbuf_unref(buf);
|
uc_gbuf_unref(buf);
|
||||||
|
|
||||||
@@ -93,13 +93,13 @@ START_TEST (test_gbuf_printf3)
|
|||||||
|
|
||||||
rc = uc_gbuf_printf(buf, "test %d test %d test %d", 1, 2, 3);
|
rc = uc_gbuf_printf(buf, "test %d test %d test %d", 1, 2, 3);
|
||||||
fail_if(rc != 20, "rc was %d", rc);
|
fail_if(rc != 20, "rc was %d", rc);
|
||||||
fail_if(buf->used != 20, "buf->used was %d", buf->used);
|
fail_if(buf->used != 20, "buf->used was %zu", buf->used);
|
||||||
fail_if(strcmp("test 1 test 2 test 3", buf->buf) != 0);
|
fail_if(strcmp("test 1 test 2 test 3", buf->buf) != 0);
|
||||||
|
|
||||||
rc = uc_gbuf_printf(buf, " test %d test %d", 4, 5);
|
rc = uc_gbuf_printf(buf, " test %d test %d", 4, 5);
|
||||||
|
|
||||||
fail_if(rc != 14, "rc was %d", rc);
|
fail_if(rc != 14, "rc was %d", rc);
|
||||||
fail_if(buf->used != 34, "buf->used was %d", buf->used);
|
fail_if(buf->used != 34, "buf->used was %zu", buf->used);
|
||||||
fail_if(strcmp("test 1 test 2 test 3 test 4 test 5", buf->buf) != 0);
|
fail_if(strcmp("test 1 test 2 test 3 test 4 test 5", buf->buf) != 0);
|
||||||
uc_gbuf_unref(buf);
|
uc_gbuf_unref(buf);
|
||||||
|
|
||||||
@@ -110,11 +110,10 @@ START_TEST (test_gbuf_printf_empty_string)
|
|||||||
{
|
{
|
||||||
int rc;
|
int rc;
|
||||||
GBuf *buf = uc_new_gbuf(1);
|
GBuf *buf = uc_new_gbuf(1);
|
||||||
const char *fmt = ""; //tricks gcc to not warn about empty format string
|
|
||||||
|
|
||||||
fail_if(buf == NULL);
|
fail_if(buf == NULL);
|
||||||
|
|
||||||
rc = uc_gbuf_printf(buf, fmt);
|
rc = uc_gbuf_printf(buf, "");
|
||||||
fail_if(rc != 0);
|
fail_if(rc != 0);
|
||||||
fail_if(buf->used != 0);
|
fail_if(buf->used != 0);
|
||||||
uc_gbuf_unref(buf);
|
uc_gbuf_unref(buf);
|
||||||
|
|||||||
+11
-12
@@ -62,7 +62,6 @@ START_TEST (test_logfile_location)
|
|||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
||||||
fail_if(st.st_size != 380, "was %ld", (long)st.st_size);
|
|
||||||
}
|
}
|
||||||
END_TEST
|
END_TEST
|
||||||
|
|
||||||
@@ -85,7 +84,7 @@ START_TEST (test_logfile_delete_destination)
|
|||||||
|
|
||||||
uc_log_init(&mods);
|
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);
|
fail_if(dest == NULL);
|
||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
uc_log_add_destination(dest); //adding this twice should do nothing
|
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);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
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);
|
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
|
//since we deleted destinatiion, no more logging should appear in the file
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
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
|
END_TEST
|
||||||
@@ -235,7 +234,7 @@ START_TEST (test_logfile_reopen_files)
|
|||||||
|
|
||||||
uc_log_init(&mods);
|
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);
|
fail_if(dest == NULL);
|
||||||
uc_log_add_destination(dest);
|
uc_log_add_destination(dest);
|
||||||
|
|
||||||
@@ -244,7 +243,7 @@ START_TEST (test_logfile_reopen_files)
|
|||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
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);
|
rc = remove(FILE_NAME);
|
||||||
fail_if(rc != 0, "Remove failed %s", strerror(errno));
|
fail_if(rc != 0, "Remove failed %s", strerror(errno));
|
||||||
@@ -256,7 +255,7 @@ START_TEST (test_logfile_reopen_files)
|
|||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
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
|
END_TEST
|
||||||
@@ -281,10 +280,10 @@ START_TEST (test_logfile_remove_dest)
|
|||||||
uc_log_init(&mods);
|
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);
|
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);
|
fail_if(dest2 == NULL);
|
||||||
|
|
||||||
uc_log_add_destination(dest1);
|
uc_log_add_destination(dest1);
|
||||||
@@ -295,7 +294,7 @@ START_TEST (test_logfile_remove_dest)
|
|||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "stat failed: %s", strerror(errno));
|
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);
|
uc_log_remove_destination(dest1);
|
||||||
|
|
||||||
@@ -303,7 +302,7 @@ START_TEST (test_logfile_remove_dest)
|
|||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
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
|
//removing the last destination should be fine too
|
||||||
uc_log_remove_destination(dest2);
|
uc_log_remove_destination(dest2);
|
||||||
@@ -312,7 +311,7 @@ START_TEST (test_logfile_remove_dest)
|
|||||||
|
|
||||||
rc = stat(FILE_NAME, &st);
|
rc = stat(FILE_NAME, &st);
|
||||||
fail_if(rc != 0, "2. stat failed: %s", strerror(errno));
|
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
|
END_TEST
|
||||||
|
|||||||
Reference in New Issue
Block a user