diff options
author | dzwdz | 2023-01-25 20:16:22 +0100 |
---|---|---|
committer | dzwdz | 2023-01-25 20:16:22 +0100 |
commit | 17bfb0ef0a48330b1d54e61fe3c30d83528d2d90 (patch) | |
tree | b3d4aed1f408edcb17fe5c86fccaeacaa2a5a48a /src/user/app/tests/kernel | |
parent | 2ad6ee8ed15d1bf898645a16dbc06991a3c1425e (diff) |
style: typedef structs, shorter namespaces
I've wanted to do this for a while, and since I've just had a relatively
large refactor commit (pcpy), this is as good of a time as any.
Typedefing structs was mostly inspired by Plan 9's coding style. It makes
some lines of code much shorter at basically no expense.
Everything related to userland kept old-style struct definitions, so as not
to force that style onto other people.
I also considered changing SCREAMING_ENUM_FIELDS to NicerLookingCamelcase,
but I didn't, just in case that'd be confusing.
Diffstat (limited to 'src/user/app/tests/kernel')
-rw-r--r-- | src/user/app/tests/kernel/fdlimit.c | 28 | ||||
-rw-r--r-- | src/user/app/tests/kernel/fs.c | 44 | ||||
-rw-r--r-- | src/user/app/tests/kernel/misc.c | 38 | ||||
-rw-r--r-- | src/user/app/tests/kernel/miscsyscall.c | 160 | ||||
-rw-r--r-- | src/user/app/tests/kernel/path.c | 6 | ||||
-rw-r--r-- | src/user/app/tests/kernel/threads.c | 12 |
6 files changed, 144 insertions, 144 deletions
diff --git a/src/user/app/tests/kernel/fdlimit.c b/src/user/app/tests/kernel/fdlimit.c index d22af13..f332357 100644 --- a/src/user/app/tests/kernel/fdlimit.c +++ b/src/user/app/tests/kernel/fdlimit.c @@ -4,10 +4,10 @@ #include <unistd.h> static void test_fdlimit_pipe(void) { - handle_t ends[2]; - handle_t h[2] = {-1, -1}; + hid_t ends[2]; + hid_t h[2] = {-1, -1}; for (;;) { - handle_t cur = _syscall_open("/", 1, OPEN_READ); + hid_t cur = _sys_open("/", 1, OPEN_READ); if (cur == -EMFILE) break; test(cur >= 0); h[0] = h[1]; @@ -15,31 +15,31 @@ static void test_fdlimit_pipe(void) { } test(h[0] >= 0); /* we need at least two handles */ - test(_syscall_pipe(ends, 0) == -EMFILE); - test(_syscall_open("/", 1, OPEN_READ) == -EMFILE); + test(_sys_pipe(ends, 0) == -EMFILE); + test(_sys_open("/", 1, OPEN_READ) == -EMFILE); close(h[1]); - test(_syscall_pipe(ends, 0) == -EMFILE); - test(_syscall_open("/", 1, OPEN_READ) == h[1]); - test(_syscall_open("/", 1, OPEN_READ) == -EMFILE); + test(_sys_pipe(ends, 0) == -EMFILE); + test(_sys_open("/", 1, OPEN_READ) == h[1]); + test(_sys_open("/", 1, OPEN_READ) == -EMFILE); close(h[0]); close(h[1]); - test(_syscall_pipe(ends, 0) == 0); + test(_sys_pipe(ends, 0) == 0); } static void test_fdlimit_fork(void) { for (;;) { - handle_t cur = _syscall_open("/", 1, OPEN_READ); + hid_t cur = _sys_open("/", 1, OPEN_READ); if (cur == -EMFILE) break; test(cur >= 0); } - if (!_syscall_fork(0, NULL)) _syscall_exit(123); + if (!_sys_fork(0, NULL)) _sys_exit(123); - test(_syscall_fork(FORK_NEWFS, NULL) == -EMFILE); - test(_syscall_await() == 123); - test(_syscall_await() == ~0); + test(_sys_fork(FORK_NEWFS, NULL) == -EMFILE); + test(_sys_await() == 123); + test(_sys_await() == ~0); } void r_k_fdlimit(void) { diff --git a/src/user/app/tests/kernel/fs.c b/src/user/app/tests/kernel/fs.c index 6669c41..b5684d7 100644 --- a/src/user/app/tests/kernel/fs.c +++ b/src/user/app/tests/kernel/fs.c @@ -5,34 +5,34 @@ #include <string.h> static void test_unfinished_req(void) { - handle_t h = -1; - int ret = _syscall_fork(FORK_NEWFS, &h); + hid_t h = -1; + int ret = _sys_fork(FORK_NEWFS, &h); test(0 <= ret); if (ret == 0) { // TODO make a similar test with all 0s passed to fs_wait struct ufs_request res; - _syscall_fs_wait(NULL, 0, &res); + _sys_fs_wait(NULL, 0, &res); // TODO second fs_wait exit(0); } else { test(0 <= h); - test(_syscall_mount(h, "/", 1) == 0); - int ret = _syscall_open("/", 1, 0); + test(_sys_mount(h, "/", 1) == 0); + int ret = _sys_open("/", 1, 0); test(ret < 0); // the handler quits while handling that call - but this syscall should return anyways } } static void test_orphaned_fs(void) { - handle_t h = -1; - int ret = _syscall_fork(FORK_NEWFS, &h); + hid_t h = -1; + int ret = _sys_fork(FORK_NEWFS, &h); test(0 <= ret); if (ret == 0) { exit(0); } else { test(0 <= h); - test(_syscall_mount(h, "/", 1) == 0); - int ret = _syscall_open("/", 1, 0); + test(_sys_mount(h, "/", 1) == 0); + int ret = _sys_open("/", 1, 0); test(ret < 0); } } @@ -41,32 +41,32 @@ static void test_fs_cleanup(void) { const char *msg = "success"; int msglen = 8; char buf[16]; - handle_t ends[2]; - test(_syscall_pipe(ends, 0) >= 0); - if (!_syscall_fork(0, NULL)) { - handle_t h = -1; - if (_syscall_fork(FORK_NEWFS, &h) == 0) { + hid_t ends[2]; + test(_sys_pipe(ends, 0) >= 0); + if (!_sys_fork(0, NULL)) { + hid_t h = -1; + if (_sys_fork(FORK_NEWFS, &h) == 0) { for (;;) { struct ufs_request req; - handle_t reqh = _syscall_fs_wait(buf, sizeof buf, &req); + hid_t reqh = _sys_fs_wait(buf, sizeof buf, &req); if (reqh < 0) break; - _syscall_fs_respond(reqh, NULL, 0, 0); /* success */ + _sys_fs_respond(reqh, NULL, 0, 0); /* success */ } /* this is the test: does it break out of the loop * when it should cleanup */ - _syscall_write(ends[1], msg, msglen, -1, 0); + _sys_write(ends[1], msg, msglen, -1, 0); exit(0); } else { - test(_syscall_mount(h, "/", 1) == 0); - h = _syscall_open("/", 1, 0); + test(_sys_mount(h, "/", 1) == 0); + h = _sys_open("/", 1, 0); test(h >= 0); - _syscall_close(h); + _sys_close(h); // TODO another test without the delay - _syscall_sleep(0); + _sys_sleep(0); exit(0); } } else { - test(_syscall_read(ends[0], buf, sizeof buf, 0) == msglen); + test(_sys_read(ends[0], buf, sizeof buf, 0) == msglen); test(memcmp(buf, msg, msglen) == 0); } } diff --git a/src/user/app/tests/kernel/misc.c b/src/user/app/tests/kernel/misc.c index f6a8feb..b60ebc0 100644 --- a/src/user/app/tests/kernel/misc.c +++ b/src/user/app/tests/kernel/misc.c @@ -16,7 +16,7 @@ static void test_fault_kill(void) { } int await_cnt = 0; - while (_syscall_await() != ~0) await_cnt++; + while (_sys_await() != ~0) await_cnt++; test(await_cnt == 2); } @@ -24,32 +24,32 @@ static void test_efault(void) { const char *str = "o, 16 characters"; char str2[16]; char *invalid = (void*)0x1000; - handle_t h; + hid_t h; memcpy(str2, str, 16); - test((h = _syscall_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE)) >= 0); - test(_syscall_write(h, str, 16, 0, 0) == 16); - test(_syscall_write(h, str2, 16, 0, 0) == 16); + test((h = _sys_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE)) >= 0); + test(_sys_write(h, str, 16, 0, 0) == 16); + test(_sys_write(h, str2, 16, 0, 0) == 16); - test(_syscall_write(h, invalid, 16, 0, 0) == -EFAULT); + test(_sys_write(h, invalid, 16, 0, 0) == -EFAULT); /* x64 non-canonical pointers */ - test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0, 0) == -EFAULT); + test(_sys_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0, 0) == -EFAULT); - test(_syscall_write(h, str, 16, 0, 0) == 16); + test(_sys_write(h, str, 16, 0, 0) == 16); close(h); } diff --git a/src/user/app/tests/kernel/miscsyscall.c b/src/user/app/tests/kernel/miscsyscall.c index 58a9afb..c90560e 100644 --- a/src/user/app/tests/kernel/miscsyscall.c +++ b/src/user/app/tests/kernel/miscsyscall.c @@ -17,7 +17,7 @@ static void test_await(void) { if (!fork()) exit(i); - while ((ret = _syscall_await()) != ~0) { + while ((ret = _sys_await()) != ~0) { test(0 <= ret && ret < 16); counts[ret]++; } @@ -30,114 +30,114 @@ static void test_await2(void) { /* hangs on failure */ if (!fork()) { if (!fork()) { - for (;;) _syscall_sleep(1000000000); + for (;;) _sys_sleep(1000000000); } else { exit(123); } } - test(_syscall_await() == 123); - test(_syscall_await() == ~0); /* don't wait for tombstone */ - _syscall_filicide(); + test(_sys_await() == 123); + test(_sys_await() == ~0); /* don't wait for tombstone */ + _sys_filicide(); } static void test_pipe(void) { const char *pipe_msgs[2] = {"hello", "world"}; - handle_t ends[2]; + hid_t ends[2]; char buf[16]; /* test regular reads / writes */ - test(_syscall_pipe(ends, 0) >= 0); + test(_sys_pipe(ends, 0) >= 0); if (!fork()) { /* those repeated asserts ensure that you can't read/write to the wrong ends */ - test(_syscall_read(ends[1], buf, 16, 0) < 0); - test(_syscall_write(ends[0], buf, 16, 0, 0) < 0); + test(_sys_read(ends[1], buf, 16, 0) < 0); + test(_sys_write(ends[0], buf, 16, 0, 0) < 0); - test(5 == _syscall_write(ends[1], pipe_msgs[0], 5, -1, 0)); + test(5 == _sys_write(ends[1], pipe_msgs[0], 5, -1, 0)); - test(_syscall_read(ends[1], buf, 16, 0) < 0); - test(_syscall_write(ends[0], buf, 16, 0, 0) < 0); + test(_sys_read(ends[1], buf, 16, 0) < 0); + test(_sys_write(ends[0], buf, 16, 0, 0) < 0); - test(5 == _syscall_write(ends[1], pipe_msgs[1], 5, -1, 0)); + test(5 == _sys_write(ends[1], pipe_msgs[1], 5, -1, 0)); exit(0); } else { - test(_syscall_read(ends[1], buf, 16, 0) < 0); - test(_syscall_write(ends[0], buf, 16, 0, 0) < 0); + test(_sys_read(ends[1], buf, 16, 0) < 0); + test(_sys_write(ends[0], buf, 16, 0, 0) < 0); - test(5 == _syscall_read(ends[0], buf, 16, 0)); + test(5 == _sys_read(ends[0], buf, 16, 0)); test(!memcmp(buf, pipe_msgs[0], 5)); - test(_syscall_read(ends[1], buf, 16, 0) < 0); - test(_syscall_write(ends[0], buf, 16, 0, 0) < 0); + test(_sys_read(ends[1], buf, 16, 0) < 0); + test(_sys_write(ends[0], buf, 16, 0, 0) < 0); - test(5 == _syscall_read(ends[0], buf, 16, 0)); + test(5 == _sys_read(ends[0], buf, 16, 0)); test(!memcmp(buf, pipe_msgs[1], 5)); - _syscall_await(); + _sys_await(); } close(ends[0]); close(ends[1]); /* writing to pipes with one end closed */ - test(_syscall_pipe(ends, 0) >= 0); + test(_sys_pipe(ends, 0) >= 0); for (int i = 0; i < 16; i++) { if (!fork()) { close(ends[1]); - test(_syscall_read(ends[0], buf, 16, 0) < 0); + test(_sys_read(ends[0], buf, 16, 0) < 0); exit(0); } } close(ends[1]); for (int i = 0; i < 16; i++) - _syscall_await(); + _sys_await(); close(ends[0]); - test(_syscall_pipe(ends, 0) >= 0); + test(_sys_pipe(ends, 0) >= 0); for (int i = 0; i < 16; i++) { if (!fork()) { close(ends[0]); - test(_syscall_write(ends[1], buf, 16, 0, 0) < 0); + test(_sys_write(ends[1], buf, 16, 0, 0) < 0); exit(0); } } close(ends[0]); for (int i = 0; i < 16; i++) - _syscall_await(); + _sys_await(); close(ends[1]); /* queueing */ - test(_syscall_pipe(ends, 0) >= 0); + test(_sys_pipe(ends, 0) >= 0); for (int i = 0; i < 16; i++) { if (!fork()) { - test(_syscall_write(ends[1], pipe_msgs[0], 5, -1, 0) == 5); + test(_sys_write(ends[1], pipe_msgs[0], 5, -1, 0) == 5); exit(0); } } close(ends[1]); for (int i = 0; i < 16; i++) { - test(_syscall_read(ends[0], buf, sizeof buf, 0) == 5); - _syscall_await(); + test(_sys_read(ends[0], buf, sizeof buf, 0) == 5); + _sys_await(); } - test(_syscall_read(ends[0], buf, sizeof buf, 0) < 0); + test(_sys_read(ends[0], buf, sizeof buf, 0) < 0); close(ends[0]); - test(_syscall_pipe(ends, 0) >= 0); + test(_sys_pipe(ends, 0) >= 0); for (int i = 0; i < 16; i++) { if (!fork()) { memset(buf, 0, sizeof buf); - test(_syscall_read(ends[0], buf, 5, -1) == 5); + test(_sys_read(ends[0], buf, 5, -1) == 5); test(!memcmp(buf, pipe_msgs[1], 5)); exit(0); } } close(ends[0]); for (int i = 0; i < 16; i++) { - test(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) == 5); - _syscall_await(); + test(_sys_write(ends[1], pipe_msgs[1], 5, -1, 0) == 5); + _sys_await(); } - test(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) < 0); + test(_sys_write(ends[1], pipe_msgs[1], 5, -1, 0) < 0); close(ends[1]); @@ -147,65 +147,65 @@ static void test_pipe(void) { static void test_memflag(void) { void *page = (void*)0x77777000; - _syscall_memflag(page, 4096, MEMFLAG_PRESENT); // allocate page + _sys_memflag(page, 4096, MEMFLAG_PRESENT); // allocate page memset(page, 77, 4096); // write to it - _syscall_memflag(page, 4096, 0); // free it + _sys_memflag(page, 4096, 0); // free it if (!fork()) { memset(page, 11, 4096); // should segfault exit(0); } else { - test(_syscall_await() != 0); // test if the process crashed + test(_sys_await() != 0); // test if the process crashed } char *pages[4]; for (size_t i = 0; i < 4; i++) { - pages[i] = _syscall_memflag(NULL, 4096, MEMFLAG_FINDFREE); - test(pages[i] == _syscall_memflag(NULL, 4096, MEMFLAG_FINDFREE | MEMFLAG_PRESENT)); + pages[i] = _sys_memflag(NULL, 4096, MEMFLAG_FINDFREE); + test(pages[i] == _sys_memflag(NULL, 4096, MEMFLAG_FINDFREE | MEMFLAG_PRESENT)); if (i > 0) test(pages[i] != pages[i-1]); *pages[i] = 0x77; } for (size_t i = 0; i < 4; i++) - _syscall_memflag(pages, 4096, MEMFLAG_PRESENT); + _sys_memflag(pages, 4096, MEMFLAG_PRESENT); } static void test_dup(void) { - handle_t pipe[2]; - handle_t h1, h2; - test(_syscall_pipe(pipe, 0) >= 0); + hid_t pipe[2]; + hid_t h1, h2; + test(_sys_pipe(pipe, 0) >= 0); if (!fork()) { close(pipe[0]); - h1 = _syscall_dup(pipe[1], -1, 0); + h1 = _sys_dup(pipe[1], -1, 0); test(h1 >= 0); test(h1 != pipe[1]); - h2 = _syscall_dup(h1, -1, 0); + h2 = _sys_dup(h1, -1, 0); test(h2 >= 0); test(h2 != pipe[1] && h2 != h1); - _syscall_write(pipe[1], "og", 2, 0, 0); - _syscall_write(h1, "h1", 2, 0, 0); - _syscall_write(h2, "h2", 2, 0, 0); + _sys_write(pipe[1], "og", 2, 0, 0); + _sys_write(h1, "h1", 2, 0, 0); + _sys_write(h2, "h2", 2, 0, 0); close(pipe[1]); - _syscall_write(h1, "h1", 2, 0, 0); - _syscall_write(h2, "h2", 2, 0, 0); + _sys_write(h1, "h1", 2, 0, 0); + _sys_write(h2, "h2", 2, 0, 0); - test(_syscall_dup(h1, pipe[1], 0) == pipe[1]); - test(_syscall_dup(h2, pipe[1], 0) == pipe[1]); - test(_syscall_dup(h1, pipe[1], 0) == pipe[1]); - test(_syscall_dup(h2, pipe[1], 0) == pipe[1]); + test(_sys_dup(h1, pipe[1], 0) == pipe[1]); + test(_sys_dup(h2, pipe[1], 0) == pipe[1]); + test(_sys_dup(h1, pipe[1], 0) == pipe[1]); + test(_sys_dup(h2, pipe[1], 0) == pipe[1]); close(h1); close(h2); - test(_syscall_dup(pipe[1], h2, 0) == h2); - _syscall_write(h2, "h2", 2, 0, 0); + test(_sys_dup(pipe[1], h2, 0) == h2); + _sys_write(h2, "h2", 2, 0, 0); close(h2); - test(_syscall_dup(pipe[1], h1, 0) == h1); - _syscall_write(h1, "h1", 2, 0, 0); + test(_sys_dup(pipe[1], h1, 0) == h1); + _sys_write(h1, "h1", 2, 0, 0); close(h1); exit(0); @@ -213,10 +213,10 @@ static void test_dup(void) { char buf[16]; size_t count = 0; close(pipe[1]); - while (_syscall_read(pipe[0], buf, sizeof buf, 0) >= 0) + while (_sys_read(pipe[0], buf, sizeof buf, 0) >= 0) count++; test(count == 7); - _syscall_await(); + _sys_await(); } @@ -226,47 +226,47 @@ static void test_dup(void) { static void test_execbuf(void) { if (!fork()) { uint64_t buf[] = { - EXECBUF_SYSCALL, _SYSCALL_EXIT, 123, 0, 0, 0, 0, + EXECBUF_SYSCALL, _SYS_EXIT, 123, 0, 0, 0, 0, }; - _syscall_execbuf(buf, sizeof buf); + _sys_execbuf(buf, sizeof buf); test_fail(); } else { - test(_syscall_await() == 123); + test(_sys_await() == 123); } } static void test_sleep(void) { - handle_t reader; + hid_t reader; FILE *writer; if (!forkpipe(&writer, &reader)) { if (!fork()) { if (!fork()) { - _syscall_sleep(100); + _sys_sleep(100); fprintf(writer, "1"); - _syscall_sleep(200); + _sys_sleep(200); fprintf(writer, "3"); - _syscall_sleep(200); + _sys_sleep(200); fprintf(writer, "5"); - _syscall_exit(0); + _sys_exit(0); } if (!fork()) { fprintf(writer, "0"); - _syscall_sleep(200); + _sys_sleep(200); fprintf(writer, "2"); - _syscall_sleep(200); + _sys_sleep(200); fprintf(writer, "4"); /* get killed while asleep * a peaceful death, i suppose. */ - for (;;) _syscall_sleep(1000000000); + for (;;) _sys_sleep(1000000000); } - _syscall_await(); - _syscall_filicide(); - _syscall_exit(0); + _sys_await(); + _sys_filicide(); + _sys_exit(0); } /* this part checks if, after killing an asleep process, * other processes can still wake up */ - _syscall_sleep(600); + _sys_sleep(600); fprintf(writer, "6"); exit(0); } else { @@ -275,7 +275,7 @@ static void test_sleep(void) { size_t pos = 0; for (;;) { char buf[128]; - long ret = _syscall_read(reader, buf, sizeof buf, 0); + long ret = _sys_read(reader, buf, sizeof buf, 0); if (ret < 0) break; test(pos + ret <= target); test(memcmp(buf, expected + pos, ret) == 0); @@ -286,8 +286,8 @@ static void test_sleep(void) { } static void test_badopen(void) { - test(_syscall_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE) >= 0); - test(_syscall_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE) == -EINVAL); + test(_sys_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE | OPEN_WRITE) >= 0); + test(_sys_open(TMPFILEPATH, strlen(TMPFILEPATH), OPEN_CREATE) == -EINVAL); } void r_k_miscsyscall(void) { diff --git a/src/user/app/tests/kernel/path.c b/src/user/app/tests/kernel/path.c index 2bce344..5392681 100644 --- a/src/user/app/tests/kernel/path.c +++ b/src/user/app/tests/kernel/path.c @@ -94,11 +94,11 @@ static void test_mount_resolve(void) { for (size_t i = 0; i < sizeof(testcases) / sizeof(testcases[0]); i++) { const char *input = testcases[i][0]; const char *expected = testcases[i][1]; - handle_t h = _syscall_open(input, strlen(input), 0); + hid_t h = _sys_open(input, strlen(input), 0); test(h >= 0); - int len = _syscall_read(h, buf, sizeof buf, 0); + int len = _sys_read(h, buf, sizeof buf, 0); test(len == (int)strlen(expected) && !memcmp(expected, buf, len)); - _syscall_close(h); + _sys_close(h); } } diff --git a/src/user/app/tests/kernel/threads.c b/src/user/app/tests/kernel/threads.c index cb7111d..abca41c 100644 --- a/src/user/app/tests/kernel/threads.c +++ b/src/user/app/tests/kernel/threads.c @@ -18,13 +18,13 @@ static void test_basic_thread(void) { test(global_n == 10); } -handle_t global_h; +hid_t global_h; static void shared_handle(void *sem) { - handle_t ends[2]; - test(_syscall_pipe(ends, 0) >= 0); + hid_t ends[2]; + test(_sys_pipe(ends, 0) >= 0); global_h = ends[0]; esem_signal(sem); - _syscall_write(ends[1], "Hello!", 7, -1, 0); + _sys_write(ends[1], "Hello!", 7, -1, 0); } static void test_shared_handle(void) { struct evil_sem *sem = esem_new(0); @@ -34,7 +34,7 @@ static void test_shared_handle(void) { esem_wait(sem); test(global_h >= 0); - test(_syscall_read(global_h, buf, sizeof buf, 0) == 7); + test(_sys_read(global_h, buf, sizeof buf, 0) == 7); test(!strcmp("Hello!", buf)); } @@ -44,7 +44,7 @@ static void many_thread(void *arg) { static void test_many_threads(void) { uint64_t n = 0; for (int i = 0; i < 10; i++) thread_create(0, many_thread, &n); - for (int i = 0; i < 10; i++) _syscall_await(); + for (int i = 0; i < 10; i++) _sys_await(); test(n == 100); } |