aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJoseph Hunkeler <jhunkeler@users.noreply.github.com>2024-06-21 12:49:45 -0400
committerGitHub <noreply@github.com>2024-06-21 12:49:45 -0400
commit77a0276d9f37bcf828c77f9bcc59ff945116274e (patch)
tree91cf7cb955798ad40718341172b0a8ffbc59a1f2 /tests
parent931ee28eb9c5b5e3c2b0d3008f5f65d810dc9b0c (diff)
downloadstasis-77a0276d9f37bcf828c77f9bcc59ff945116274e.tar.gz
Rebrand OhMyCal (OMC) as STASIS (#7)
Diffstat (limited to 'tests')
-rw-r--r--tests/CMakeLists.txt2
-rw-r--r--tests/test_docker.c40
-rw-r--r--tests/test_ini.c80
-rw-r--r--tests/test_relocation.c20
-rw-r--r--tests/test_str.c54
-rw-r--r--tests/test_strlist.c94
-rw-r--r--tests/test_system.c64
-rw-r--r--tests/test_template.c32
-rw-r--r--tests/test_utils.c132
-rw-r--r--tests/testing.h86
10 files changed, 302 insertions, 302 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5b45d58..f3a45e8 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -21,7 +21,7 @@ foreach(file ${files})
elseif (CMAKE_C_COMPILER_ID STREQUAL "MSVC")
target_compile_options(${file_without_ext} PRIVATE ${win_cflags} ${win_msvc_cflags})
endif()
- target_link_libraries(${file_without_ext} PRIVATE ohmycal)
+ target_link_libraries(${file_without_ext} PRIVATE stasis_core)
add_test(${file_without_ext} ${file_without_ext})
set_tests_properties(${file_without_ext}
PROPERTIES
diff --git a/tests/test_docker.c b/tests/test_docker.c
index eac385e..04a73aa 100644
--- a/tests/test_docker.c
+++ b/tests/test_docker.c
@@ -4,16 +4,16 @@ struct DockerCapabilities cap_suite;
void test_docker_capable() {
struct DockerCapabilities cap;
int result = docker_capable(&cap);
- OMC_ASSERT(result == true, "docker installation unusable");
- OMC_ASSERT(cap.available, "docker is not available");
- OMC_ASSERT(cap.build != 0, "docker cannot build images");
+ STASIS_ASSERT(result == true, "docker installation unusable");
+ STASIS_ASSERT(cap.available, "docker is not available");
+ STASIS_ASSERT(cap.build != 0, "docker cannot build images");
// no cap.podman assertion. doesn't matter if we have docker or podman
- OMC_ASSERT(cap.usable, "docker is unusable");
+ STASIS_ASSERT(cap.usable, "docker is unusable");
}
void test_docker_exec() {
- OMC_ASSERT(docker_exec("system info", 0) == 0, "unable to print docker information");
- OMC_ASSERT(docker_exec("system info", OMC_DOCKER_QUIET) == 0, "unable to be quiet");
+ STASIS_ASSERT(docker_exec("system info", 0) == 0, "unable to print docker information");
+ STASIS_ASSERT(docker_exec("system info", STASIS_DOCKER_QUIET) == 0, "unable to be quiet");
}
void test_docker_sanitize_tag() {
@@ -27,47 +27,47 @@ void test_docker_sanitize_tag() {
break;
}
}
- OMC_ASSERT(result == 0, "proper tag characters were not replaced correctly");
+ STASIS_ASSERT(result == 0, "proper tag characters were not replaced correctly");
guard_free(input);
}
void test_docker_build_and_script_and_save() {
- OMC_SKIP_IF(docker_exec("pull alpine:latest", OMC_DOCKER_QUIET), "unable to pull an image");
+ STASIS_SKIP_IF(docker_exec("pull alpine:latest", STASIS_DOCKER_QUIET), "unable to pull an image");
const char *dockerfile_contents = "FROM alpine:latest\nCMD [\"sh\", \"-l\"]\n";
mkdir("test_docker_build", 0755);
if (!pushd("test_docker_build")) {
- omc_testing_write_ascii("Dockerfile", dockerfile_contents);
- OMC_ASSERT(docker_build(".", "-t test_docker_build", cap_suite.build) == 0, "docker build test failed");
- OMC_ASSERT(docker_script("test_docker_build", "uname -a", 0) == 0, "simple docker container script execution failed");
- OMC_ASSERT(docker_save("test_docker_build", ".", OMC_DOCKER_IMAGE_COMPRESSION) == 0, "saving a simple image failed");
- OMC_ASSERT(docker_exec("load < test_docker_build.tar.*", 0) == 0, "loading a simple image failed");
+ stasis_testing_write_ascii("Dockerfile", dockerfile_contents);
+ STASIS_ASSERT(docker_build(".", "-t test_docker_build", cap_suite.build) == 0, "docker build test failed");
+ STASIS_ASSERT(docker_script("test_docker_build", "uname -a", 0) == 0, "simple docker container script execution failed");
+ STASIS_ASSERT(docker_save("test_docker_build", ".", STASIS_DOCKER_IMAGE_COMPRESSION) == 0, "saving a simple image failed");
+ STASIS_ASSERT(docker_exec("load < test_docker_build.tar.*", 0) == 0, "loading a simple image failed");
docker_exec("image rm -f test_docker_build", 0);
remove("Dockerfile");
popd();
remove("test_docker_build");
} else {
- OMC_ASSERT(false, "dir change failed");
+ STASIS_ASSERT(false, "dir change failed");
return;
}
}
void test_docker_validate_compression_program() {
- OMC_ASSERT(docker_validate_compression_program(OMC_DOCKER_IMAGE_COMPRESSION) == 0, "baked-in compression program does not exist");
+ STASIS_ASSERT(docker_validate_compression_program(STASIS_DOCKER_IMAGE_COMPRESSION) == 0, "baked-in compression program does not exist");
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
+ STASIS_TEST_BEGIN_MAIN();
if (!docker_capable(&cap_suite)) {
- return OMC_TEST_SUITE_SKIP;
+ return STASIS_TEST_SUITE_SKIP;
}
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_FUNC *tests[] = {
test_docker_capable,
test_docker_exec,
test_docker_build_and_script_and_save,
test_docker_sanitize_tag,
test_docker_validate_compression_program,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/test_ini.c b/tests/test_ini.c
index f9f8234..5958cfd 100644
--- a/tests/test_ini.c
+++ b/tests/test_ini.c
@@ -4,22 +4,22 @@
void test_ini_open_empty() {
struct INIFILE *ini;
ini = ini_open("/dev/null");
- OMC_ASSERT(ini->section_count == 1, "should have at least one section pre-allocated");
- OMC_ASSERT(ini->section != NULL, "default section not present");
+ STASIS_ASSERT(ini->section_count == 1, "should have at least one section pre-allocated");
+ STASIS_ASSERT(ini->section != NULL, "default section not present");
ini_free(&ini);
- OMC_ASSERT(ini == NULL, "ini_free did not set pointer argument to NULL");
+ STASIS_ASSERT(ini == NULL, "ini_free did not set pointer argument to NULL");
}
void test_ini_open() {
const char *filename = "ini_open.ini";
const char *data = "[default]\na=1\nb=2\nc=3\n[section name]test=true\n";
struct INIFILE *ini;
- omc_testing_write_ascii(filename, data);
+ stasis_testing_write_ascii(filename, data);
ini = ini_open(filename);
- OMC_ASSERT(ini->section_count == 2, "should have two sections");
- OMC_ASSERT(ini->section != NULL, "sections are not allocated");
+ STASIS_ASSERT(ini->section_count == 2, "should have two sections");
+ STASIS_ASSERT(ini->section != NULL, "sections are not allocated");
ini_free(&ini);
- OMC_ASSERT(ini == NULL, "ini_free did not set pointer argument to NULL");
+ STASIS_ASSERT(ini == NULL, "ini_free did not set pointer argument to NULL");
remove(filename);
}
@@ -29,27 +29,27 @@ void test_ini_section_search() {
struct INIFILE *ini;
struct INISection *section;
- omc_testing_write_ascii(filename, data);
+ stasis_testing_write_ascii(filename, data);
ini = ini_open(filename);
section = ini_section_search(&ini, INI_SEARCH_BEGINS, "section");
- OMC_ASSERT(section->data_count == 1, "should have one data variable");
- OMC_ASSERT(strcmp(section->data[0]->key, "test") == 0, "should have one data variable named 'test'");
- OMC_ASSERT(strcmp(section->data[0]->value, "true") == 0, "'test' should be equal to 'true'");
- OMC_ASSERT(strcmp(section->key, "section name here") == 0, "defined section not found");
+ STASIS_ASSERT(section->data_count == 1, "should have one data variable");
+ STASIS_ASSERT(strcmp(section->data[0]->key, "test") == 0, "should have one data variable named 'test'");
+ STASIS_ASSERT(strcmp(section->data[0]->value, "true") == 0, "'test' should be equal to 'true'");
+ STASIS_ASSERT(strcmp(section->key, "section name here") == 0, "defined section not found");
section = ini_section_search(&ini, INI_SEARCH_SUBSTR, "name");
- OMC_ASSERT(strcmp(section->data[0]->key, "test") == 0, "should have one data variable named 'test'");
- OMC_ASSERT(strcmp(section->data[0]->value, "true") == 0, "'test' should be equal to 'true'");
- OMC_ASSERT(strcmp(section->key, "section name here") == 0, "defined section not found");
+ STASIS_ASSERT(strcmp(section->data[0]->key, "test") == 0, "should have one data variable named 'test'");
+ STASIS_ASSERT(strcmp(section->data[0]->value, "true") == 0, "'test' should be equal to 'true'");
+ STASIS_ASSERT(strcmp(section->key, "section name here") == 0, "defined section not found");
section = ini_section_search(&ini, INI_SEARCH_EXACT, "section name here");
- OMC_ASSERT(strcmp(section->data[0]->key, "test") == 0, "should have one data variable named 'test'");
- OMC_ASSERT(strcmp(section->data[0]->value, "true") == 0, "'test' should be equal to 'true'");
- OMC_ASSERT(strcmp(section->key, "section name here") == 0, "defined section not found");
+ STASIS_ASSERT(strcmp(section->data[0]->key, "test") == 0, "should have one data variable named 'test'");
+ STASIS_ASSERT(strcmp(section->data[0]->value, "true") == 0, "'test' should be equal to 'true'");
+ STASIS_ASSERT(strcmp(section->key, "section name here") == 0, "defined section not found");
section = ini_section_search(&ini, INI_SEARCH_BEGINS, "bogus");
- OMC_ASSERT(section == NULL, "bogus section search returned non-NULL");
+ STASIS_ASSERT(section == NULL, "bogus section search returned non-NULL");
section = ini_section_search(&ini, INI_SEARCH_BEGINS, NULL);
- OMC_ASSERT(section == NULL, "NULL argument returned non-NULL");
+ STASIS_ASSERT(section == NULL, "NULL argument returned non-NULL");
ini_free(&ini);
remove(filename);
}
@@ -59,15 +59,15 @@ void test_ini_has_key() {
const char *data = "[default]\na=1\nb=2\nc=3\n[section name here]\ntest=true\n";
struct INIFILE *ini;
- omc_testing_write_ascii(filename, data);
+ stasis_testing_write_ascii(filename, data);
ini = ini_open(filename);
- OMC_ASSERT(ini_has_key(ini, "default", "a") == true, "'default:a' key should exist");
- OMC_ASSERT(ini_has_key(NULL, "default", NULL) == false, "NULL ini object should return false");
- OMC_ASSERT(ini_has_key(ini, "default", NULL) == false, "NULL key should return false");
- OMC_ASSERT(ini_has_key(ini, NULL, "a") == false, "NULL section should return false");
- OMC_ASSERT(ini_has_key(ini, "default", "noname") == false, "'default:noname' key should not exist");
- OMC_ASSERT(ini_has_key(ini, "doesnotexist", "name") == false, "'doesnotexist:name' key should not exist");
+ STASIS_ASSERT(ini_has_key(ini, "default", "a") == true, "'default:a' key should exist");
+ STASIS_ASSERT(ini_has_key(NULL, "default", NULL) == false, "NULL ini object should return false");
+ STASIS_ASSERT(ini_has_key(ini, "default", NULL) == false, "NULL key should return false");
+ STASIS_ASSERT(ini_has_key(ini, NULL, "a") == false, "NULL section should return false");
+ STASIS_ASSERT(ini_has_key(ini, "default", "noname") == false, "'default:noname' key should not exist");
+ STASIS_ASSERT(ini_has_key(ini, "doesnotexist", "name") == false, "'doesnotexist:name' key should not exist");
ini_free(&ini);
remove(filename);
}
@@ -77,32 +77,32 @@ void test_ini_setval_getval() {
const char *data = "[default]\na=1\nb=2\nc=3\n[section name here]\ntest=true\n";
struct INIFILE *ini;
- omc_testing_write_ascii(filename, data);
+ stasis_testing_write_ascii(filename, data);
ini = ini_open(filename);
union INIVal val;
- OMC_ASSERT(ini_setval(&ini, INI_SETVAL_REPLACE, "default", "a", "changed") == 0, "failed to set value");
- OMC_ASSERT(ini_getval(ini, "default", "a", INIVAL_TYPE_STR, &val) == 0, "failed to get value");
- OMC_ASSERT(strcmp(val.as_char_p, "a") != 0, "unexpected value loaded from modified variable");
- OMC_ASSERT(strcmp(val.as_char_p, "changed") == 0, "unexpected value loaded from modified variable");
+ STASIS_ASSERT(ini_setval(&ini, INI_SETVAL_REPLACE, "default", "a", "changed") == 0, "failed to set value");
+ STASIS_ASSERT(ini_getval(ini, "default", "a", INIVAL_TYPE_STR, &val) == 0, "failed to get value");
+ STASIS_ASSERT(strcmp(val.as_char_p, "a") != 0, "unexpected value loaded from modified variable");
+ STASIS_ASSERT(strcmp(val.as_char_p, "changed") == 0, "unexpected value loaded from modified variable");
- OMC_ASSERT(ini_setval(&ini, INI_SETVAL_APPEND, "default", "a", " twice") == 0, "failed to set value");
- OMC_ASSERT(ini_getval(ini, "default", "a", INIVAL_TYPE_STR, &val) == 0, "failed to get value");
- OMC_ASSERT(strcmp(val.as_char_p, "changed") != 0, "unexpected value loaded from modified variable");
- OMC_ASSERT(strcmp(val.as_char_p, "changed twice") == 0, "unexpected value loaded from modified variable");
+ STASIS_ASSERT(ini_setval(&ini, INI_SETVAL_APPEND, "default", "a", " twice") == 0, "failed to set value");
+ STASIS_ASSERT(ini_getval(ini, "default", "a", INIVAL_TYPE_STR, &val) == 0, "failed to get value");
+ STASIS_ASSERT(strcmp(val.as_char_p, "changed") != 0, "unexpected value loaded from modified variable");
+ STASIS_ASSERT(strcmp(val.as_char_p, "changed twice") == 0, "unexpected value loaded from modified variable");
ini_free(&ini);
remove(filename);
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_ini_open_empty,
test_ini_open,
test_ini_section_search,
test_ini_has_key,
test_ini_setval_getval,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/test_relocation.c b/tests/test_relocation.c
index 0796074..a6c33f2 100644
--- a/tests/test_relocation.c
+++ b/tests/test_relocation.c
@@ -16,8 +16,8 @@ void test_replace_text() {
char input[BUFSIZ] = {0};
strcpy(input, test_string);
- OMC_ASSERT(replace_text(input, target, "^^^", 0) == 0, "string replacement failed");
- OMC_ASSERT(strcmp(input, expected) == 0, "unexpected replacement");
+ STASIS_ASSERT(replace_text(input, target, "^^^", 0) == 0, "string replacement failed");
+ STASIS_ASSERT(strcmp(input, expected) == 0, "unexpected replacement");
}
}
@@ -33,9 +33,9 @@ void test_file_replace_text() {
if (fp) {
fprintf(fp, "%s", test_string);
fclose(fp);
- OMC_ASSERT(file_replace_text(filename, target, "^^^", 0) == 0, "string replacement failed");
+ STASIS_ASSERT(file_replace_text(filename, target, "^^^", 0) == 0, "string replacement failed");
} else {
- OMC_ASSERT(false, "failed to open file for writing");
+ STASIS_ASSERT(false, "failed to open file for writing");
return;
}
@@ -43,20 +43,20 @@ void test_file_replace_text() {
fp = fopen(filename, "r");
if (fp) {
fread(input, sizeof(*input), sizeof(input), fp);
- OMC_ASSERT(strcmp(input, expected) == 0, "unexpected replacement");
+ STASIS_ASSERT(strcmp(input, expected) == 0, "unexpected replacement");
} else {
- OMC_ASSERT(false, "failed to open file for reading");
+ STASIS_ASSERT(false, "failed to open file for reading");
return;
}
}
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_replace_text,
test_file_replace_text,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/test_str.c b/tests/test_str.c
index fc2cf46..be3f3e1 100644
--- a/tests/test_str.c
+++ b/tests/test_str.c
@@ -15,8 +15,8 @@ void test_to_short_version() {
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result = to_short_version(tc[i].data);
- OMC_ASSERT_FATAL(result != NULL, "should not be NULL");
- OMC_ASSERT(strcmp(result, tc[i].expected) == 0, "unexpected result");
+ STASIS_ASSERT_FATAL(result != NULL, "should not be NULL");
+ STASIS_ASSERT(strcmp(result, tc[i].expected) == 0, "unexpected result");
guard_free(result);
}
@@ -38,7 +38,7 @@ void test_tolower_s() {
char input[100] = {0};
strcpy(input, tc[i].data);
tolower_s(input);
- OMC_ASSERT(strcmp(input, tc[i].expected) == 0, "unexpected result");
+ STASIS_ASSERT(strcmp(input, tc[i].expected) == 0, "unexpected result");
}
}
@@ -59,7 +59,7 @@ void test_isdigit_s() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- OMC_ASSERT(isdigit_s(tc[i].data) == tc[i].expected, "unexpected result");
+ STASIS_ASSERT(isdigit_s(tc[i].data) == tc[i].expected, "unexpected result");
}
}
@@ -75,10 +75,10 @@ void test_strdup_array_and_strcmp_array() {
.expected = (const char *[]) {"I", "have", "a", "pencil", "box", NULL}},
};
- OMC_ASSERT(strdup_array(NULL) == NULL, "returned non-NULL on NULL argument");
+ STASIS_ASSERT(strdup_array(NULL) == NULL, "returned non-NULL on NULL argument");
for (size_t outer = 0; outer < sizeof(tc) / sizeof(*tc); outer++) {
char **result = strdup_array((char **) tc[outer].data);
- OMC_ASSERT(strcmp_array((const char **) result, tc[outer].expected) == 0, "array members were different");
+ STASIS_ASSERT(strcmp_array((const char **) result, tc[outer].expected) == 0, "array members were different");
}
const struct testcase tc_bad[] = {
@@ -88,12 +88,12 @@ void test_strdup_array_and_strcmp_array() {
.expected = (const char *[]) {"I", "have", "a", "pencil", "box", NULL}},
};
- OMC_ASSERT(strcmp_array(tc[0].data, NULL) > 0, "right argument is NULL, expected positive return");
- OMC_ASSERT(strcmp_array(NULL, tc[0].data) < 0, "left argument is NULL, expected negative return");
- OMC_ASSERT(strcmp_array(NULL, NULL) == 0, "left and right arguments are NULL, expected zero return");
+ STASIS_ASSERT(strcmp_array(tc[0].data, NULL) > 0, "right argument is NULL, expected positive return");
+ STASIS_ASSERT(strcmp_array(NULL, tc[0].data) < 0, "left argument is NULL, expected negative return");
+ STASIS_ASSERT(strcmp_array(NULL, NULL) == 0, "left and right arguments are NULL, expected zero return");
for (size_t outer = 0; outer < sizeof(tc_bad) / sizeof(*tc_bad); outer++) {
char **result = strdup_array((char **) tc_bad[outer].data);
- OMC_ASSERT(strcmp_array((const char **) result, tc_bad[outer].expected) != 0, "array members were identical");
+ STASIS_ASSERT(strcmp_array((const char **) result, tc_bad[outer].expected) != 0, "array members were identical");
}
}
@@ -112,7 +112,7 @@ void test_strchrdel() {
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *data = strdup(tc[i].data);
strchrdel(data, tc[i].input);
- OMC_ASSERT(strcmp(data, tc[i].expected) == 0, "wrong status for condition");
+ STASIS_ASSERT(strcmp(data, tc[i].expected) == 0, "wrong status for condition");
guard_free(data);
}
}
@@ -138,7 +138,7 @@ void test_endswith() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
int result = endswith(tc[i].data, tc[i].input);
- OMC_ASSERT(result == tc[i].expected, "wrong status for condition");
+ STASIS_ASSERT(result == tc[i].expected, "wrong status for condition");
}
}
@@ -163,7 +163,7 @@ void test_startswith() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
int result = startswith(tc[i].data, tc[i].input);
- OMC_ASSERT(result == tc[i].expected, "wrong status for condition");
+ STASIS_ASSERT(result == tc[i].expected, "wrong status for condition");
}
}
@@ -180,7 +180,7 @@ void test_num_chars() {
{.data = "abc\t\ndef\nabc\ndef\n", .input = '\t', .expected = 1},
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
- OMC_ASSERT(num_chars(tc[i].data, tc[i].input) == tc[i].expected, "incorrect number of characters detected");
+ STASIS_ASSERT(num_chars(tc[i].data, tc[i].input) == tc[i].expected, "incorrect number of characters detected");
}
}
@@ -204,7 +204,7 @@ void test_split() {
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char **result;
result = split(tc[i].data, tc[i].delim, tc[i].max_split);
- OMC_ASSERT(strcmp_array(result, tc[i].expected) == 0, "Split failed");
+ STASIS_ASSERT(strcmp_array(result, tc[i].expected) == 0, "Split failed");
GENERIC_ARRAY_FREE(result);
}
}
@@ -224,7 +224,7 @@ void test_join() {
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result;
result = join(tc[i].data, tc[i].delim);
- OMC_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
+ STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
guard_free(result);
}
}
@@ -243,7 +243,7 @@ void test_join_ex() {
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result;
result = join_ex(tc[i].delim, "a", "b", "c", "d", "e", NULL);
- OMC_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
+ STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "failed to join array");
guard_free(result);
}
}
@@ -269,7 +269,7 @@ void test_substring_between() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *result = substring_between(tc[i].data, tc[i].delim);
- OMC_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "unable to extract substring");
+ STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "unable to extract substring");
guard_free(result);
}
}
@@ -288,7 +288,7 @@ void test_strdeldup() {
};
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char **result = strdeldup(tc[i].data);
- OMC_ASSERT(strcmp_array(result, tc[i].expected) == 0, "incorrect number of duplicates removed");
+ STASIS_ASSERT(strcmp_array(result, tc[i].expected) == 0, "incorrect number of duplicates removed");
GENERIC_ARRAY_FREE(result);
}
}
@@ -313,13 +313,13 @@ void test_lstrip() {
{.data = " I am a string.\n", .expected = "I am a string.\n"},
};
- OMC_ASSERT(lstrip(NULL) == NULL, "incorrect return type");
+ STASIS_ASSERT(lstrip(NULL) == NULL, "incorrect return type");
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *buf = calloc(255, sizeof(*buf));
char *result;
strcpy(buf, tc[i].data);
result = lstrip(buf);
- OMC_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-left");
+ STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-left");
guard_free(buf);
}
}
@@ -338,13 +338,13 @@ void test_strip() {
{.data = " ", .expected = ""},
};
- OMC_ASSERT(strip(NULL) == NULL, "incorrect return type");
+ STASIS_ASSERT(strip(NULL) == NULL, "incorrect return type");
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
char *buf = calloc(255, sizeof(*buf));
char *result;
strcpy(buf, tc[i].data);
result = strip(buf);
- OMC_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-right");
+ STASIS_ASSERT(strcmp(result ? result : "", tc[i].expected) == 0, "incorrect strip-from-right");
guard_free(buf);
}
}
@@ -354,8 +354,8 @@ void test_isempty() {
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_to_short_version,
test_tolower_s,
test_isdigit_s,
@@ -372,6 +372,6 @@ int main(int argc, char *argv[]) {
test_join_ex,
test_substring_between,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/test_strlist.c b/tests/test_strlist.c
index aa9eb4e..723c904 100644
--- a/tests/test_strlist.c
+++ b/tests/test_strlist.c
@@ -8,7 +8,7 @@ do { \
strlist_append(&list, (char *) tc[i].data); \
result = FUNC(list, i); \
if (!strlist_errno) { \
- OMC_ASSERT(result == (TYPE) tc[i].expected, "unexpected numeric result"); \
+ STASIS_ASSERT(result == (TYPE) tc[i].expected, "unexpected numeric result"); \
} \
} \
guard_strlist_free(&list); \
@@ -17,9 +17,9 @@ do { \
void test_strlist_init() {
struct StrList *list;
list = strlist_init();
- OMC_ASSERT(list != NULL, "list should not be NULL");
- OMC_ASSERT(list->num_alloc == 1, "fresh list should have one record allocated");
- OMC_ASSERT(list->num_inuse == 0, "fresh list should have no records in use");
+ STASIS_ASSERT(list != NULL, "list should not be NULL");
+ STASIS_ASSERT(list->num_alloc == 1, "fresh list should have one record allocated");
+ STASIS_ASSERT(list->num_inuse == 0, "fresh list should have no records in use");
guard_strlist_free(&list);
}
@@ -47,9 +47,9 @@ void test_strlist_append() {
list = strlist_init();
for (size_t i = 0; i < sizeof(tc) / sizeof(*tc); i++) {
strlist_append(&list, (char *) tc[i].data);
- OMC_ASSERT(list->num_inuse == tc[i].expected_in_use, "incorrect number of records in use");
- OMC_ASSERT(list->num_alloc == tc[i].expected_in_use + 1, "incorrect number of records allocated");
- OMC_ASSERT(strcmp(strlist_item(list, i), tc[i].data) == 0, "value was appended incorrectly. data mismatch.");
+ STASIS_ASSERT(list->num_inuse == tc[i].expected_in_use, "incorrect number of records in use");
+ STASIS_ASSERT(list->num_alloc == tc[i].expected_in_use + 1, "incorrect number of records allocated");
+ STASIS_ASSERT(strcmp(strlist_item(list, i), tc[i].data) == 0, "value was appended incorrectly. data mismatch.");
}
guard_strlist_free(&list);
}
@@ -62,7 +62,7 @@ void test_strlist_append_many_records() {
for (size_t i = 0; i < maxrec; i++) {
strlist_append(&list, (char *) data);
}
- OMC_ASSERT(strlist_count(list) == maxrec, "record count mismatch");
+ STASIS_ASSERT(strlist_count(list) == maxrec, "record count mismatch");
guard_strlist_free(&list);
}
@@ -86,7 +86,7 @@ void test_strlist_set() {
result = strcmp(strlist_item(list, i), replacement_long) == 0;
set_resize_long_all_ok += result;
}
- OMC_ASSERT(set_resize_long_all_ok == (int) maxrec, "Replacing record with longer strings failed");
+ STASIS_ASSERT(set_resize_long_all_ok == (int) maxrec, "Replacing record with longer strings failed");
for (size_t i = 0; i < maxrec; i++) {
int result;
@@ -94,9 +94,9 @@ void test_strlist_set() {
result = strcmp(strlist_item(list, i), replacement_short) == 0;
set_resize_short_all_ok += result;
}
- OMC_ASSERT(set_resize_short_all_ok == (int) maxrec, "Replacing record with shorter strings failed");
+ STASIS_ASSERT(set_resize_short_all_ok == (int) maxrec, "Replacing record with shorter strings failed");
- OMC_ASSERT(strlist_count(list) == maxrec, "record count mismatch");
+ STASIS_ASSERT(strlist_count(list) == maxrec, "record count mismatch");
guard_strlist_free(&list);
}
@@ -115,14 +115,14 @@ void test_strlist_append_file() {
const char *local_filename = "test_strlist_append_file.txt";
struct testcase tc[] = {
- {.origin = "https://ssb.stsci.edu/jhunk/omc_test/test_strlist_append_file_from_remote.txt", .expected = expected},
+ {.origin = "https://ssb.stsci.edu/jhunk/stasis_test/test_strlist_append_file_from_remote.txt", .expected = expected},
{.origin = local_filename, .expected = expected},
};
FILE *fp;
fp = fopen(local_filename, "w");
if (!fp) {
- OMC_ASSERT(false, "unable to open local file for writing");
+ STASIS_ASSERT(false, "unable to open local file for writing");
}
for (size_t i = 0; expected[i] != NULL; i++) {
fprintf(fp, "%s", expected[i]);
@@ -133,7 +133,7 @@ void test_strlist_append_file() {
struct StrList *list;
list = strlist_init();
if (!list) {
- OMC_ASSERT(false, "failed to create list");
+ STASIS_ASSERT(false, "failed to create list");
return;
}
strlist_append_file(list, (char *) tc[i].origin, NULL);
@@ -142,9 +142,9 @@ void test_strlist_append_file() {
const char *right;
left = strlist_item(list, z);
right = expected[z];
- OMC_ASSERT(strcmp(left, right) == 0, "file content is different than expected");
+ STASIS_ASSERT(strcmp(left, right) == 0, "file content is different than expected");
}
- OMC_ASSERT(strcmp_array(list->data, expected) == 0, "file contents does not match expected values");
+ STASIS_ASSERT(strcmp_array(list->data, expected) == 0, "file contents does not match expected values");
guard_strlist_free(&list);
}
}
@@ -159,10 +159,10 @@ void test_strlist_append_strlist() {
strlist_append(&right, "B");
strlist_append(&right, "C");
strlist_append_strlist(left, right);
- OMC_ASSERT(strlist_cmp(left, right) == 0, "left and right should be identical");
+ STASIS_ASSERT(strlist_cmp(left, right) == 0, "left and right should be identical");
strlist_append_strlist(left, right);
- OMC_ASSERT(strlist_cmp(left, right) == 1, "left and right should be different");
- OMC_ASSERT(strlist_count(left) > strlist_count(right), "left should be larger than right");
+ STASIS_ASSERT(strlist_cmp(left, right) == 1, "left and right should be different");
+ STASIS_ASSERT(strlist_count(left) > strlist_count(right), "left should be larger than right");
guard_strlist_free(&left);
guard_strlist_free(&right);
}
@@ -182,7 +182,7 @@ void test_strlist_append_array() {
char *item = strlist_item(list, i);
result += strcmp(item, data[i]) == 0;
}
- OMC_ASSERT(result == strlist_count(list), "result is not identical to input");
+ STASIS_ASSERT(result == strlist_count(list), "result is not identical to input");
guard_strlist_free(&list);
}
@@ -193,9 +193,9 @@ void test_strlist_append_tokenize() {
list = strlist_init();
strlist_append_tokenize(list, (char *) data, "\n");
// note: the trailing '\n' in the data is parsed as a token
- OMC_ASSERT(line_count + 1 == strlist_count(list), "unexpected number of lines in array");
+ STASIS_ASSERT(line_count + 1 == strlist_count(list), "unexpected number of lines in array");
int trailing_item_is_empty = isempty(strlist_item(list, strlist_count(list) - 1));
- OMC_ASSERT(trailing_item_is_empty, "trailing record should be an empty string");
+ STASIS_ASSERT(trailing_item_is_empty, "trailing record should be an empty string");
guard_strlist_free(&list);
}
@@ -207,10 +207,10 @@ void test_strlist_copy() {
strlist_append(&list, "of this data");
strlist_append(&list, "1:1, please");
- OMC_ASSERT(strlist_copy(NULL) == NULL, "NULL argument should return NULL");
+ STASIS_ASSERT(strlist_copy(NULL) == NULL, "NULL argument should return NULL");
list_copy = strlist_copy(list);
- OMC_ASSERT(strlist_cmp(list, list_copy) == 0, "list was copied incorrectly");
+ STASIS_ASSERT(strlist_cmp(list, list_copy) == 0, "list was copied incorrectly");
guard_strlist_free(&list);
guard_strlist_free(&list_copy);
}
@@ -241,8 +241,8 @@ void test_strlist_remove() {
}
}
size_t len_after = strlist_count(list);
- OMC_ASSERT(len_before == data_size, "list length before modification is incorrect. new records?");
- OMC_ASSERT(len_after == (len_before - removed), "list length after modification is incorrect. not enough records removed.");
+ STASIS_ASSERT(len_before == data_size, "list length before modification is incorrect. new records?");
+ STASIS_ASSERT(len_after == (len_before - removed), "list length after modification is incorrect. not enough records removed.");
guard_strlist_free(&list);
}
@@ -253,18 +253,18 @@ void test_strlist_cmp() {
left = strlist_init();
right = strlist_init();
- OMC_ASSERT(strlist_cmp(NULL, NULL) == -1, "NULL first argument should return -1");
- OMC_ASSERT(strlist_cmp(left, NULL) == -2, "NULL second argument should return -2");
- OMC_ASSERT(strlist_cmp(left, right) == 0, "should be the same");
+ STASIS_ASSERT(strlist_cmp(NULL, NULL) == -1, "NULL first argument should return -1");
+ STASIS_ASSERT(strlist_cmp(left, NULL) == -2, "NULL second argument should return -2");
+ STASIS_ASSERT(strlist_cmp(left, right) == 0, "should be the same");
strlist_append(&left, "left");
- OMC_ASSERT(strlist_cmp(left, right) == 1, "should return 1");
+ STASIS_ASSERT(strlist_cmp(left, right) == 1, "should return 1");
strlist_append(&right, "right");
- OMC_ASSERT(strlist_cmp(left, right) == 1, "should return 1");
+ STASIS_ASSERT(strlist_cmp(left, right) == 1, "should return 1");
strlist_append(&left, "left again");
strlist_append(&left, "left again");
strlist_append(&left, "left again");
- OMC_ASSERT(strlist_cmp(left, right) == 1, "should return 1");
- OMC_ASSERT(strlist_cmp(right, left) == 1, "should return 1");
+ STASIS_ASSERT(strlist_cmp(left, right) == 1, "should return 1");
+ STASIS_ASSERT(strlist_cmp(right, left) == 1, "should return 1");
guard_strlist_free(&left);
guard_strlist_free(&right);
}
@@ -286,7 +286,7 @@ void test_strlist_reverse() {
char *item = strlist_item(list, i);
result += strcmp(item, expected[i]) == 0;
}
- OMC_ASSERT(result == (int) strlist_count(list), "alphabetic sort failed");
+ STASIS_ASSERT(result == (int) strlist_count(list), "alphabetic sort failed");
guard_strlist_free(&list);
}
@@ -297,8 +297,8 @@ void test_strlist_count() {
strlist_append(&list, "123");
strlist_append(&list, "def");
strlist_append(&list, "456");
- OMC_ASSERT(strlist_count(NULL) == 0, "NULL input should produce a zero result");
- OMC_ASSERT(strlist_count(list) == 4, "incorrect record count");
+ STASIS_ASSERT(strlist_count(NULL) == 0, "NULL input should produce a zero result");
+ STASIS_ASSERT(strlist_count(list) == 4, "incorrect record count");
guard_strlist_free(&list);
}
@@ -314,13 +314,13 @@ void test_strlist_sort_alphabetic() {
list = strlist_init();
strlist_append_array(list, (char **) data);
- strlist_sort(list, OMC_SORT_ALPHA);
+ strlist_sort(list, STASIS_SORT_ALPHA);
int result = 0;
for (size_t i = 0; i < strlist_count(list); i++) {
char *item = strlist_item(list, i);
result += strcmp(item, expected[i]) == 0;
}
- OMC_ASSERT(result == (int) strlist_count(list), "alphabetic sort failed");
+ STASIS_ASSERT(result == (int) strlist_count(list), "alphabetic sort failed");
guard_strlist_free(&list);
}
@@ -335,13 +335,13 @@ void test_strlist_sort_len_ascending() {
list = strlist_init();
strlist_append_array(list, (char **) data);
- strlist_sort(list, OMC_SORT_LEN_ASCENDING);
+ strlist_sort(list, STASIS_SORT_LEN_ASCENDING);
int result = 0;
for (size_t i = 0; i < strlist_count(list); i++) {
char *item = strlist_item(list, i);
result += strcmp(item, expected[i]) == 0;
}
- OMC_ASSERT(result == (int) strlist_count(list), "ascending sort failed");
+ STASIS_ASSERT(result == (int) strlist_count(list), "ascending sort failed");
guard_strlist_free(&list);
}
@@ -356,13 +356,13 @@ void test_strlist_sort_len_descending() {
list = strlist_init();
strlist_append_array(list, (char **) data);
- strlist_sort(list, OMC_SORT_LEN_DESCENDING);
+ strlist_sort(list, STASIS_SORT_LEN_DESCENDING);
int result = 0;
for (size_t i = 0; i < strlist_count(list); i++) {
char *item = strlist_item(list, i);
result += strcmp(item, expected[i]) == 0;
}
- OMC_ASSERT(result == (int) strlist_count(list), "descending sort failed");
+ STASIS_ASSERT(result == (int) strlist_count(list), "descending sort failed");
guard_strlist_free(&list);
}
@@ -370,7 +370,7 @@ void test_strlist_item_as_str() {
struct StrList *list;
list = strlist_init();
strlist_append(&list, "hello");
- OMC_ASSERT(strcmp(strlist_item_as_str(list, 0), "hello") == 0, "unexpected string result");
+ STASIS_ASSERT(strcmp(strlist_item_as_str(list, 0), "hello") == 0, "unexpected string result");
guard_strlist_free(&list);
}
@@ -578,8 +578,8 @@ void test_strlist_item_as_long_double() {
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_strlist_init,
test_strlist_free,
test_strlist_append,
@@ -612,6 +612,6 @@ int main(int argc, char *argv[]) {
test_strlist_item_as_double,
test_strlist_item_as_long_double,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/test_system.c b/tests/test_system.c
index bf60222..0f6bfb7 100644
--- a/tests/test_system.c
+++ b/tests/test_system.c
@@ -2,7 +2,7 @@
static int ascii_file_contains(const char *filename, const char *value) {
int result = -1;
- char *contents = omc_testing_read_ascii(filename);
+ char *contents = stasis_testing_read_ascii(filename);
if (!contents) {
perror(filename);
return result;
@@ -16,71 +16,71 @@ void test_shell_output_null_args() {
char *result;
int status;
result = shell_output(NULL, &status);
- OMC_ASSERT(strcmp(result, "") == 0, "no output expected");
- OMC_ASSERT(status != 0, "expected a non-zero exit code due to null argument string");
+ STASIS_ASSERT(strcmp(result, "") == 0, "no output expected");
+ STASIS_ASSERT(status != 0, "expected a non-zero exit code due to null argument string");
}
void test_shell_output_non_zero_exit() {
char *result;
int status;
result = shell_output("HELLO1234 WORLD", &status);
- OMC_ASSERT(strcmp(result, "") == 0, "no output expected");
- OMC_ASSERT(status != 0, "expected a non-zero exit code due to intentional error");
+ STASIS_ASSERT(strcmp(result, "") == 0, "no output expected");
+ STASIS_ASSERT(status != 0, "expected a non-zero exit code due to intentional error");
}
void test_shell_output() {
char *result;
int status;
result = shell_output("echo HELLO WORLD", &status);
- OMC_ASSERT(strcmp(result, "HELLO WORLD\n") == 0, "output message was incorrect");
- OMC_ASSERT(status == 0, "expected zero exit code");
+ STASIS_ASSERT(strcmp(result, "HELLO WORLD\n") == 0, "output message was incorrect");
+ STASIS_ASSERT(status == 0, "expected zero exit code");
}
void test_shell_safe() {
struct Process proc;
memset(&proc, 0, sizeof(proc));
shell_safe(&proc, "true");
- OMC_ASSERT(proc.returncode == 0, "expected a zero exit code");
+ STASIS_ASSERT(proc.returncode == 0, "expected a zero exit code");
}
void test_shell_safe_verify_restrictions() {
struct Process proc;
- const char *invalid_chars = OMC_SHELL_SAFE_RESTRICT;
+ const char *invalid_chars = STASIS_SHELL_SAFE_RESTRICT;
for (size_t i = 0; i < strlen(invalid_chars); i++) {
char cmd[PATH_MAX] = {0};
memset(&proc, 0, sizeof(proc));
sprintf(cmd, "true%c false", invalid_chars[i]);
shell_safe(&proc, cmd);
- OMC_ASSERT(proc.returncode == -1, "expected a negative result due to intentional error");
+ STASIS_ASSERT(proc.returncode == -1, "expected a negative result due to intentional error");
}
}
void test_shell_null_proc() {
int returncode = shell(NULL, "true");
- OMC_ASSERT(returncode == 0, "expected a zero exit code");
+ STASIS_ASSERT(returncode == 0, "expected a zero exit code");
}
void test_shell_null_args() {
struct Process proc;
memset(&proc, 0, sizeof(proc));
shell(&proc, NULL);
- OMC_ASSERT(proc.returncode < 0, "expected a non-zero/negative exit code");
+ STASIS_ASSERT(proc.returncode < 0, "expected a non-zero/negative exit code");
}
void test_shell_exit() {
struct Process proc;
memset(&proc, 0, sizeof(proc));
shell(&proc, "true");
- OMC_ASSERT(proc.returncode == 0, "expected a zero exit code");
+ STASIS_ASSERT(proc.returncode == 0, "expected a zero exit code");
}
void test_shell_non_zero_exit() {
struct Process proc;
memset(&proc, 0, sizeof(proc));
shell(&proc, "false");
- OMC_ASSERT(proc.returncode != 0, "expected a non-zero exit code");
+ STASIS_ASSERT(proc.returncode != 0, "expected a non-zero exit code");
}
void test_shell() {
@@ -95,28 +95,28 @@ void test_shell() {
struct Process *proc = &procs[i];
switch (i) {
case 0:
- OMC_ASSERT(proc->returncode == 0, "echo should not fail");
+ STASIS_ASSERT(proc->returncode == 0, "echo should not fail");
break;
case 1:
- OMC_ASSERT(proc->returncode == 0, "echo should not fail");
- OMC_ASSERT(access(proc->f_stdout, F_OK) == 0, "stdout.log should exist");
- OMC_ASSERT(access(proc->f_stderr, F_OK) != 0, "stderr.log should not exist");
- OMC_ASSERT(ascii_file_contains(proc->f_stdout, "test_stdout\n"), "output file did not contain test message");
+ STASIS_ASSERT(proc->returncode == 0, "echo should not fail");
+ STASIS_ASSERT(access(proc->f_stdout, F_OK) == 0, "stdout.log should exist");
+ STASIS_ASSERT(access(proc->f_stderr, F_OK) != 0, "stderr.log should not exist");
+ STASIS_ASSERT(ascii_file_contains(proc->f_stdout, "test_stdout\n"), "output file did not contain test message");
remove(proc->f_stdout);
break;
case 2:
- OMC_ASSERT(proc->returncode == 0, "echo should not fail");
- OMC_ASSERT(access(proc->f_stdout, F_OK) != 0, "stdout.log should not exist");
- OMC_ASSERT(access(proc->f_stderr, F_OK) == 0, "stderr.log should exist");
- OMC_ASSERT(ascii_file_contains(proc->f_stderr, "test_stderr\n"), "output file did not contain test message");
+ STASIS_ASSERT(proc->returncode == 0, "echo should not fail");
+ STASIS_ASSERT(access(proc->f_stdout, F_OK) != 0, "stdout.log should not exist");
+ STASIS_ASSERT(access(proc->f_stderr, F_OK) == 0, "stderr.log should exist");
+ STASIS_ASSERT(ascii_file_contains(proc->f_stderr, "test_stderr\n"), "output file did not contain test message");
remove(proc->f_stderr);
break;
case 3:
- OMC_ASSERT(proc->returncode == 0, "echo should not fail");
- OMC_ASSERT(access("stdouterr.log", F_OK) == 0, "stdouterr.log should exist");
- OMC_ASSERT(access("stderr.log", F_OK) != 0, "stdout.log should not exist");
- OMC_ASSERT(access("stderr.log", F_OK) != 0, "stderr.log should not exist");
- OMC_ASSERT(ascii_file_contains(proc->f_stdout, "test_stdout\ntest_stderr\n"), "output file did not contain test message");
+ STASIS_ASSERT(proc->returncode == 0, "echo should not fail");
+ STASIS_ASSERT(access("stdouterr.log", F_OK) == 0, "stdouterr.log should exist");
+ STASIS_ASSERT(access("stderr.log", F_OK) != 0, "stdout.log should not exist");
+ STASIS_ASSERT(access("stderr.log", F_OK) != 0, "stderr.log should not exist");
+ STASIS_ASSERT(ascii_file_contains(proc->f_stdout, "test_stdout\ntest_stderr\n"), "output file did not contain test message");
remove(proc->f_stdout);
remove(proc->f_stderr);
break;
@@ -127,8 +127,8 @@ void test_shell() {
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_shell_output_null_args,
test_shell_output_non_zero_exit,
test_shell_output,
@@ -140,6 +140,6 @@ int main(int argc, char *argv[]) {
test_shell_exit,
test_shell,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
}
diff --git a/tests/test_template.c b/tests/test_template.c
index fda860a..05d8242 100644
--- a/tests/test_template.c
+++ b/tests/test_template.c
@@ -39,9 +39,9 @@ void test_tpl_workflow() {
tpl_reset();
tpl_register("hello_message", &data);
- OMC_ASSERT(strcmp(tpl_render("I said, \"{{ hello_message }}\""), "I said, \"Hello world!\"") == 0, "stored value in key is incorrect");
+ STASIS_ASSERT(strcmp(tpl_render("I said, \"{{ hello_message }}\""), "I said, \"Hello world!\"") == 0, "stored value in key is incorrect");
setenv("HELLO", "Hello environment!", 1);
- OMC_ASSERT(strcmp(tpl_render("{{ env:HELLO }}"), "Hello environment!") == 0, "environment variable content mismatch");
+ STASIS_ASSERT(strcmp(tpl_render("{{ env:HELLO }}"), "Hello environment!") == 0, "environment variable content mismatch");
unsetenv("HELLO");
guard_free(data);
}
@@ -52,8 +52,8 @@ void test_tpl_register() {
unsigned used_before_register = tpl_pool_used;
tpl_register("hello_message", &data);
- OMC_ASSERT(tpl_pool_used == (used_before_register + 1), "tpl_register did not increment allocation counter");
- OMC_ASSERT(tpl_pool[used_before_register] != NULL, "register did not allocate a tpl_item record in the pool");
+ STASIS_ASSERT(tpl_pool_used == (used_before_register + 1), "tpl_register did not increment allocation counter");
+ STASIS_ASSERT(tpl_pool[used_before_register] != NULL, "register did not allocate a tpl_item record in the pool");
free(data);
}
@@ -69,32 +69,32 @@ void test_tpl_register_func() {
tpl_register_func("sub", &tasks[1]);
tpl_register_func("mul", &tasks[2]);
tpl_register_func("div", &tasks[3]);
- OMC_ASSERT(tpl_pool_func_used == sizeof(tasks) / sizeof(*tasks), "unexpected function pool used");
+ STASIS_ASSERT(tpl_pool_func_used == sizeof(tasks) / sizeof(*tasks), "unexpected function pool used");
char *result = NULL;
result = tpl_render("{{ func:add(0,3) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
result = tpl_render("{{ func:add(1,2) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
result = tpl_render("{{ func:sub(6,3) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
result = tpl_render("{{ func:sub(4,1) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
result = tpl_render("{{ func:mul(1, 3) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
result = tpl_render("{{ func:div(6,2) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
result = tpl_render("{{ func:div(3,1) }}");
- OMC_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
+ STASIS_ASSERT(result != NULL && strcmp(result, "3") == 0, "Answer was not 3");
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_tpl_workflow,
test_tpl_register_func,
test_tpl_register,
};
- OMC_TEST_RUN(tests);
- OMC_TEST_END_MAIN();
+ STASIS_TEST_RUN(tests);
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/test_utils.c b/tests/test_utils.c
index a2fa8c6..4b19604 100644
--- a/tests/test_utils.c
+++ b/tests/test_utils.c
@@ -18,8 +18,8 @@ void test_listdir() {
}
struct StrList *listing;
listing = listdir(dirs[0]);
- OMC_ASSERT(listing != NULL, "listdir failed");
- OMC_ASSERT(listing && (strlist_count(listing) == (sizeof(dirs) / sizeof(*dirs)) - 1), "should have 3");
+ STASIS_ASSERT(listing != NULL, "listdir failed");
+ STASIS_ASSERT(listing && (strlist_count(listing) == (sizeof(dirs) / sizeof(*dirs)) - 1), "should have 3");
guard_strlist_free(&listing);
}
@@ -45,7 +45,7 @@ void test_redact_sensitive() {
char *input = strdup(data[i]);
char output[100] = {0};
redact_sensitive(to_redact, sizeof(to_redact) / sizeof(*to_redact), input, output, sizeof(output) - 1);
- OMC_ASSERT(strcmp(output, expected[i]) == 0, "incorrect redaction");
+ STASIS_ASSERT(strcmp(output, expected[i]) == 0, "incorrect redaction");
}
}
@@ -64,13 +64,13 @@ void test_fix_tox_conf() {
if (fp) {
fprintf(fp, "%s", data);
fclose(fp);
- OMC_ASSERT(fix_tox_conf(filename, &result) == 0, "fix_tox_conf failed");
+ STASIS_ASSERT(fix_tox_conf(filename, &result) == 0, "fix_tox_conf failed");
} else {
- OMC_ASSERT(false, "writing mock tox.ini failed");
+ STASIS_ASSERT(false, "writing mock tox.ini failed");
}
char **lines = file_readlines(result, 0, 0, NULL);
- OMC_ASSERT(strstr_array(lines, expected) != NULL, "{posargs} not found in result");
+ STASIS_ASSERT(strstr_array(lines, expected) != NULL, "{posargs} not found in result");
remove(result);
guard_free(result);
@@ -91,30 +91,30 @@ void test_xml_pretty_print_in_place() {
if (fp) {
fprintf(fp, "%s", data);
fclose(fp);
- OMC_ASSERT(xml_pretty_print_in_place(
+ STASIS_ASSERT(xml_pretty_print_in_place(
filename,
- OMC_XML_PRETTY_PRINT_PROG,
- OMC_XML_PRETTY_PRINT_ARGS) == 0,
+ STASIS_XML_PRETTY_PRINT_PROG,
+ STASIS_XML_PRETTY_PRINT_ARGS) == 0,
"xml pretty print failed (xmllint not installed?)");
} else {
- OMC_ASSERT(false, "failed to create input file");
+ STASIS_ASSERT(false, "failed to create input file");
}
fp = fopen(filename, "r");
char buf[BUFSIZ] = {0};
if (fread(buf, sizeof(*buf), sizeof(buf) - 1, fp) < 1) {
- OMC_ASSERT(false, "failed to consume formatted xml file contents");
+ STASIS_ASSERT(false, "failed to consume formatted xml file contents");
}
- OMC_ASSERT(strcmp(expected, buf) == 0, "xml file was not reformatted");
+ STASIS_ASSERT(strcmp(expected, buf) == 0, "xml file was not reformatted");
}
void test_path_store() {
char *dest = NULL;
chdir(cwd_workspace);
int result = path_store(&dest, PATH_MAX, cwd_workspace, "test_path_store");
- OMC_ASSERT(result == 0, "path_store encountered an error");
- OMC_ASSERT(dest != NULL, "dest should not be NULL");
- OMC_ASSERT(dest && (access(dest, F_OK) == 0), "destination path was not created");
+ STASIS_ASSERT(result == 0, "path_store encountered an error");
+ STASIS_ASSERT(dest != NULL, "dest should not be NULL");
+ STASIS_ASSERT(dest && (access(dest, F_OK) == 0), "destination path was not created");
rmtree(dest);
}
@@ -122,13 +122,13 @@ void test_isempty_dir() {
const char *dname = "test_isempty_dir";
rmtree(dname);
mkdir(dname, 0755);
- OMC_ASSERT(isempty_dir(dname) > 0, "empty directory went undetected");
+ STASIS_ASSERT(isempty_dir(dname) > 0, "empty directory went undetected");
char path[PATH_MAX];
sprintf(path, "%s/file.txt", dname);
touch(path);
- OMC_ASSERT(isempty_dir(dname) == 0, "populated directory went undetected");
+ STASIS_ASSERT(isempty_dir(dname) == 0, "populated directory went undetected");
}
void test_xmkstemp() {
@@ -137,7 +137,7 @@ void test_xmkstemp() {
const char *data = "Hello, world!\n";
tempfile = xmkstemp(&tempfp, "w");
- OMC_ASSERT(tempfile != NULL, "failed to create temporary file");
+ STASIS_ASSERT(tempfile != NULL, "failed to create temporary file");
fprintf(tempfp, "%s", data);
fclose(tempfp);
@@ -146,7 +146,7 @@ void test_xmkstemp() {
fgets(buf, sizeof(buf) - 1, tempfp);
fclose(tempfp);
- OMC_ASSERT(strcmp(buf, data) == 0, "data written to temp file is incorrect");
+ STASIS_ASSERT(strcmp(buf, data) == 0, "data written to temp file is incorrect");
remove(tempfile);
free(tempfile);
}
@@ -154,16 +154,16 @@ void test_xmkstemp() {
void test_msg() {
int flags_indent[] = {
0,
- OMC_MSG_L1,
- OMC_MSG_L2,
- OMC_MSG_L3,
+ STASIS_MSG_L1,
+ STASIS_MSG_L2,
+ STASIS_MSG_L3,
};
int flags_info[] = {
- //OMC_MSG_NOP,
- OMC_MSG_SUCCESS,
- OMC_MSG_WARN,
- OMC_MSG_ERROR,
- //OMC_MSG_RESTRICT,
+ //STASIS_MSG_NOP,
+ STASIS_MSG_SUCCESS,
+ STASIS_MSG_WARN,
+ STASIS_MSG_ERROR,
+ //STASIS_MSG_RESTRICT,
};
for (size_t i = 0; i < sizeof(flags_indent) / sizeof(*flags_indent); i++) {
for (size_t x = 0; x < sizeof(flags_info) / sizeof(*flags_info); x++) {
@@ -193,13 +193,13 @@ void test_git_clone_and_describe() {
system(init_cmd);
// clone the bare repo
- OMC_ASSERT(git_clone(&proc, repo_git, repo, NULL) == 0,
+ STASIS_ASSERT(git_clone(&proc, repo_git, repo, NULL) == 0,
"a local clone of bare repository should have succeeded");
chdir(repo);
// interact with it
touch("README.md");
- system("git config user.name omc");
+ system("git config user.name stasis");
system("git config user.email null@null.null");
system("git add README.md");
system("git commit --no-gpg-sign -m Test");
@@ -208,33 +208,33 @@ void test_git_clone_and_describe() {
// test git_describe is functional
char *taginfo_none = git_describe(".");
- OMC_ASSERT(taginfo_none != NULL, "should be a git hash, not NULL");
+ STASIS_ASSERT(taginfo_none != NULL, "should be a git hash, not NULL");
system("git tag -a 1.0.0 -m Mock");
system("git push --tags origin");
char *taginfo = git_describe(".");
- OMC_ASSERT(taginfo != NULL, "should be 1.0.0, not NULL");
- OMC_ASSERT(strcmp(taginfo, "1.0.0") == 0, "just-created tag was not described correctly");
+ STASIS_ASSERT(taginfo != NULL, "should be 1.0.0, not NULL");
+ STASIS_ASSERT(strcmp(taginfo, "1.0.0") == 0, "just-created tag was not described correctly");
chdir("..");
char *taginfo_outer = git_describe(repo);
- OMC_ASSERT(taginfo_outer != NULL, "should be 1.0.0, not NULL");
- OMC_ASSERT(strcmp(taginfo_outer, "1.0.0") == 0, "just-created tag was not described correctly (out-of-dir invocation)");
+ STASIS_ASSERT(taginfo_outer != NULL, "should be 1.0.0, not NULL");
+ STASIS_ASSERT(strcmp(taginfo_outer, "1.0.0") == 0, "just-created tag was not described correctly (out-of-dir invocation)");
char *taginfo_bad = git_describe("abc1234_not_here_or_there");
- OMC_ASSERT(taginfo_bad == NULL, "a repository that shouldn't exist... exists and has a tag.");
+ STASIS_ASSERT(taginfo_bad == NULL, "a repository that shouldn't exist... exists and has a tag.");
chdir(cwd);
}
void test_touch() {
- OMC_ASSERT(touch("touchedfile.txt") == 0, "touch failed");
- OMC_ASSERT(access("touchedfile.txt", F_OK) == 0, "touched file does not exist");
+ STASIS_ASSERT(touch("touchedfile.txt") == 0, "touch failed");
+ STASIS_ASSERT(access("touchedfile.txt", F_OK) == 0, "touched file does not exist");
remove("touchedfile.txt");
}
void test_find_program() {
- OMC_ASSERT(find_program("willnotexist123") == NULL, "did not return NULL");
- OMC_ASSERT(find_program("find") != NULL, "program not available (OS dependent)");
+ STASIS_ASSERT(find_program("willnotexist123") == NULL, "did not return NULL");
+ STASIS_ASSERT(find_program("find") != NULL, "program not available (OS dependent)");
}
static int file_readlines_callback_modify(size_t size, char **line) {
@@ -276,16 +276,16 @@ void test_file_readlines() {
result = file_readlines(filename, 0, 0, NULL);
int i;
for (i = 0; result[i] != NULL; i++);
- OMC_ASSERT(num_chars(data, '\n') == i, "incorrect number of lines in data");
- OMC_ASSERT(strcmp(result[3], "see?\n") == 0, "last line in data is incorrect'");
+ STASIS_ASSERT(num_chars(data, '\n') == i, "incorrect number of lines in data");
+ STASIS_ASSERT(strcmp(result[3], "see?\n") == 0, "last line in data is incorrect'");
GENERIC_ARRAY_FREE(result);
result = file_readlines(filename, 0, 0, file_readlines_callback_modify);
- OMC_ASSERT(strcmp(result[3], "xxx?\n") == 0, "last line should be: 'xxx?\\n'");
+ STASIS_ASSERT(strcmp(result[3], "xxx?\n") == 0, "last line should be: 'xxx?\\n'");
GENERIC_ARRAY_FREE(result);
result = file_readlines(filename, 0, 0, file_readlines_callback_get_specific_line);
- OMC_ASSERT(strcmp(result[0], "see?\n") == 0, "the first record of the result is not the last line of the file 'see?\\n'");
+ STASIS_ASSERT(strcmp(result[0], "see?\n") == 0, "the first record of the result is not the last line of the file 'see?\\n'");
GENERIC_ARRAY_FREE(result);
remove(filename);
}
@@ -302,7 +302,7 @@ void test_path_dirname() {
strcpy(tmp, input);
char *result = path_dirname(tmp);
- OMC_ASSERT(strcmp(expected, result) == 0, NULL);
+ STASIS_ASSERT(strcmp(expected, result) == 0, NULL);
}
}
@@ -315,7 +315,7 @@ void test_path_basename() {
const char *input = data[i];
const char *expected = data[i + 1];
char *result = path_basename(input);
- OMC_ASSERT(strcmp(expected, result) == 0, NULL);
+ STASIS_ASSERT(strcmp(expected, result) == 0, NULL);
}
}
@@ -338,8 +338,8 @@ void test_expandpath() {
strcat(path, DIR_SEP);
char *expanded = expandpath(path);
- OMC_ASSERT(startswith(expanded, home) > 0, expanded);
- OMC_ASSERT(endswith(expanded, DIR_SEP) > 0, "the input string ends with a directory separator, the result did not");
+ STASIS_ASSERT(startswith(expanded, home) > 0, expanded);
+ STASIS_ASSERT(endswith(expanded, DIR_SEP) > 0, "the input string ends with a directory separator, the result did not");
free(expanded);
}
@@ -361,12 +361,12 @@ void test_rmtree() {
sprintf(mockfile, "%s/%zu.txt", path, i);
if (mkdir(path, 0755)) {
perror(path);
- OMC_ASSERT(false, NULL);
+ STASIS_ASSERT(false, NULL);
}
touch(mockfile);
}
- OMC_ASSERT(rmtree(root) == 0, "rmtree should have been able to remove the directory");
- OMC_ASSERT(access(root, F_OK) < 0, "the directory is still present");
+ STASIS_ASSERT(rmtree(root) == 0, "rmtree should have been able to remove the directory");
+ STASIS_ASSERT(access(root, F_OK) < 0, "the directory is still present");
}
void test_dirstack() {
@@ -384,18 +384,18 @@ void test_dirstack() {
pushd(data[i]);
getcwd(cwd, PATH_MAX);
}
- OMC_ASSERT(dirstack_len == sizeof(data) / sizeof(*data), NULL);
- OMC_ASSERT(strcmp(dirstack[0], cwd_workspace) == 0, NULL);
+ STASIS_ASSERT(dirstack_len == sizeof(data) / sizeof(*data), NULL);
+ STASIS_ASSERT(strcmp(dirstack[0], cwd_workspace) == 0, NULL);
for (int i = 1; i < dirstack_len; i++) {
- OMC_ASSERT(endswith(dirstack[i], data[i - 1]), NULL);
+ STASIS_ASSERT(endswith(dirstack[i], data[i - 1]), NULL);
}
for (size_t i = 0, x = dirstack_len - 1; x != 0 && i < sizeof(data) / sizeof(*data); i++, x--) {
char *expected = strdup(dirstack[x]);
popd();
getcwd(cwd, PATH_MAX);
- OMC_ASSERT(strcmp(cwd, expected) == 0, NULL);
+ STASIS_ASSERT(strcmp(cwd, expected) == 0, NULL);
free(expected);
}
}
@@ -405,16 +405,16 @@ void test_pushd_popd() {
chdir(cwd_workspace);
rmtree(dname);
- OMC_ASSERT(mkdir(dname, 0755) == 0, "directory should not exist yet");
- OMC_ASSERT(pushd(dname) == 0, "failed to enter directory");
+ STASIS_ASSERT(mkdir(dname, 0755) == 0, "directory should not exist yet");
+ STASIS_ASSERT(pushd(dname) == 0, "failed to enter directory");
char *cwd = getcwd(NULL, PATH_MAX);
// we should be inside the test directory, not the starting directory
- OMC_ASSERT(strcmp(cwd_workspace, cwd) != 0, "");
- OMC_ASSERT(popd() == 0, "return from directory failed");
+ STASIS_ASSERT(strcmp(cwd_workspace, cwd) != 0, "");
+ STASIS_ASSERT(popd() == 0, "return from directory failed");
char *cwd_after_popd = getcwd(NULL, PATH_MAX);
- OMC_ASSERT(strcmp(cwd_workspace, cwd_after_popd) == 0, "should be the path where we started");
+ STASIS_ASSERT(strcmp(cwd_workspace, cwd_after_popd) == 0, "should be the path where we started");
}
void test_pushd_popd_suggested_workflow() {
@@ -426,23 +426,23 @@ void test_pushd_popd_suggested_workflow() {
if (!mkdir(dname, 0755)) {
if (!pushd(dname)) {
char *cwd = getcwd(NULL, PATH_MAX);
- OMC_ASSERT(strcmp(cwd_workspace, cwd) != 0, NULL);
+ STASIS_ASSERT(strcmp(cwd_workspace, cwd) != 0, NULL);
// return from dir
popd();
free(cwd);
}
// cwd should be our starting directory
char *cwd = getcwd(NULL, PATH_MAX);
- OMC_ASSERT(strcmp(cwd_workspace, cwd) == 0, NULL);
+ STASIS_ASSERT(strcmp(cwd_workspace, cwd) == 0, NULL);
} else {
- OMC_ASSERT(false, "mkdir function failed");
+ STASIS_ASSERT(false, "mkdir function failed");
}
}
int main(int argc, char *argv[]) {
- OMC_TEST_BEGIN_MAIN();
- OMC_TEST_FUNC *tests[] = {
+ STASIS_TEST_BEGIN_MAIN();
+ STASIS_TEST_FUNC *tests[] = {
test_listdir,
test_redact_sensitive,
test_fix_tox_conf,
@@ -469,11 +469,11 @@ int main(int argc, char *argv[]) {
chdir(ws);
getcwd(cwd_workspace, sizeof(cwd_workspace) - 1);
- OMC_TEST_RUN(tests);
+ STASIS_TEST_RUN(tests);
chdir(cwd_start);
if (rmtree(cwd_workspace)) {
perror(cwd_workspace);
}
- OMC_TEST_END_MAIN();
+ STASIS_TEST_END_MAIN();
} \ No newline at end of file
diff --git a/tests/testing.h b/tests/testing.h
index 35bfbd2..15bd208 100644
--- a/tests/testing.h
+++ b/tests/testing.h
@@ -1,16 +1,16 @@
-#ifndef OMC_TESTING_H
-#define OMC_TESTING_H
-#include "omc.h"
-#define OMC_TEST_RUN_MAX 10000
-#define OMC_TEST_SUITE_FATAL 1
-#define OMC_TEST_SUITE_SKIP 127
+#ifndef STASIS_TESTING_H
+#define STASIS_TESTING_H
+#include "core.h"
+#define STASIS_TEST_RUN_MAX 10000
+#define STASIS_TEST_SUITE_FATAL 1
+#define STASIS_TEST_SUITE_SKIP 127
#ifndef __FILE_NAME__
#define __FILE_NAME__ __FILE__
#endif
-typedef void(OMC_TEST_FUNC)();
-struct omc_test_result_t {
+typedef void(STASIS_TEST_FUNC)();
+struct stasis_test_result_t {
const char *filename;
const char *funcname;
int lineno;
@@ -18,36 +18,36 @@ struct omc_test_result_t {
const char *msg_reason;
const int status;
const int skip;
-} omc_test_results[OMC_TEST_RUN_MAX];
-size_t omc_test_results_i = 0;
+} stasis_test_results[STASIS_TEST_RUN_MAX];
+size_t stasis_test_results_i = 0;
-void omc_testing_record_result(struct omc_test_result_t result);
+void stasis_testing_record_result(struct stasis_test_result_t result);
-void omc_testing_record_result(struct omc_test_result_t result) {
- memcpy(&omc_test_results[omc_test_results_i], &result, sizeof(result));
- omc_test_results_i++;
+void stasis_testing_record_result(struct stasis_test_result_t result) {
+ memcpy(&stasis_test_results[stasis_test_results_i], &result, sizeof(result));
+ stasis_test_results_i++;
}
-int omc_testing_has_failed() {
- for (size_t i = 0; i < omc_test_results_i; i++) {
- if (omc_test_results[i].status == false) {
+int stasis_testing_has_failed() {
+ for (size_t i = 0; i < stasis_test_results_i; i++) {
+ if (stasis_test_results[i].status == false) {
return 1;
}
}
return 0;
}
-void omc_testing_record_result_summary() {
+void stasis_testing_record_result_summary() {
size_t failed = 0;
size_t skipped = 0;
size_t passed = 0;
int do_message;
static char status_msg[255] = {0};
- for (size_t i = 0; i < omc_test_results_i; i++) {
- if (omc_test_results[i].status && omc_test_results[i].skip) {
+ for (size_t i = 0; i < stasis_test_results_i; i++) {
+ if (stasis_test_results[i].status && stasis_test_results[i].skip) {
strcpy(status_msg, "SKIP");
do_message = 1;
skipped++;
- } else if (!omc_test_results[i].status) {
+ } else if (!stasis_test_results[i].status) {
strcpy(status_msg, "FAIL");
do_message = 1;
failed++;
@@ -58,19 +58,19 @@ void omc_testing_record_result_summary() {
}
fprintf(stdout, "[%s] %s:%d :: %s() => %s",
status_msg,
- omc_test_results[i].filename,
- omc_test_results[i].lineno,
- omc_test_results[i].funcname,
- omc_test_results[i].msg_assertion);
+ stasis_test_results[i].filename,
+ stasis_test_results[i].lineno,
+ stasis_test_results[i].funcname,
+ stasis_test_results[i].msg_assertion);
if (do_message) {
- fprintf(stdout, "\n \\_ %s", omc_test_results[i].msg_reason);
+ fprintf(stdout, "\n \\_ %s", stasis_test_results[i].msg_reason);
}
fprintf(stdout, "\n");
}
- fprintf(stdout, "\n[UNIT] %zu tests passed, %zu tests failed, %zu tests skipped out of %zu\n", passed, failed, skipped, omc_test_results_i);
+ fprintf(stdout, "\n[UNIT] %zu tests passed, %zu tests failed, %zu tests skipped out of %zu\n", passed, failed, skipped, stasis_test_results_i);
}
-char *omc_testing_read_ascii(const char *filename) {
+char *stasis_testing_read_ascii(const char *filename) {
struct stat st;
if (stat(filename, &st)) {
perror(filename);
@@ -96,7 +96,7 @@ char *omc_testing_read_ascii(const char *filename) {
return result;
}
-int omc_testing_write_ascii(const char *filename, const char *data) {
+int stasis_testing_write_ascii(const char *filename, const char *data) {
FILE *fp;
fp = fopen(filename, "w+");
if (!fp) {
@@ -114,18 +114,18 @@ int omc_testing_write_ascii(const char *filename, const char *data) {
return 0;
}
-#define OMC_TEST_BEGIN_MAIN() do { \
+#define STASIS_TEST_BEGIN_MAIN() do { \
setenv("PYTHONUNBUFFERED", "1", 1); \
fflush(stdout); \
fflush(stderr); \
setvbuf(stdout, NULL, _IONBF, 0); \
setvbuf(stderr, NULL, _IONBF, 0); \
- atexit(omc_testing_record_result_summary); \
+ atexit(stasis_testing_record_result_summary); \
} while (0)
-#define OMC_TEST_END_MAIN() do { return omc_testing_has_failed(); } while (0)
+#define STASIS_TEST_END_MAIN() do { return stasis_testing_has_failed(); } while (0)
-#define OMC_ASSERT(COND, REASON) do { \
- omc_testing_record_result((struct omc_test_result_t) { \
+#define STASIS_ASSERT(COND, REASON) do { \
+ stasis_testing_record_result((struct stasis_test_result_t) { \
.filename = __FILE_NAME__, \
.funcname = __FUNCTION__, \
.lineno = __LINE__, \
@@ -134,8 +134,8 @@ int omc_testing_write_ascii(const char *filename, const char *data) {
.msg_reason = REASON } ); \
} while (0)
-#define OMC_ASSERT_FATAL(COND, REASON) do { \
- omc_testing_record_result((struct omc_test_result_t) { \
+#define STASIS_ASSERT_FATAL(COND, REASON) do { \
+ stasis_testing_record_result((struct stasis_test_result_t) { \
.filename = __FILE_NAME__, \
.funcname = __FUNCTION__, \
.lineno = __LINE__, \
@@ -143,13 +143,13 @@ int omc_testing_write_ascii(const char *filename, const char *data) {
.msg_assertion = "ASSERT FATAL (" #COND ")", \
.msg_reason = REASON } \
); \
- if (omc_test_results[omc_test_results_i ? omc_test_results_i - 1 : omc_test_results_i].status == false) {\
- exit(OMC_TEST_SUITE_FATAL); \
+ if (stasis_test_results[stasis_test_results_i ? stasis_test_results_i - 1 : stasis_test_results_i].status == false) {\
+ exit(STASIS_TEST_SUITE_FATAL); \
} \
} while (0)
-#define OMC_SKIP_IF(COND, REASON) do { \
- omc_testing_record_result((struct omc_test_result_t) { \
+#define STASIS_SKIP_IF(COND, REASON) do { \
+ stasis_testing_record_result((struct stasis_test_result_t) { \
.filename = __FILE_NAME__, \
.funcname = __FUNCTION__, \
.lineno = __LINE__, \
@@ -158,12 +158,12 @@ int omc_testing_write_ascii(const char *filename, const char *data) {
.msg_assertion = "SKIP (" #COND ")", \
.msg_reason = REASON } \
); \
- if (omc_test_results[omc_test_results_i ? omc_test_results_i - 1 : omc_test_results_i].skip == true) {\
+ if (stasis_test_results[stasis_test_results_i ? stasis_test_results_i - 1 : stasis_test_results_i].skip == true) {\
return; \
} \
} while (0)
-#define OMC_TEST_RUN(X) do { \
+#define STASIS_TEST_RUN(X) do { \
for (size_t i = 0; i < sizeof(X) / sizeof(*X); i++) { \
if (X[i]) { \
X[i](); \
@@ -171,4 +171,4 @@ int omc_testing_write_ascii(const char *filename, const char *data) {
} \
} while (0)
-#endif //OMC_TESTING_H
+#endif //STASIS_TESTING_H