1
Fork 0
mirror of git://git.sv.gnu.org/emacs.git synced 2026-01-18 17:01:01 -08:00
new test

Copied from Perforce
 Change: 19572
 ServerID: perforce.ravenbrook.com
This commit is contained in:
Richard Tucker 1998-06-02 16:30:32 +01:00
parent 66f09888f3
commit 17b682db45
8 changed files with 836 additions and 0 deletions

137
mps/qa/function/83.c Normal file
View file

@ -0,0 +1,137 @@
/* $HopeName$
TEST_HEADER
summary = test for bug with segment summaries
language = c
link = testlib.o awlfmt.o
END_HEADER
*/
/*
This bug, suggested by drj, turned out not to exist. The problem
would have occurred when a nailed, buffered segment was scanned,
and the summary would be wrongly set. But in fact all buffered
segments are scanned in their entirety anyway, so no problem
arises.
*/
#include "testlib.h"
#include "mpscamc.h"
#include "mpscawl.h"
#include "awlfmt.h"
void *stackpointer;
mps_addr_t temp_root;
static void test(void)
{
mps_space_t space;
mps_pool_t pool1, pool2;
mps_thr_t thread;
mps_root_t root;
mps_fmt_t format;
mps_ap_t ap1, ap2, ap;
mycell *a, *b, *c, *d;
int i;
alloccomments = 1;
fixcomments = 1;
deathcomments = 1;
formatcomments = 1;
fixcomments = 1;
cdie(mps_space_create(&space), "create space");
cdie(mps_thread_reg(&thread, space), "register thread");
cdie(
mps_root_create_table(&root, space, MPS_RANK_AMBIG, 0, &temp_root, 1),
"create temp root");
cdie(
mps_fmt_create_A(&format, space, &fmtA),
"create format");
cdie(
mps_pool_create(&pool1, space, mps_class_amc(), format),
"create pool");
cdie(
mps_pool_create(&pool2, space, mps_class_awl(), format),
"create pool");
cdie(
mps_ap_create(&ap1, pool1, MPS_RANK_EXACT),
"create ap");
cdie(
mps_ap_create(&ap2, pool2, MPS_RANK_EXACT),
"create ap");
ap=ap1;
mps_arena_park(space);
c = allocone(ap, 1, 1);
for (i=0; i<20; i++) {
if (i==10) {
comment("b...");
b = allocone(ap, 1, 1);
}
a = allocone(ap, 1, 1);
setref(a, 0, c);
if (i==10) {
comment("switch ap");
ap = ap2;
}
d = allocone(ap, 1000, 1);
c = a;
}
setref(b, 0, c);
temp_root = NULL;
mps_arena_collect(space);
mps_arena_release(space);
report("d", "%p", d);
mps_ap_destroy(ap1);
mps_ap_destroy(ap2);
comment("Destroyed aps.");
mps_pool_destroy(pool1);
mps_pool_destroy(pool2);
comment("Destroyed pools.");
mps_fmt_destroy(format);
comment("Destroyed format.");
mps_root_destroy(root);
comment("Destroyed root.");
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;
}

166
mps/qa/function/87.c Normal file
View file

