diff options
author | dzwdz | 2023-08-14 18:51:07 +0200 |
---|---|---|
committer | dzwdz | 2023-08-14 18:51:07 +0200 |
commit | 642b5fb0007b64c77d186fcb018d571152ee1d47 (patch) | |
tree | 1c466461f3602d306be309a053edae558ef2568e /src/user/app/tests/tests.c | |
parent | 8050069c57b729c18c19b1a03ab6e4bf63b4735e (diff) |
reorganization: first steps
Diffstat (limited to 'src/user/app/tests/tests.c')
-rw-r--r-- | src/user/app/tests/tests.c | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c deleted file mode 100644 index 5cba682..0000000 --- a/src/user/app/tests/tests.c +++ /dev/null @@ -1,68 +0,0 @@ -#include "tests.h" -#include <camellia/syscalls.h> -#include <unistd.h> - -__attribute__((visibility("hidden"))) -extern char __executable_start[]; - -FILE *fail_trig; - -void run_test(void (*fn)()) { - if (!fork()) { - fn(); - _sys_filicide(); - exit(0); - } else { - /* successful tests must return 0 */ - if (_sys_await() != 0) { - test_failf("%p, base %p", (void*)((void*)fn - (void*)__executable_start), __executable_start); - } - } -} - -int forkpipe(FILE **f, hid_t *h) { - hid_t ends[2]; - if (_sys_pipe(ends, 0) < 0) { - fprintf(stderr, "couldn't create pipe\n"); - exit(1); - } - int ret = fork(); - if (!ret) { - close(ends[0]); - *f = fdopen(ends[1], "w"); - *h = -1; - } else { - close(ends[1]); - *f = NULL; - *h = ends[0]; - } - return ret; -} - -int main(void) { - hid_t reader; - if (!forkpipe(&fail_trig, &reader)) { - r_k_miscsyscall(); - r_k_fs(); - r_k_fdlimit(); - r_k_misc(); - r_k_path(); - r_k_threads(); - r_libc_esemaphore(); - r_libc_setjmp(); - r_libc_string(); - r_s_printf(); - r_s_ringbuf(); - exit(0); - } else { - for (;;) { - char buf[128]; - long ret = _sys_read(reader, buf, sizeof buf, 0); - if (ret < 0) break; - printf("\033[31mFAIL\033[0m "); - fwrite(buf, ret, 1, stdout); - printf("\n"); - } - } - return 0; -} |