summaryrefslogtreecommitdiff
path: root/src/init/tests/stress.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/init/tests/stress.c')
-rw-r--r--src/init/tests/stress.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/init/tests/stress.c b/src/init/tests/stress.c
new file mode 100644
index 0000000..11c30cb
--- /dev/null
+++ b/src/init/tests/stress.c
@@ -0,0 +1,28 @@
+#define TEST_MACROS
+#include <init/stdlib.h>
+#include <init/tests/main.h>
+#include <shared/flags.h>
+#include <shared/syscalls.h>
+
+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);
+}