From: Dejan Jovanović Date: Wed, 3 Feb 2010 00:49:38 +0000 (+0000) Subject: context_mm testing X-Git-Tag: cvc5-1.0.0~9307 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=690bd6341c0ede1ff9edc30f8a8ce384fa936008;p=cvc5.git context_mm testing --- diff --git a/test/unit/context/context_mm_black.h b/test/unit/context/context_mm_black.h index 534f490f6..78c5a53ae 100644 --- a/test/unit/context/context_mm_black.h +++ b/test/unit/context/context_mm_black.h @@ -36,24 +36,40 @@ public: void testPushPop() { // Push, then allocate, then pop + // We make sure that we don't allocate too much so that all the regions + // should be reclaimed + int chunkSizeBytes = 16384; + int maxFreeChunks = 100; + int piecesPerChunk = 13; + int len = chunkSizeBytes / piecesPerChunk; // Length of the individual block + int N = maxFreeChunks*piecesPerChunk; for (int p = 0; p < 5; ++ p) { d_cmm->push(); - for (int i = 1; i < 16384/3; ++i) { - int len = i*3; + for (int i = 0; i < N; ++i) { char* newMem = (char*)d_cmm->newData(len); - for(int k = 0; k < len - 1; k ++) - newMem[k] = 'a'; - newMem[len-1] = 0; + // We only setup the memory in the first run, the others should + // reclaim the same memory + if (p == 0) { + for(int k = 0; k < len - 1; k ++) + newMem[k] = 'a'; + newMem[len-1] = 0; + } + if (strlen(newMem) != len - 1) { + cout << strlen(newMem) << " : " << len - 1 << endl; + } TS_ASSERT(strlen(newMem) == len - 1); } d_cmm->pop(); } + int factor = 3; + N = 16384/factor; + // Push, then allocate, then pop all at once for (int p = 0; p < 5; ++ p) { d_cmm->push(); - for (int i = 1; i < 16384/3; ++i) { - int len = i*3; + for (int i = 1; i < N; ++i) { + int len = i*factor; char* newMem = (char*)d_cmm->newData(len); for(int k = 0; k < len - 1; k ++) newMem[k] = 'a';