diff --git a/mps/qa/function/19.c b/mps/qa/function/19.c new file mode 100644 index 00000000000..74387948494 --- /dev/null +++ b/mps/qa/function/19.c @@ -0,0 +1,57 @@ +/* test create lots of aps at once (and cause to run out of memory) + language c + link testlib.o newfmt.o +*/ + +#include "testlib.h" +#include "mpscamc.h" +#include "mpscmv.h" +#include "newfmt.h" + +void *stackpointer; + +static void test(void) { + mps_space_t space; + mps_pool_t pool; + mps_thr_t thread; + mps_fmt_t format; + mps_root_t root; + mps_ap_t ap; + mps_addr_t q; + + int p; + + die(mps_space_create(&space), "create"); + die(mps_thread_reg(&thread, space), "register thread"); + die(mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread, + mps_stack_scan_ambig, stackpointer, 0), "create root"); + die(mps_fmt_create_A(&format, space, &fmtA), "create format"); + + die(mps_pool_create(&pool, space, mps_class_mv(), + 1024*32, 1024*16, 1024*256), "pool"); + + while (mps_alloc(&q, pool, 64*1024)==MPS_RES_OK); + p=0; + + die(mps_pool_create(&pool, space, mps_class_amc(), format), + "create pool"); + + while (1) { + p++; + die(mps_ap_create(&ap, pool, MPS_RANK_EXACT), + "create ap"); + report("ap", "%i", p); + } + + asserts(1, "Unreachable!"); +} + +int main(void) +{ + void *m; + stackpointer=&m; /* hack to get stack pointer */ + + easy_tramp(test); + pass(); + return 0; +} diff --git a/mps/qa/function/20.c b/mps/qa/function/20.c new file mode 100644 index 00000000000..5f66d2c2b9c --- /dev/null +++ b/mps/qa/function/20.c @@ -0,0 +1,51 @@ +/* test create lots of formats at once (and cause to run out of memory) + language c + link testlib.o newfmt.o +*/ + +#include "testlib.h" +#include "mpscamc.h" +#include "mpscmv.h" +#include "newfmt.h" + +void *stackpointer; + +static void test(void) { + mps_space_t space; + mps_pool_t pool; + mps_thr_t thread; + mps_fmt_t format; + mps_root_t root; + mps_addr_t q; + + int p; + + die(mps_space_create(&space), "create"); + die(mps_thread_reg(&thread, space), "register thread"); + die(mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread, + mps_stack_scan_ambig, stackpointer, 0), "create root"); + + die(mps_pool_create(&pool, space, mps_class_mv(), + 1024*32, 1024*16, 1024*256), "pool"); + + while (mps_alloc(&q, pool, 64*1024)==MPS_RES_OK); + p=0; + + while (1) { + p++; + die(mps_fmt_create_A(&format, space, &fmtA), "create format"); + report("format", "%i", p); + } + + asserts(1, "Unreachable!"); +} + +int main(void) +{ + void *m; + stackpointer=&m; /* hack to get stack pointer */ + + easy_tramp(test); + pass(); + return 0; +} diff --git a/mps/qa/function/21.c b/mps/qa/function/21.c new file mode 100644 index 00000000000..f6a4ce78378 --- /dev/null +++ b/mps/qa/function/21.c @@ -0,0 +1,32 @@ +/* test allocate large promise, make it small, repeat + language c + link testlib.o +*/ + +#include "testlib.h" +#include "mpscmv.h" + +static void test(void) { + mps_space_t space; + mps_pool_t pool; + mps_addr_t q; + int p; + + die(mps_space_create(&space), "create"); + + die(mps_pool_create(&pool, space, mps_class_mv(), + 1024*32, 1024*16, 1024*256), "pool"); + + for (p=0; p<2000; p++) { + die(mps_alloc(&q, pool, 1024*1024), "alloc"); + q = (mps_addr_t) ((char *) q + 8); + mps_free(pool, q, 256*1024-8); + report("promise", "%i", p); + } +} + +int main(void) { + easy_tramp(test); + pass(); + return 0; +} diff --git a/mps/qa/function/22.c b/mps/qa/function/22.c new file mode 100644 index 00000000000..a2ba61dc8a5 --- /dev/null +++ b/mps/qa/function/22.c @@ -0,0 +1,34 @@ +/* test allocate large promise, make it small, repeat interleaved + language c + link testlib.o +*/ + +#include "testlib.h" +#include "mpscmv.h" + +static void test(void) { + mps_space_t space; + mps_pool_t pool; + mps_addr_t q, r; + int p; + + die(mps_space_create(&space), "create"); + + die(mps_pool_create(&pool, space, mps_class_mv(), + 1024*32, 1024*16, 1024*256), "pool"); + + die(mps_alloc(&q, pool, 1024*1024), "alloc"); + + for (p=0; p<2000; p++) { + report("promise", "%i", p); + die(mps_alloc(&r, pool, 1024*1024), "alloc"); + mps_free(pool, q, 256*1024-8); + q = (mps_addr_t) ((char *) r + 8); + } +} + +int main(void) { + easy_tramp(test); + pass(); + return 0; +}