@ -0,0 +1,166 @@
/* $HopeName$
TEST_HEADER
summary = EPVM make sure objects are left intact
language = c
link = testlib.o epvmfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscepvm.h"
#include "mpsavm.h"
#include "epvmfmt.h"
#define MAX_SAVE 1000
#define INIT_SAVE 12
void *stackpointer;
#define MAXOBJS 5000
mps_addr_t addrs[MAXOBJS];
size_t sizes[MAXOBJS] = {0};
mps_epvm_save_level_t levels[MAXOBJS];
mps_pool_t pool1;
mps_epvm_save_level_t lev1;
mps_ap_t ap1s;
static void myrestore(mps_epvm_save_level_t i) {
int j;
comment("restore to %i", i);
mps_epvm_restore(pool1, i);
for (j=0; j<MAXOBJS; j++) {
if (levels[j] > i) {
comment("free %i", j);
sizes[j] = (size_t) 0;
}
}
}
static void mycheck(psobj *addr, size_t size) {
int i;
unsigned long ob, om, pb, pm;
pb = (unsigned long) addr;
pm = pb+size;
for (i=0; i<MAXOBJS; i++) {
if (sizes[i] != 0) {
ob = (unsigned long) (addrs[i]);
om = ob + sizes[i];
asserts(om <= pb || ob >= pm,
"overlapping objects: %p, %p", addr, addrs[i]);
}
}
}
static void myalloc(int i) {
size_t s;
psobj *a;
s = 8 * (ranint(50)+1);
a = allocepvm(ap1s, s);
comment("alloc %i at %p level %i", i, a, lev1);
mycheck(a, s);
addrs[i] = a;
sizes[i] = s;
levels[i] = lev1;
}
static void mysave() {
if (lev1 < MAX_SAVE) {
lev1++;
comment("save to %i", lev1);
mps_epvm_save(pool1);
}
}
int myfindblank(int *ii) {
int j;
for (j=0; j<MAXOBJS; j++) {
if (sizes[j]==0) {
*ii = j;
return 1;
}
}
return 0;
}
static void test(void)
{
mps_arena_t arena;
mps_thr_t thread;
mps_root_t root;
mps_fmt_t format;
int i, j;
/* create an arena that can't grow beyond 64M */
cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*64)),
"create arena");
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_fmt_create_A(&format, arena, &fmtepvm), "create format");
cdie(mps_pool_create(&pool1, arena, mps_class_epvm(),
format, MAX_SAVE, INIT_SAVE), "create pool1");
cdie(mps_ap_create(&ap1s, pool1, 0), "create ap1s");
lev1 = INIT_SAVE;
for (j=0; j<100000; j++) {
if (myfindblank(&i)) {
myalloc(i);
} else {
lev1--;
while(lev1>0 && ranint(100)!=0) {
lev1--;
}
myrestore(lev1);
if (lev1 == 0) {
mysave();
}
}
if (ranint(100)<20) {
mysave();
}
}
mps_ap_destroy(ap1s);
mps_pool_destroy(pool1);
mps_fmt_destroy(format);
mps_root_destroy(root);
mps_thread_dereg(thread);
mps_arena_destroy(arena);
comment("Destroyed arena");
}
int main(void) {
void *m;
stackpointer=&m;
easy_tramp(test);
pass();
return 0;
}

84
mps/qa/function/88.c Normal file
View file

@ -0,0 +1,84 @@
/* $HopeName$
TEST_HEADER
summary = EPVM allocate and collect_world
language = c
link = testlib.o epvmfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscepvm.h"
#include "mpsavm.h"
#include "epvmfmt.h"
#define MAX_SAVE 32
#define INIT_SAVE 0
void *stackpointer;
psobj *a[100];
static void test(void)
{
mps_arena_t arena;
mps_thr_t thread;
mps_root_t root;
mps_fmt_t format;
mps_pool_t pool1;
mps_epvm_save_level_t lev1;
mps_ap_t ap1s;
int i, j;
alloccomments = 1;
/* create an arena that can't grow beyond 64M */
cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*64)),
"create arena");
cdie(mps_thread_reg(&thread, arena), "register thread");
cdie(mps_root_create_table(&root, arena, MPS_RANK_AMBIG, 0, &a[0], 100),
"create root");
cdie(mps_fmt_create_A(&format, arena, &fmtepvm), "create format");
cdie(mps_pool_create(&pool1, arena, mps_class_epvm(),
format, MAX_SAVE, INIT_SAVE), "create pool1");
cdie(mps_ap_create(&ap1s, pool1, 0), "create ap1s");
lev1 = INIT_SAVE;
for (i=0; i<10; i++) {
for (j=0; j<10000; j++) {
a[ranint(100)] = allocepvm(ap1s, (size_t) (8+8*ranint(16)));
}
mps_arena_collect(arena);
comment("collected %i", i);
}
mps_ap_destroy(ap1s);
mps_pool_destroy(pool1);
mps_fmt_destroy(format);
mps_root_destroy(root);
mps_thread_dereg(thread);
mps_arena_destroy(arena);
comment("Destroyed arena");
}
int main(void) {
void *m;
stackpointer=&m;
easy_tramp(test);
pass();
return 0;
}

78
mps/qa/function/89.c Normal file
View file

