Update tests for new check library & osx

This commit is contained in:
Nils O. Selåsdal
2025-06-28 00:56:58 +02:00
parent 9d2ed015f3
commit fb8979d695
29 changed files with 449 additions and 27 deletions
+17 -4
View File
@@ -10,7 +10,7 @@
#include "ucore/restart_counter.h"
#define FILE_NAME "restart_counter_test"
//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)
@@ -20,6 +20,7 @@ static void logging_rm_files(void)
START_TEST (test_restart_counter)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -33,9 +34,11 @@ START_TEST (test_restart_counter)
ck_assert_int_eq(1, uc_restart_counter_get(&cnt));
}
END_TEST
START_TEST (test_restart_counter_existing)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -50,9 +53,11 @@ START_TEST (test_restart_counter_existing)
fail_if(rc != UC_RC_OK);
ck_assert_int_eq(100000, uc_restart_counter_get(&cnt));
}
END_TEST
START_TEST (test_restart_counter_inaccessible_file)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -60,8 +65,10 @@ START_TEST (test_restart_counter_inaccessible_file)
rc = uc_restart_counter_init(&cnt, "/should/not/exist/abc", 0);
fail_if(rc != UC_RC_ERR_FILE_ACCESS_ERROR);
}
END_TEST
START_TEST (test_restart_counter_garble)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -78,9 +85,11 @@ START_TEST (test_restart_counter_garble)
fail_if(rc != UC_RC_OK, "%d", rc);
ck_assert_int_eq(1, uc_restart_counter_get(&cnt));
}
END_TEST
START_TEST (test_restart_counter_full_filesystem)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -88,9 +97,11 @@ START_TEST (test_restart_counter_full_filesystem)
rc = uc_restart_counter_init(&cnt, "/dev/full", 0);
fail_if(rc != UC_RC_ERR_UNSPECIFIED);
}
END_TEST
#ifndef __APPLE__
START_TEST (test_restart_counter_lock_file)
{
UCRCResult rc;
struct UCRestartCounter cnt;
@@ -126,8 +137,9 @@ START_TEST (test_restart_counter_lock_file)
_exit(0);
}
}
END_TEST
#endif
Suite *restart_counter_suite(void)
{
@@ -143,8 +155,9 @@ Suite *restart_counter_suite(void)
} else {
puts("Cannot access /dev/full. Not testing test_logfile_full_filesystem");
}
#ifndef __APPLE__
tcase_add_test(tc1, test_restart_counter_lock_file);
#endif
tcase_add_checked_fixture(tc1, logging_rm_files, logging_rm_files);
suite_add_tcase(s, tc1);