1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-04-23 22:42:01 -07:00
new test

Copied from Perforce
 Change: 20310
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Tucker 1998-10-29 13:11:07 +00:00
parent f193f28b79
commit 84e0b4bf86
4 changed files with 497 additions and 0 deletions

107
mps/qa/function/125.c Normal file
View file

@ -0,0 +1,107 @@
/*
TEST_HEADER
id = $HopeName$
summary = extensible arena test (small objects)
language = c
link = testlib.o rankfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscamc.h"
#include "mpsavm.h"
#include "rankfmt.h"
void *stackpointer;
static void test(void)
{
mps_space_t space;
mps_pool_t pool;
mps_thr_t thread;
mps_root_t root, root1;
mps_fmt_t format;
mps_ap_t ap;
mycell *a, *b;
int j;
/* create an arena that can't grow beyond 1 M */
cdie(mps_arena_create(&space, mps_arena_class_vm(), (size_t) (1024*1024*1)),
"create arena");
cdie(mps_thread_reg(&thread, space), "register thread");
cdie(
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
mps_stack_scan_ambig, stackpointer, 0),
"create root");
cdie(
mps_root_create_table(&root1,space,MPS_RANK_AMBIG,0,&exfmt_root,1),
"create table root");
cdie(
mps_fmt_create_A(&format, space, &fmtA),
"create format");
cdie(
mps_pool_create(&pool, space, mps_class_amc(), format),
"create pool");
cdie(
mps_ap_create(&ap, pool, MPS_RANK_EXACT),
"create ap");
comment("ready");
b = allocone(ap, 2, MPS_RANK_EXACT);
/* allocate lots of little objects */
while (mps_arena_committed(space) < 1024ul*1024ul*20) {
comment("reserved %ld, committed %ld",
mps_arena_reserved(space), mps_arena_committed(space));
for (j=0; j<10000; j++) {
a = allocone(ap, 2, MPS_RANK_EXACT);
setref(a, 0, b);
b = a;
a = allocone(ap, 1, MPS_RANK_EXACT);
setref(b, 1, a);
}
mps_arena_collect(space);
}
mps_ap_destroy(ap);
comment("Destroyed ap.");
mps_pool_destroy(pool);
comment("Destroyed pool.");
mps_fmt_destroy(format);
comment("Destroyed format.");
mps_root_destroy(root);
mps_root_destroy(root1);
comment("Destroyed roots.");
mps_thread_dereg(thread);
comment("Deregistered thread.");
mps_space_destroy(space);
comment("Destroyed space.");
}
int main(void)
{
void *m;
stackpointer=&m; /* hack to get stack pointer */
easy_tramp(test);
pass();
return 0;
}

109
mps/qa/function/126.c Normal file
View file

@ -0,0 +1,109 @@
/*
TEST_HEADER
id = $HopeName$
summary = extensible arena test (huge objects)
language = c
link = testlib.o rankfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscamc.h"
#include "mpsavm.h"
#include "rankfmt.h"
void *stackpointer;
static void test(void)
{
mps_space_t space;
mps_pool_t pool;
mps_thr_t thread;
mps_root_t root, root1;
mps_fmt_t format;
mps_ap_t ap;
mycell *b;
/* create an arena that can't grow beyond 1 M */
cdie(mps_arena_create(&space, mps_arena_class_vm(), (size_t) (1024*1024*1)),
"create arena");
cdie(mps_thread_reg(&thread, space), "register thread");
cdie(
mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
mps_stack_scan_ambig, stackpointer, 0),
"create root");
cdie(
mps_root_create_table(&root1,space,MPS_RANK_AMBIG,0,&exfmt_root,1),
"create table root");
cdie(
mps_fmt_create_A(&format, space, &fmtA),
"create format");
cdie(
mps_pool_create(&pool, space, mps_class_amc(), format),
"create pool");
cdie(
mps_ap_create(&ap, pool, MPS_RANK_EXACT),
"create ap");
comment("ready");
comment("reserved %ld, committed %ld",
mps_arena_reserved(space), mps_arena_committed(space));
b = allocdumb(ap, 1024ul*1024ul*40, MPS_RANK_EXACT);
comment("alloc 40 MB");
comment("reserved %ld, committed %ld",
mps_arena_reserved(space), mps_arena_committed(space));
b = allocdumb(ap, 1024ul*1024ul*40, MPS_RANK_EXACT);
comment("alloc 80 MB");
comment("reserved %ld, committed %ld",
mps_arena_reserved(space), mps_arena_committed(space));
mps_arena_collect(space);
comment("collected");
comment("reserved %ld, committed %ld",
mps_arena_reserved(space), mps_arena_committed(space));
mps_ap_destroy(ap);
comment("Destroyed ap.");
mps_pool_destroy(pool);
comment("Destroyed pool.");
mps_fmt_destroy(format);
comment("Destroyed format.");
mps_root_destroy(root);
mps_root_destroy(root1);
comment("Destroyed roots.");
mps_thread_dereg(thread);
comment("Deregistered thread.");
mps_space_destroy(space);
comment("Destroyed space.");
}
int main(void)
{
void *m;
stackpointer=&m; /* hack to get stack pointer */
easy_tramp(test);
pass();
return 0;
}

