summaryrefslogtreecommitdiff
path: root/src/user/app/init/tests
diff options
context:
space:
mode:
Diffstat (limited to 'src/user/app/init/tests')
-rw-r--r--src/user/app/init/tests/main.c20
-rw-r--r--src/user/app/init/tests/pipe.c10
-rw-r--r--src/user/app/init/tests/semaphore.c6
-rw-r--r--src/user/app/init/tests/stress.c4
-rw-r--r--src/user/app/init/tests/tests.h2
5 files changed, 21 insertions, 21 deletions
diff --git a/src/user/app/init/tests/main.c b/src/user/app/init/tests/main.c
index cf59925..7036965 100644
--- a/src/user/app/init/tests/main.c
+++ b/src/user/app/init/tests/main.c
@@ -11,7 +11,7 @@
static void run_forked(void (*fn)()) {
if (!fork()) {
fn();
- _syscall_exit(0);
+ exit(0);
} else {
/* successful tests must return 0
* TODO add a better fail msg */
@@ -30,7 +30,7 @@ static void test_await(void) {
for (int i = 0; i < 16; i++)
if (!fork())
- _syscall_exit(i);
+ exit(i);
while ((ret = _syscall_await()) != ~0) {
assert(0 <= ret && ret < 16);
@@ -50,12 +50,12 @@ static void test_faults(void) {
if (!fork()) { // invalid memory access
asm volatile("movb $69, 0" ::: "memory");
printf("this shouldn't happen");
- _syscall_exit(-1);
+ exit(-1);
}
if (!fork()) { // #GP
asm volatile("hlt" ::: "memory");
printf("this shouldn't happen");
- _syscall_exit(-1);
+ exit(-1);
}
while (_syscall_await() != ~0) await_cnt++;
@@ -68,24 +68,24 @@ static void test_interrupted_fs(void) {
// TODO make a similar test with all 0s passed to fs_wait
struct fs_wait_response res;
_syscall_fs_wait(NULL, 0, &res);
- _syscall_exit(0);
+ exit(0);
} else { /* parent */
_syscall_mount(h, "/", 1);
int ret = _syscall_open("/", 1, 0);
// the handler quits while handling that call - but this syscall should return anyways
- _syscall_exit(ret < 0 ? 0 : -1);
+ exit(ret < 0 ? 0 : -1);
}
}
static void test_orphaned_fs(void) {
handle_t h;
if (_syscall_fork(FORK_NEWFS, &h)) { /* child */
- _syscall_exit(0);
+ exit(0);
} else { /* parent */
_syscall_mount(h, "/", 1);
int ret = _syscall_open("/", 1, 0);
// no handler will ever be available to handle this call - the syscall should instantly return
- _syscall_exit(ret < 0 ? 0 : -1);
+ exit(ret < 0 ? 0 : -1);
}
}
@@ -97,7 +97,7 @@ static void test_memflag(void) {
if (!fork()) {
memset(page, 11, 4096); // should segfault
- _syscall_exit(0);
+ exit(0);
} else {
assert(_syscall_await() != 0); // test if the process crashed
}
@@ -156,7 +156,7 @@ static void test_dup(void) {
_syscall_write(h1, "h1", 2, 0);
close(h1);
- _syscall_exit(0);
+ exit(0);
} else {
char buf[16];
size_t count = 0;
diff --git a/src/user/app/init/tests/pipe.c b/src/user/app/init/tests/pipe.c
index f7005f8..d6e954a 100644
--- a/src/user/app/init/tests/pipe.c
+++ b/src/user/app/init/tests/pipe.c
@@ -28,7 +28,7 @@ void test_pipe(void) {
ret = _syscall_write(ends[1], pipe_msgs[1], 5, -1);
assert(ret == 5);
- _syscall_exit(0);
+ exit(0);
} else {
assert(_syscall_read(ends[1], buf, 16, 0) < 0);
assert(_syscall_write(ends[0], buf, 16, 0) < 0);
@@ -56,7 +56,7 @@ void test_pipe(void) {
if (!fork()) {
close(ends[1]);
assert(_syscall_read(ends[0], buf, 16, 0) < 0);
- _syscall_exit(0);
+ exit(0);
}
}
close(ends[1]);
@@ -69,7 +69,7 @@ void test_pipe(void) {
if (!fork()) {
close(ends[0]);
assert(_syscall_write(ends[1], buf, 16, 0) < 0);
- _syscall_exit(0);
+ exit(0);
}
}
close(ends[0]);
@@ -83,7 +83,7 @@ void test_pipe(void) {
for (int i = 0; i < 16; i++) {
if (!fork()) {
assert(_syscall_write(ends[1], pipe_msgs[0], 5, -1) == 5);
- _syscall_exit(0);
+ exit(0);
}
}
close(ends[1]);
@@ -100,7 +100,7 @@ void test_pipe(void) {
memset(buf, 0, sizeof buf);
assert(_syscall_read(ends[0], buf, 5, -1) == 5);
assert(!memcmp(buf, pipe_msgs[1], 5));
- _syscall_exit(0);
+ exit(0);
}
}
close(ends[0]);
diff --git a/src/user/app/init/tests/semaphore.c b/src/user/app/init/tests/semaphore.c
index fc0cc10..e05f2f9 100644
--- a/src/user/app/init/tests/semaphore.c
+++ b/src/user/app/init/tests/semaphore.c
@@ -45,7 +45,7 @@ void test_semaphore(void) {
assert(sem1 && sem2);
if (!fork()) {
odd(pipe[1], sem1, sem2);
- _syscall_exit(69);
+ exit(69);
} else {
even(pipe[1], sem1, sem2);
assert(_syscall_await() == 69);
@@ -60,7 +60,7 @@ void test_semaphore(void) {
assert(sem1 && sem2);
if (!fork()) {
even(pipe[1], sem1, sem2);
- _syscall_exit(69);
+ exit(69);
} else {
odd(pipe[1], sem1, sem2);
assert(_syscall_await() == 69);
@@ -69,7 +69,7 @@ void test_semaphore(void) {
esem_free(sem1);
esem_free(sem2);
- _syscall_exit(0);
+ exit(0);
} else {
close(pipe[1]);
diff --git a/src/user/app/init/tests/stress.c b/src/user/app/init/tests/stress.c
index e620f0a..9be88d7 100644
--- a/src/user/app/init/tests/stress.c
+++ b/src/user/app/init/tests/stress.c
@@ -7,7 +7,7 @@
static void run_forked(void (*fn)()) {
if (!fork()) {
fn();
- _syscall_exit(0);
+ exit(0);
} else {
/* successful tests must return 0
* TODO add a better fail msg */
@@ -18,7 +18,7 @@ static void run_forked(void (*fn)()) {
static void stress_fork(void) {
for (size_t i = 0; i < 2048; i++) {
- if (!fork()) _syscall_exit(0);
+ if (!fork()) exit(0);
_syscall_await();
}
}
diff --git a/src/user/app/init/tests/tests.h b/src/user/app/init/tests/tests.h
index 23ed1e3..39294eb 100644
--- a/src/user/app/init/tests/tests.h
+++ b/src/user/app/init/tests/tests.h
@@ -13,7 +13,7 @@ void test_semaphore(void);
#define argify(str) str, sizeof(str) - 1
#define test_fail() do { \
printf("\033[31m" "TEST FAILED: %s:%xh\n" "\033[0m", __func__, __LINE__); \
- _syscall_exit(0); \
+ exit(0); \
} while (0)
#define assert(cond) if (!(cond)) test_fail();