diff options
author | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-02-03 00:49:38 +0000 |
---|---|---|
committer | Dejan Jovanović <dejan.jovanovic@gmail.com> | 2010-02-03 00:49:38 +0000 |
commit | 690bd6341c0ede1ff9edc30f8a8ce384fa936008 (patch) | |
tree | fbdc6f42bd5935d43c09b57f59b2f19d6db0b586 | |
parent | b905fa5289877aabf16b6014759da7661d096ff4 (diff) |
context_mm testing
-rw-r--r-- | test/unit/context/context_mm_black.h | 30 |
1 files changed, 23 insertions, 7 deletions
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'; |