121
mps/qa/function/130.c Normal file
View file

@ -0,0 +1,121 @@
/*
TEST_HEADER
id = $HopeName$
summary = allocation shouldn't fail if there's garbage to collect (2)
language = c
link = testlib.o rankfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscamc.h"
#include "mpsavm.h"
#include "rankfmt.h"
void *stackpointer;
mps_pool_t poolmv;
mps_space_t space;
static void test(void)
{
mps_pool_t pool;
mps_thr_t thread;
mps_root_t root;
mps_fmt_t format;
mps_ap_t ap, ap2;
mycell *a, *b;
mps_res_t res;
int i;
/* create an arena that can't grow beyond 30 M */
cdie(mps_arena_create(&space, mps_arena_class_vm(), (size_t) (1024*1024*30)),
"create arena");
mps_arena_commit_limit_set(space, (size_t) (1024*1024*40));
cdie(mps_thread_reg(&thread, space), "register thread");
cdie(mps_root_create_reg(&root, space, MPS_RANK_AMBIG, 0, thread,
mps_stack_scan_ambig, stackpointer, 0), "create root");
cdie(
mps_fmt_create_A(&format, space, &fmtA),
"create format");
cdie(
mps_pool_create(&pool, space, mps_class_amc(), format),
"create pool");
cdie(
mps_ap_create(&ap, pool, MPS_RANK_EXACT),
"create ap");
/* allocate until full */
i = 0;
b = NULL;
while (allocrone(&a, ap, 128, MPS_RANK_EXACT) == MPS_RES_OK) {
i++;
setref(a, 0, b);
b = a;
}
comment("%d objs allocated.", i);
report("committed", "%ld", mps_arena_committed(space));
/* try to allocate 10 times */
cdie(mps_ap_create(&ap2, pool, MPS_RANK_EXACT), "create second ap");
mps_ap_destroy(ap);
for (i = 0; i < 10; i++) {
res = allocrone(&a, ap2, 128, MPS_RANK_EXACT);
report("predie", "%s", err_text(res));
}
/* now let everything die, and try to allocate 10 times */
mps_root_destroy(root);
for (i = 0; i < 10; i++) {
res = allocrone(&a, ap2, 128, MPS_RANK_EXACT);
report("postdie", "%s", err_text(res));
}
die(allocrone(&a, ap2, 128, MPS_RANK_EXACT), "alloc failed");
mps_ap_destroy(ap2);
comment("Destroyed ap.");
mps_pool_destroy(pool);
comment("Destroyed pool.");
mps_fmt_destroy(format);
comment("Destroyed format.");
mps_thread_dereg(thread);
comment("Deregistered thread.");
mps_space_destroy(space);
comment("Destroyed space.");
}
int main(void)
{
void *m;
stackpointer=&m; /* hack to get stack pointer */
easy_tramp(test);
pass();
return 0;
}

160
mps/qa/function/134.c Normal file
View file

