Update tests for cmake

This commit is contained in:
Nils O. Selåsdal
2025-07-16 19:51:06 +02:00
parent b74a4ab663
commit 2278080b69
4 changed files with 23 additions and 25 deletions
+1 -1
View File
@@ -10,6 +10,6 @@ endif()
add_executable(test_runner ${TEST_SOURCE_FILES})
target_link_libraries(test_runner check ucore)
add_custom_target(runtest COMMAND test_runner
add_custom_target(test COMMAND test_runner
DEPENDS test_runner
WORKING_DIRECTORY ${CMAKE_PROJECT_DIR})
+5 -6
View File
@@ -61,7 +61,7 @@ START_TEST (test_gbuf_printf1)
rc = uc_gbuf_printf(buf, "test %d", 1);
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);
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);
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);
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);
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);
rc = uc_gbuf_printf(buf, " test %d test %d", 4, 5);
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);
uc_gbuf_unref(buf);
@@ -110,11 +110,10 @@ START_TEST (test_gbuf_printf_empty_string)
{
int rc;
GBuf *buf = uc_new_gbuf(1);
const char *fmt = ""; //tricks gcc to not warn about empty format string
fail_if(buf == NULL);
rc = uc_gbuf_printf(buf, fmt);
rc = uc_gbuf_printf(buf, "");
fail_if(rc != 0);
fail_if(buf->used != 0);
uc_gbuf_unref(buf);
+11 -12
View File
@@ -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
@@ -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,7 +243,7 @@ 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));
@@ -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,7 +302,7 @@ 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);
@@ -312,7 +311,7 @@ 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
}
END_TEST