diff options
author | dzwdz | 2022-07-26 23:23:50 +0200 |
---|---|---|
committer | dzwdz | 2022-07-26 23:23:50 +0200 |
commit | c8b55b3fd4924abcdf919458b0d8adb0ec00b0f2 (patch) | |
tree | 4afc9ef487f435b79a7eb42cb8bc616c164e64c0 /src/user/app/tests/stress.c | |
parent | 57152f6a03d857118fa82e0a28657d869f4c7110 (diff) |
user: break out the shell and tests into separate binaries
Diffstat (limited to 'src/user/app/tests/stress.c')
-rw-r--r-- | src/user/app/tests/stress.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/src/user/app/tests/stress.c b/src/user/app/tests/stress.c new file mode 100644 index 0000000..9be88d7 --- /dev/null +++ b/src/user/app/tests/stress.c @@ -0,0 +1,28 @@ +#define TEST_MACROS +#include "tests.h" +#include <camellia/flags.h> +#include <camellia/syscalls.h> +#include <unistd.h> + +static void run_forked(void (*fn)()) { + if (!fork()) { + fn(); + 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 (!fork()) exit(0); + _syscall_await(); + } +} + +void stress_all(void) { + run_forked(stress_fork); +} |