@ -0,0 +1,160 @@
/*
TEST_HEADER
id = $HopeName$
summary = test of ramp allocation with smallish arena (64MB)
language = c
link = testlib.o rankfmt.o
OUTPUT_SPEC
result = pass
END_HEADER
*/
#include "testlib.h"
#include "mpscamc.h"
#include "mpsavm.h"
#include "rankfmt.h"
#define ARENALIMIT (64)
#define TABSIZE (50000)
#define ENTERRAMP (30000)
#define LEAVERAMP (100000)
#define BACKSIZE (128)
#define BACKITER (32)
#define RAMPSIZE (128)
#define ITERATIONS (1000000ul)
#define RAMP_INTERFACE
/*
#define COLLECT_WORLD
*/
void *stackpointer;
mps_space_t arena;
mps_pool_t poolamc;
mps_thr_t thread;
mps_root_t root, root1;
mps_fmt_t format;
mps_ap_t apamc;
static mps_addr_t objtab[TABSIZE];
static void alloc_back(void) {
long int i, j;
for (j = 0; j < BACKITER; j++) {
i = ranint(ranint(ranint(ranint(TABSIZE)+1)+1)+1);
objtab[i] = allocdumb(apamc, BACKSIZE, MPS_RANK_EXACT);
}
}
static void test(void) {
long int i;
long int rsize;
int inramp;
mycell *r, *s;
cdie(mps_arena_create(&arena, mps_arena_class_vm(),
(size_t) 1024*1024*ARENALIMIT),
"create space");
cdie(mps_thread_reg(&thread, arena), "register thread");
cdie(
mps_root_create_reg(&root, arena, MPS_RANK_AMBIG, 0, thread,
mps_stack_scan_ambig, stackpointer, 0),
"create root");
cdie(
mps_root_create_table(&root1, arena, MPS_RANK_EXACT, 0, &objtab[0], TABSIZE),
"create root table");
cdie(
mps_fmt_create_A(&format, arena, &fmtA),
"create format");
cdie(
mps_pool_create(&poolamc, arena, mps_class_amc(), format),
"create pool");
cdie(
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
"create ap");
inramp = 0;
for (i = 0; i < ITERATIONS; i++) {
if (i % 10000 == 0) {
comment("%ld of %ld", i, ITERATIONS);
}
alloc_back();
if (inramp) {
s = allocone(apamc, 3, MPS_RANK_EXACT);
setref(r, 0, s);
setref(s, 1, r);
r = s;
s = allocdumb(apamc, RAMPSIZE, MPS_RANK_EXACT);
setref(r, 2, s);
rsize ++;
if (ranint(LEAVERAMP) == 0) {
r = allocone(apamc, 2, MPS_RANK_EXACT);
s = allocone(apamc, 2, MPS_RANK_EXACT);
#ifdef RAMP_INTERFACE
mps_ap_alloc_pattern_end(apamc, mps_alloc_pattern_ramp());
#endif
#ifdef COLLECT_WORLD
mps_arena_collect(arena);
mps_arena_release(arena);
#endif
comment("ramp end, %ld objects", rsize);
inramp = 0;
}
} else {
if (ranint(ENTERRAMP) == 0) {
#ifdef RAMP_INTERFACE
mps_ap_alloc_pattern_begin(apamc, mps_alloc_pattern_ramp());
#endif
comment("ramp begin");
r = allocone(apamc, 3, MPS_RANK_EXACT);
inramp = 1;
rsize = 0;
}
}
}
mps_ap_destroy(apamc);
comment("Destroyed ap.");
mps_pool_destroy(poolamc);
comment("Destroyed pool.");
mps_fmt_destroy(format);
comment("Destroyed format.");
mps_root_destroy(root1);
mps_root_destroy(root);
comment("Destroyed roots.");
mps_thread_dereg(thread);
comment("Deregistered thread.");
mps_arena_destroy(arena);
comment("Destroyed space.");
}
int main(void)
{
void *m;
stackpointer=&m; /* hack to get stack pointer */
easy_tramp(test);
report("result", "pass");
return 0;
}