From 2e79a2e5af3affa7a6a3becdffb1c91d89af90af Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 11 Jul 2022 21:54:51 +0200 Subject: user: reorganize the userland sources --- src/user/tests/stress.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 src/user/tests/stress.c (limited to 'src/user/tests/stress.c') diff --git a/src/user/tests/stress.c b/src/user/tests/stress.c new file mode 100644 index 0000000..51b9c4e --- /dev/null +++ b/src/user/tests/stress.c @@ -0,0 +1,28 @@ +#define TEST_MACROS +#include +#include +#include +#include + +static void run_forked(void (*fn)()) { + if (!_syscall_fork(0, NULL)) { + fn(); + _syscall_exit(0); + } else { + /* successful tests must return 0 + * TODO add a better fail msg */ + if (_syscall_await() != 0) test_fail(); + } +} + + +static void stress_fork(void) { + for (size_t i = 0; i < 2048; i++) { + if (!_syscall_fork(0, NULL)) _syscall_exit(0); + _syscall_await(); + } +} + +void stress_all(void) { + run_forked(stress_fork); +} -- cgit v1.2.3