diff options
author | dzwdz | 2022-08-04 15:58:54 +0200 |
---|---|---|
committer | dzwdz | 2022-08-04 15:58:54 +0200 |
commit | 81a58004d51547d074b4218f906b0b95f2b2c5dc (patch) | |
tree | 4301047fc342e165bc5a043a04b5fed44b8e8084 /src/user/app/tests | |
parent | 4a844820866094ff7d57435a16b7c23a9126814d (diff) |
syscalls: add _syscall_sleep()
Diffstat (limited to 'src/user/app/tests')
-rw-r--r-- | src/user/app/tests/tests.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/user/app/tests/tests.c b/src/user/app/tests/tests.c index d655ab9..5c40bcd 100644 --- a/src/user/app/tests/tests.c +++ b/src/user/app/tests/tests.c @@ -254,7 +254,37 @@ static void test_strtol(void) { assert(!strcmp("hello", end)); assert(01234 == strtol(" 01234hello", &end, 0)); assert(!strcmp("hello", end)); +} + +static void test_sleep(void) { + // TODO yet another of those fake tests that you have to verify by hand + if (!fork()) { + if (!fork()) { + _syscall_sleep(100); + printf("1\n"); + _syscall_sleep(200); + printf("3\n"); + _syscall_sleep(200); + printf("5\n"); + _syscall_exit(0); + } + if (!fork()) { + printf("0\n"); + _syscall_sleep(200); + printf("2\n"); + _syscall_sleep(200); + printf("4\n"); + /* get killed while asleep + * a peaceful death, i suppose. */ + for (;;) _syscall_sleep(1000000000); + } + _syscall_await(); + _syscall_exit(0); + } + /* this part checks if, after killing an asleep process, other processes can still wake up */ + _syscall_sleep(600); + printf("6\n"); } static void test_misc(void) { @@ -276,6 +306,7 @@ int main(void) { run_forked(test_execbuf); run_forked(test_printf); run_forked(test_strtol); + run_forked(test_sleep); run_forked(test_misc); return 1; } |