aboutsummaryrefslogtreecommitdiff
path: root/tests/test_system.c
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/test_system.c
parent931ee28eb9c5b5e3c2b0d3008f5f65d810dc9b0c (diff)
downloadstasis-77a0276d9f37bcf828c77f9bcc59ff945116274e.tar.gz
Rebrand OhMyCal (OMC) as STASIS (#7)
Diffstat (limited to 'tests/test_system.c')
-rw-r--r--tests/test_system.c64
1 files changed, 32 insertions, 32 deletions
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();
}