summaryrefslogtreecommitdiff
path: root/src/user/app/init/tests/stress.c
blob: e620f0aab7726e17f0d96ea2c76dda501efbf83b (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 "tests.h"
#include <camellia/flags.h>
#include <camellia/syscalls.h>
#include <unistd.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);
}