diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-26 19:54:31 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-08-26 19:54:31 +0300 |
| commit | f81cad34c0e29384a393bf3aa25dbce3d5962c53 (patch) | |
| tree | b5f15e38ccab11cb066b8ab0d511609079f51d17 /tests | |
| parent | b25156373cd89792b1c457b77699bb7f9beb430d (diff) | |
| download | kmi-f81cad34c0e29384a393bf3aa25dbce3d5962c53.tar.gz kmi-f81cad34c0e29384a393bf3aa25dbce3d5962c53.zip | |
check for running out of memory during fork
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/fork-exhaustion/init.c | 23 | ||||
| -rw-r--r-- | tests/fork-exhaustion/source.mk | 2 |
2 files changed, 25 insertions, 0 deletions
diff --git a/tests/fork-exhaustion/init.c b/tests/fork-exhaustion/init.c new file mode 100644 index 0000000..0e330f4 --- /dev/null +++ b/tests/fork-exhaustion/init.c @@ -0,0 +1,23 @@ +#include <common/test.h> + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(pid); + UNUSED(tid); + UNUSED(d0); + UNUSED(d1); + UNUSED(d2); + UNUSED(d3); + + check(pid == 0, "illegal pid for init\n"); + id_t our_id = 0; + while (1) { + printf("forking\n"); + id_t new_id = sys_fork(&our_id); + if (new_id < 0) + break; + } + + /* if kernel didn't crash, we consider it a success */ + ok(); +} diff --git a/tests/fork-exhaustion/source.mk b/tests/fork-exhaustion/source.mk new file mode 100644 index 0000000..458973d --- /dev/null +++ b/tests/fork-exhaustion/source.mk @@ -0,0 +1,2 @@ +DO != ./scripts/gen-prog -n fork-exhaustion -p init init.c +DO != ./scripts/gen-simple -n fork-exhaustion -p init |
