blob: 9af1706961a084940df89d12ad2e36047fa3cbd5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#define TEST_MACROS
#include <shared/flags.h>
#include <shared/syscalls.h>
#include <user/app/init/tests/main.h>
#include <user/lib/stdlib.h>
static void run_forked(void (*fn)()) {
if (!fork()) {
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 (!fork()) _syscall_exit(0);
_syscall_await();
}
}
void stress_all(void) {
run_forked(stress_fork);
}
|