summaryrefslogtreecommitdiff
path: root/src/cmd/tests/stress.c
blob: 8e0186e84f2f2a06779bb3e30f338b730b437ee7 (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
29
#include "tests.h"
#include <camellia/compat.h>
#include <camellia/flags.h>
#include <camellia/syscalls.h>
#include <stdlib.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 (_sys_await() != 0) test_fail();
	}
}


static void stress_fork(void) {
	for (size_t i = 0; i < 2048; i++) {
		if (!fork()) exit(0);
		_sys_await();
	}
}

void stress_all(void) {
	run_forked(stress_fork);
}