summaryrefslogtreecommitdiff
path: root/test/unit/context/context_mm_black.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/context/context_mm_black.h')
-rw-r--r--test/unit/context/context_mm_black.h30
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';
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback