summaryrefslogtreecommitdiff
path: root/src/user/tests/stress.c
diff options
context:
space:
mode:
authordzwdz2022-07-11 21:54:51 +0200
committerdzwdz2022-07-11 21:54:51 +0200
commit2e79a2e5af3affa7a6a3becdffb1c91d89af90af (patch)
treec253761c4ec010ad14b08f9ee8dfc1a50411b30f /src/user/tests/stress.c
parent6c01d9a7e34e1fccc2775b0e2187ac5e50dd4392 (diff)
user: reorganize the userland sources
Diffstat (limited to 'src/user/tests/stress.c')
-rw-r--r--src/user/tests/stress.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/user/tests/stress.c b/src/user/tests/stress.c
new file mode 100644
index 0000000..51b9c4e
--- /dev/null
+++ b/src/user/tests/stress.c
@@ -0,0 +1,28 @@
+#define TEST_MACROS
+#include <user/lib/stdlib.h>
+#include <user/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);
+}