From cd9e76a6de0c0002948e1cdc8fb2aee6c7a6bcd9 Mon Sep 17 00:00:00 2001 From: Gareth Rees Date: Fri, 6 Jul 2018 14:26:54 +0100 Subject: [PATCH] Check that traces with no condemned objects can be started and finished without error in each automatic pool class. regression test for job004086. Copied from Perforce Change: 194475 --- mps/test/function/234.c | 79 +++++++++++++++++++++++++++++++++++++++ mps/test/testsets/passing | 1 + 2 files changed, 80 insertions(+) create mode 100644 mps/test/function/234.c diff --git a/mps/test/function/234.c b/mps/test/function/234.c new file mode 100644 index 00000000000..7d160aaef1e --- /dev/null +++ b/mps/test/function/234.c @@ -0,0 +1,79 @@ +/* +TEST_HEADER + id = $Id$ + summary = empty traces (regression test for job004086) + language = c + link = testlib.o rankfmt.o +END_HEADER +*/ + +#include "mpsavm.h" +#include "mpscamc.h" +#include "mpscams.h" +#include "mpscawl.h" +#include "mpsclo.h" +#include "rankfmt.h" +#include "testlib.h" + +static void *stackpointer; + +static void test_pool(mps_pool_class_t pool_class) +{ + mps_arena_t arena; + mps_pool_t pool; + mps_thr_t thread; + mps_root_t root; + mps_fmt_t format; + mps_ap_t ap; + void *addr; + + cdie(mps_arena_create_k(&arena, mps_arena_class_vm(), mps_args_none), + "create arena"); + cdie(mps_thread_reg(&thread, arena), "register thread"); + cdie(mps_root_create_thread(&root, arena, thread, stackpointer), + "create thread"); + cdie(mps_fmt_create_A(&format, arena, &fmtA), "create format"); + MPS_ARGS_BEGIN(args) { + MPS_ARGS_ADD(args, MPS_KEY_FORMAT, format); + cdie(mps_pool_create_k(&pool, arena, pool_class, args), "create pool"); + } MPS_ARGS_END(args); + cdie(mps_ap_create_k(&ap, pool, mps_args_none), "create ap"); + + /* First reserve on the allocation point causes the pool to create a + buffered segment but with no objects yet. */ + cdie(mps_reserve(&addr, ap, MPS_PF_ALIGN), "reserve"); + + /* Create a trace and condemn the world, but discover that no + objects were condemned, so abort the trace. */ + mps_arena_collect(arena); + + /* Collect again to ensure that aborting the trace after condemning + didn't violate the trace invariants. */ + mps_arena_collect(arena); + + asserts(mps_commit(ap, &addr, MPS_PF_ALIGN), "commit"); + + mps_ap_destroy(ap); + mps_pool_destroy(pool); + mps_fmt_destroy(format); + mps_root_destroy(root); + mps_thread_dereg(thread); + mps_arena_destroy(arena); +} + +static void test(void) +{ + test_pool(mps_class_amc()); + test_pool(mps_class_ams()); + test_pool(mps_class_awl()); + test_pool(mps_class_lo()); +} + +int main(void) +{ + void *m; + stackpointer = &m; /* hack to get stack pointer */ + easy_tramp(test); + pass(); + return 0; +} diff --git a/mps/test/testsets/passing b/mps/test/testsets/passing index 6a747a97428..ab73a7e1952 100644 --- a/mps/test/testsets/passing +++ b/mps/test/testsets/passing @@ -173,3 +173,4 @@ function/229.c function/231.c function/232.c function/233.c +function/234.c