diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-11-02 16:34:38 +0200 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-11-02 16:34:38 +0200 |
| commit | 17fd9daf39cf79ae310c1b7d0eb459802517dc6a (patch) | |
| tree | 1f9061bc489289769d134e97efea805cbf1bf29a /tests/spawn-exhaustion | |
| parent | 010152de4f19fcb4f1b627123aa27f08deb13e72 (diff) | |
| download | kmi-17fd9daf39cf79ae310c1b7d0eb459802517dc6a.tar.gz kmi-17fd9daf39cf79ae310c1b7d0eb459802517dc6a.zip | |
check spawn exhaustion
Diffstat (limited to 'tests/spawn-exhaustion')
| -rw-r--r-- | tests/spawn-exhaustion/init.c | 35 | ||||
| -rw-r--r-- | tests/spawn-exhaustion/source.mk | 1 | ||||
| -rw-r--r-- | tests/spawn-exhaustion/spawn.c | 14 |
3 files changed, 50 insertions, 0 deletions
diff --git a/tests/spawn-exhaustion/init.c b/tests/spawn-exhaustion/init.c new file mode 100644 index 0000000..1862648 --- /dev/null +++ b/tests/spawn-exhaustion/init.c @@ -0,0 +1,35 @@ +#include <common/test.h> +#include <common/cpio.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"); + printf("finding spawn in cpio archive %lx...\n", d2); + struct cpio_header *cp = cpio_find_file((const void *)d2, + "spawn", sizeof("spawn") - 1); + + check(cp, "couldn't find spawn?\n"); + long name_len = convnum(cp->c_namesize, 8, 16); + uintptr_t spawn = (uintptr_t)(cp) + align_up(sizeof(struct cpio_header) + name_len, 4); + printf("found spawn at %lx\n", spawn); + + printf("doing spawns...\n"); + + int counter = 0; + while (1) { + printf("spawning %d\n", counter++); + id_t new = sys_spawn(spawn, 0); + if (new < 0) + break; + } + + /* could also check for memory leaks but this is good enough for now */ + ok(); +} diff --git a/tests/spawn-exhaustion/source.mk b/tests/spawn-exhaustion/source.mk new file mode 100644 index 0000000..c665e49 --- /dev/null +++ b/tests/spawn-exhaustion/source.mk @@ -0,0 +1 @@ +DO != ./scripts/gen-simple -n spawn-exhaustion -p init -p spawn diff --git a/tests/spawn-exhaustion/spawn.c b/tests/spawn-exhaustion/spawn.c new file mode 100644 index 0000000..e281fc8 --- /dev/null +++ b/tests/spawn-exhaustion/spawn.c @@ -0,0 +1,14 @@ +#include <common/test.h> + +START(pid, tid, d0, d1, d2, d3) +{ + UNUSED(pid); + UNUSED(tid); + UNUSED(d0); + UNUSED(d1); + UNUSED(d2); + UNUSED(d3); + + printf("shouldn't be here\n"); + /* just die or something */ +} |
