summaryrefslogtreecommitdiff
path: root/src/user/app/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/tests')
-rw-r--r--src/user/app/tests/pipe.c20
-rw-r--r--src/user/app/tests/semaphore.c14
-rw-r--r--src/user/app/tests/tests.c58
3 files changed, 46 insertions, 46 deletions
diff --git a/src/user/app/tests/pipe.c b/src/user/app/tests/pipe.c
index d6e954a..2d67fa7 100644
--- a/src/user/app/tests/pipe.c
+++ b/src/user/app/tests/pipe.c
@@ -17,28 +17,28 @@ void test_pipe(void) {
if (!fork()) {
/* those repeated asserts ensure that you can't read/write to the wrong ends */
assert(_syscall_read(ends[1], buf, 16, 0) < 0);
- assert(_syscall_write(ends[0], buf, 16, 0) < 0);
+ assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
- ret = _syscall_write(ends[1], pipe_msgs[0], 5, -1);
+ ret = _syscall_write(ends[1], pipe_msgs[0], 5, -1, 0);
assert(ret == 5);
assert(_syscall_read(ends[1], buf, 16, 0) < 0);
- assert(_syscall_write(ends[0], buf, 16, 0) < 0);
+ assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
- ret = _syscall_write(ends[1], pipe_msgs[1], 5, -1);
+ ret = _syscall_write(ends[1], pipe_msgs[1], 5, -1, 0);
assert(ret == 5);
exit(0);
} else {
assert(_syscall_read(ends[1], buf, 16, 0) < 0);
- assert(_syscall_write(ends[0], buf, 16, 0) < 0);
+ assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
ret = _syscall_read(ends[0], buf, 16, 0);
assert(ret == 5);
assert(!memcmp(buf, pipe_msgs[0], 5));
assert(_syscall_read(ends[1], buf, 16, 0) < 0);
- assert(_syscall_write(ends[0], buf, 16, 0) < 0);
+ assert(_syscall_write(ends[0], buf, 16, 0, 0) < 0);
_syscall_read(ends[0], buf, 16, 0);
assert(ret == 5);
@@ -68,7 +68,7 @@ void test_pipe(void) {
for (int i = 0; i < 16; i++) {
if (!fork()) {
close(ends[0]);
- assert(_syscall_write(ends[1], buf, 16, 0) < 0);
+ assert(_syscall_write(ends[1], buf, 16, 0, 0) < 0);
exit(0);
}
}
@@ -82,7 +82,7 @@ void test_pipe(void) {
assert(_syscall_pipe(ends, 0) >= 0);
for (int i = 0; i < 16; i++) {
if (!fork()) {
- assert(_syscall_write(ends[1], pipe_msgs[0], 5, -1) == 5);
+ assert(_syscall_write(ends[1], pipe_msgs[0], 5, -1, 0) == 5);
exit(0);
}
}
@@ -105,10 +105,10 @@ void test_pipe(void) {
}
close(ends[0]);
for (int i = 0; i < 16; i++) {
- assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1) == 5);
+ assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) == 5);
_syscall_await();
}
- assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1) < 0);
+ assert(_syscall_write(ends[1], pipe_msgs[1], 5, -1, 0) < 0);
close(ends[1]);
diff --git a/src/user/app/tests/semaphore.c b/src/user/app/tests/semaphore.c
index e05f2f9..956734e 100644
--- a/src/user/app/tests/semaphore.c
+++ b/src/user/app/tests/semaphore.c
@@ -8,29 +8,29 @@
#include <user/lib/esemaphore.h>
static void odd(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
- _syscall_write(out, "1", 1, -1);
+ _syscall_write(out, "1", 1, -1, 0);
esem_signal(sem1);
esem_wait(sem2);
- _syscall_write(out, "3", 1, -1);
+ _syscall_write(out, "3", 1, -1, 0);
esem_signal(sem1);
esem_wait(sem2);
- _syscall_write(out, "5", 1, -1);
+ _syscall_write(out, "5", 1, -1, 0);
esem_signal(sem1);
}
static void even(handle_t out, struct evil_sem *sem1, struct evil_sem *sem2) {
esem_wait(sem1);
- _syscall_write(out, "2", 1, -1);
+ _syscall_write(out, "2", 1, -1, 0);
esem_signal(sem2);
esem_wait(sem1);
- _syscall_write(out, "4", 1, -1);
+ _syscall_write(out, "4", 1, -1, 0);
esem_signal(sem2);
esem_wait(sem1);
- _syscall_write(out, "6", 1, -1);
+ _syscall_write(out, "6", 1, -1, 0);
esem_signal(sem2);
}
@@ -53,7 +53,7 @@ void test_semaphore(void) {
esem_free(sem1);
esem_free(sem2);
- _syscall_write(pipe[1], "|", 1, -1);
+ _syscall_write(pipe[1], "|", 1, -1, 0);
sem1 = esem_new(0);
sem2 = esem_new(0);
diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c
index 458f748..1d1156e 100644
--- a/src/user/app/tests/tests.c
+++ b/src/user/app/tests/tests.c
@@ -133,13 +133,13 @@ static void test_dup(void) {
assert(h2 >= 0);
assert(h2 != pipe[1] && h2 != h1);
- _syscall_write(pipe[1], "og", 2, 0);
- _syscall_write(h1, "h1", 2, 0);
- _syscall_write(h2, "h2", 2, 0);
+ _syscall_write(pipe[1], "og", 2, 0, 0);
+ _syscall_write(h1, "h1", 2, 0, 0);
+ _syscall_write(h2, "h2", 2, 0, 0);
close(pipe[1]);
- _syscall_write(h1, "h1", 2, 0);
- _syscall_write(h2, "h2", 2, 0);
+ _syscall_write(h1, "h1", 2, 0, 0);
+ _syscall_write(h2, "h2", 2, 0, 0);
assert(_syscall_dup(h1, pipe[1], 0) == pipe[1]);
assert(_syscall_dup(h2, pipe[1], 0) == pipe[1]);
@@ -149,11 +149,11 @@ static void test_dup(void) {
close(h2);
assert(_syscall_dup(pipe[1], h2, 0) == h2);
- _syscall_write(h2, "h2", 2, 0);
+ _syscall_write(h2, "h2", 2, 0, 0);
close(h2);
assert(_syscall_dup(pipe[1], h1, 0) == h1);
- _syscall_write(h1, "h1", 2, 0);
+ _syscall_write(h1, "h1", 2, 0, 0);
close(h1);
exit(0);
@@ -200,27 +200,27 @@ static void test_efault(void) {
memcpy(str2, str, 16);
assert((h = _syscall_open(tmpfilepath, strlen(tmpfilepath), OPEN_CREATE)));
- assert(_syscall_write(h, str, 16, 0) == 16);
- assert(_syscall_write(h, str2, 16, 0) == 16);
+ assert(_syscall_write(h, str, 16, 0, 0) == 16);
+ assert(_syscall_write(h, str2, 16, 0, 0) == 16);
- assert(_syscall_write(h, invalid, 16, 0) == -EFAULT);
+ assert(_syscall_write(h, invalid, 16, 0, 0) == -EFAULT);
/* x64 canonical pointers */
- assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0) == -EFAULT);
-
- assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0) == -EFAULT);
- assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0) == -EFAULT);
-
- assert(_syscall_write(h, str, 16, 0) == 16);
+ assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x8000000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x1000000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0100000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0010000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0001000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str ^ 0x0000800000000000), 16, 0, 0) == -EFAULT);
+
+ assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x8000000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x1000000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0100000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0010000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0001000000000000), 16, 0, 0) == -EFAULT);
+ assert(_syscall_write(h, (void*)((uintptr_t)str2 ^ 0x0000800000000000), 16, 0, 0) == -EFAULT);
+
+ assert(_syscall_write(h, str, 16, 0, 0) == 16);
close(h);
}
@@ -229,16 +229,16 @@ static void test_execbuf(void) {
const char str1[] = "test_execbuf: string 1\n";
const char str2[] = "test_execbuf: and 2\n";
uint64_t buf[] = {
- EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str1, sizeof(str1) - 1, -1,
- EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str2, sizeof(str2) - 1, -1,
- EXECBUF_SYSCALL, _SYSCALL_EXIT, 0, 0, 0, 0,
+ EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str1, sizeof(str1) - 1, -1, 0,
+ EXECBUF_SYSCALL, _SYSCALL_WRITE, 1, (uintptr_t)str2, sizeof(str2) - 1, -1, 0,
+ EXECBUF_SYSCALL, _SYSCALL_EXIT, 0, 0, 0, 0, 0,
};
_syscall_execbuf(buf, sizeof buf);
test_fail();
}
static void test_misc(void) {
- assert(_syscall(~0, 0, 0, 0, 0) < 0); /* try making an invalid syscall */
+ assert(_syscall(~0, 0, 0, 0, 0, 0) < 0); /* try making an invalid syscall */
}