@ -0,0 +1,78 @@
/* $HopeName$
TEST_HEADER
summary = EPVM allocate and epvm_collect
language = c
link = testlib.o epvmfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscepvm.h"
#include "mpsavm.h"
#include "epvmfmt.h"
#define MAX_SAVE 1000
#define INIT_SAVE 12
void *stackpointer;
static void test(void)
{
mps_arena_t arena;
mps_thr_t thread;
mps_root_t root;
mps_fmt_t format;
mps_pool_t pool1;
mps_epvm_save_level_t lev1;
mps_ap_t ap1s;
int i, j;
psobj *a;
/* create an arena that can't grow beyond 64M */
cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*64)),
"create arena");
cdie(mps_thread_reg(&thread, arena), "register thread");
cdie(mps_fmt_create_A(&format, arena, &fmtepvm), "create format");
cdie(mps_pool_create(&pool1, arena, mps_class_epvm(),
format, MAX_SAVE, INIT_SAVE), "create pool1");
cdie(mps_ap_create(&ap1s, pool1, 0), "create ap1s");
lev1 = INIT_SAVE;
for (i=0; i<50; i++) {
for (j=0; j<3000; j++) {
a = allocepvm(ap1s, (size_t) (8+8*ranint(500)));
}
comment("collecting...");
mps_epvm_collect(pool1);
}
mps_ap_destroy(ap1s);
mps_pool_destroy(pool1);
mps_fmt_destroy(format);
mps_thread_dereg(thread);
mps_arena_destroy(arena);
comment("Destroyed arena");
}
int main(void) {
void *m;
stackpointer=&m;
easy_tramp(test);
pass();
return 0;
}

116
mps/qa/function/90.c Normal file
View file

@ -0,0 +1,116 @@
/* $HopeName$
TEST_HEADER
summary = various EPVM functional tests
language = c
link = testlib.o epvmfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscepvm.h"
#include "mpsavm.h"
#include "epvmfmt.h"
#define MAX_SAVE 32
#define INIT_SAVE 4
#define RT_SIZE 1000
void *stackpointer;
static void test(void)
{
mps_arena_t arena;
mps_thr_t thread;
mps_root_t root;
mps_fmt_t format;
mps_pool_t pool1;
mps_epvm_save_level_t lev1;
mps_ap_t ap1s, ap1p;
unsigned int i, j, k;
psobj *a[RT_SIZE], *b;
/* create an arena that can't grow beyond 64M */
cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*64)),
"create arena");
cdie(mps_thread_reg(&thread, arena), "register thread");
cdie(mps_root_create_table(&root, arena, MPS_RANK_AMBIG, 0, &a[0], RT_SIZE),
"create root");
cdie(mps_fmt_create_A(&format, arena, &fmtepvm), "create format");
cdie(mps_pool_create(&pool1, arena, mps_class_epvm(),
format, MAX_SAVE, INIT_SAVE), "create pool1");
cdie(mps_ap_create(&ap1s, pool1, 0), "create ap1s");
cdie(mps_ap_create(&ap1p, pool1, 1), "create ap1p");
asserts(sizeof(unsigned char) == 1, "surprise! -- characters too big!");
for (k=0; k<20; k++) {
comment("%i of 20", k);
comment("allocate string objects of various sizes");
for (i=0; i<256; i++) {
a[i] = allocepvm(ap1s, (size_t) (8+8*i));
for (j=0; j<(8+i*8); j++) {
*((unsigned char *) a[i]+j) = i;
}
}
comment("allocate psobjects pointing to strings");
for (i=0; i<256; i++) {
b = allocepvm(ap1p, (size_t) 8);
b->obj = a[i];
b->size = i+1;
a[i] = b;
}
comment("collect");
mps_epvm_collect(pool1);
comment("check objects are ok");
for (i=0; i<256; i++) {
b = a[i]->obj;
asserts(a[i]->size == i+1, "object %i wrong size", i);
for (j=0; j<(8+i*8); j++) {
asserts(*((unsigned char *) b+j) == i, "object %i corrupt at %i", i, j);
}
}
comment("finished");
}
mps_ap_destroy(ap1s);
mps_ap_destroy(ap1p);
mps_pool_destroy(pool1);
mps_fmt_destroy(format);
mps_root_destroy(root);
mps_thread_dereg(thread);
mps_arena_destroy(arena);
comment("Destroyed arena");
}
int main(void) {
void *m;
stackpointer=&m;
easy_tramp(test);
pass();
return 0;
}

97
mps/qa/function/93.c Normal file
View file

@ -0,0 +1,97 @@
/* $HopeName$
TEST_HEADER
summary = EPVM time allocations with checklevels
language = c
link = testlib.o epvmfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscepvm.h"
#include "mpsavm.h"
#include "epvmfmt.h"
#include <time.h>
#define MAX_SAVE 1
#define INIT_SAVE 0
void *stackpointer;
mps_word_t CheckLevel;
#define CheckNONE 0
#define CheckSHALLOW 1
#define CheckDEEP 2
static void timealloc(mps_pool_t pool, mps_ap_t ap, size_t size, int num, int step) {
int i, j;
clock_t t0, t1;
int secs;
psobj *a;
mps_epvm_save(pool);
t0 = clock();
for (j=0; j<step; j++) {
for (i=0; i<num; i++) {
a = allocepvm(ap, size);
}
t1 = clock();
secs = 100*(t1-t0)/CLOCKS_PER_SEC;
comment("%i, %i, %i", (j+1)*num, size*8, secs);
}
mps_epvm_restore(pool, 0);
};
static void test(void)
{
mps_arena_t arena;
mps_thr_t thread;
mps_fmt_t format;
mps_pool_t pool1;
mps_ap_t ap1s;
size_t size;
asserts(clock() != -1, "processor time not available");
/* create an arena that can't grow beyond 64M */
cdie(mps_arena_create(&arena, mps_arena_class_vm(), (size_t) (1024*1024*64)),
"create arena");
cdie(mps_thread_reg(&thread, arena), "register thread");
cdie(mps_fmt_create_A(&format, arena, &fmtepvm), "create format");
cdie(mps_pool_create(&pool1, arena, mps_class_epvm(),
format, MAX_SAVE, INIT_SAVE), "create pool1");
cdie(mps_ap_create(&ap1s, pool1, 0), "create ap1s");
for (size=1; size<32; size+=1) {
for (CheckLevel = CheckNONE; CheckLevel <= CheckDEEP; CheckLevel ++) {
timealloc(pool1, ap1s, size, 10000, 1);
}
}
mps_ap_destroy(ap1s);
mps_pool_destroy(pool1);
mps_fmt_destroy(format);
mps_thread_dereg(thread);
mps_arena_destroy(arena);
comment("Destroyed arena");
}
int main(void) {
void *m;
stackpointer=&m;
easy_tramp(test);
pass();
return 0;
}

34
mps/qa/function/98.c Normal file
View file

@ -0,0 +1,34 @@
/* $HopeName$
TEST_HEADER
summary = create arenas at once until an error results!
language = c
link = testlib.o
OUTPUT_SPEC
space > 10
END_HEADER
*/
#include "testlib.h"
#include "mpsavm.h"
static void test(void)
{
mps_space_t space;
int p;
p=0;
while (1)
{
die(mps_arena_create(&space, mps_arena_class_vm(), (size_t) (1024*1024*10)), "create");
p = p+1;
report("space", "%i", p);
}
}
int main(void)
{
easy_tramp(test);
return 0;
}

124
mps/qa/function/99.c Normal file
View file

@ -0,0 +1,124 @@
/* $HopeName$
TEST_HEADER
summary = AMC and AMCZ performance
language = c
link = testlib.o fastfmt.o
END_HEADER
*/
#include "testlib.h"
#include "mpscawl.h"
#include "mpscamc.h"
#include "fastfmt.h"
void *stackpointer;
static void test(void)
{
mps_space_t space;
mps_pool_t poolamc, poolamcz;
mps_thr_t thread;
mps_root_t root, root1;
mps_fmt_t format;
mps_ap_t apamc, apamcz;
mycell *a, *b, *c, *d, *e, *f, *g;
int i;
int j;
cdie(mps_space_create(&space), "create space");
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(&poolamc, space, mps_class_amc(), format),
"create pool");
cdie(
mps_pool_create(&poolamcz, space, mps_class_amcz(), format),
"create pool");
cdie(
mps_ap_create(&apamcz, poolamcz, MPS_RANK_EXACT),
"create ap");
cdie(
mps_ap_create(&apamc, poolamc, MPS_RANK_EXACT),
"create ap");
b = allocone(apamc, 1, MPS_RANK_EXACT);
for (j=1; j<100; j++)
{
comment("%i of 100.", j);
a = allocone(apamc, 5, MPS_RANK_EXACT);
b = a;
c = a;
d = a;
e = a;
f = a;
g = a;
for (i=1; i<5000; i++)
{
c = allocone(apamc, 20, MPS_RANK_EXACT);
d = allocone(apamcz, 20, MPS_RANK_EXACT);
if (ranint(8) == 0) e = c;
if (ranint(8) == 0) f = c;
if (ranint(8) == 0) g = c;
setref(b, 0, c);
setref(c, 1, d);
setref(c, 2, e);
setref(c, 3, f);
setref(c, 4, g);
b = c;
}
}
mps_ap_destroy(apamcz);
mps_ap_destroy(apamc);
comment("Destroyed aps.");
mps_pool_destroy(poolamc);
mps_pool_destroy(poolamcz);
comment("Destroyed pools.");
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;
}