193 |
193 |
194 void TestNoFreeRAM(TLinAddr aPageAddr) |
194 void TestNoFreeRAM(TLinAddr aPageAddr) |
195 { |
195 { |
196 test.Start(_L("Test allocating a shadow page when all free RAM is in 'chunk caches'")); |
196 test.Start(_L("Test allocating a shadow page when all free RAM is in 'chunk caches'")); |
197 |
197 |
|
198 test.Next(_L("Load gobbler LDD")); |
|
199 TInt r = User::LoadLogicalDevice(KGobblerLddFileName); |
|
200 test_Value(r, r==KErrNone || r==KErrAlreadyExists); |
|
201 RGobbler gobbler; |
|
202 test_KErrNone(gobbler.Open()); |
|
203 TUint32 taken = gobbler.GobbleRAM(496*1024*1024); |
|
204 test.Printf(_L(" Gobbled: %dK\n"), taken/1024); |
|
205 test.Printf(_L(" Free RAM 0x%08X bytes\n"),FreeRam()); |
|
206 |
198 // Remove limit on max size of live list |
207 // Remove limit on max size of live list |
199 TUint originalMin = 0; |
208 TUint originalMin = 0; |
200 TUint originalMax = 0; |
209 TUint originalMax = 0; |
201 TUint currentSize = 0; |
210 TUint currentSize = 0; |
202 TInt r = DPTest::CacheSize(originalMin, originalMax, currentSize); |
211 r = DPTest::CacheSize(originalMin, originalMax, currentSize); |
203 test_Value(r, r == KErrNone || r == KErrNotSupported); |
212 test_Value(r, r == KErrNone || r == KErrNotSupported); |
204 TBool resizeCache = r == KErrNone; |
213 TBool resizeCache = r == KErrNone; |
205 if (resizeCache) |
214 if (resizeCache) |
206 test_KErrNone(DPTest::SetCacheSize(originalMin, KMaxTUint)); |
215 test_KErrNone(DPTest::SetCacheSize(originalMin, KMaxTUint)); |
207 |
|
208 test.Next(_L("Load gobbler LDD")); |
|
209 r = User::LoadLogicalDevice(KGobblerLddFileName); |
|
210 test_Value(r, r==KErrNone || r==KErrAlreadyExists); |
|
211 RGobbler gobbler, gobbler2; |
|
212 test_KErrNone(gobbler.Open()); |
|
213 TUint32 taken = gobbler.GobbleRAM(496*1024*1024); |
|
214 test.Printf(_L(" Gobbled: %dK\n"), taken/1024); |
|
215 test.Printf(_L(" Free RAM 0x%08X bytes\n"),FreeRam()); |
|
216 // Open 2nd globber here, while we still have some free pages. |
|
217 test_KErrNone(gobbler2.Open()); |
|
218 |
|
219 |
216 |
220 // put all of free RAM in a chunk... |
217 // put all of free RAM in a chunk... |
221 TChunkCreateInfo createInfo; |
218 TChunkCreateInfo createInfo; |
222 createInfo.SetCache(512*1024*1024); |
219 createInfo.SetCache(512*1024*1024); |
223 RChunk testChunk; |
220 RChunk testChunk; |
224 test_KErrNone(testChunk.Create(createInfo)); |
221 test_KErrNone(testChunk.Create(createInfo)); |
225 TInt commitEnd = 0; |
222 TInt commitEnd = 0; |
226 while(KErrNone==(r=testChunk.Commit(commitEnd,PageSize))) |
223 while(KErrNone==(r=testChunk.Commit(commitEnd,PageSize))) |
227 commitEnd += PageSize; |
224 commitEnd += PageSize; |
228 test_Equal(KErrNoMemory,r); |
225 test_Equal(KErrNoMemory,r); |
229 |
226 |
230 // Now we have some memory in a cache chunk ensure definitely no |
|
231 // other free pages. |
|
232 taken = gobbler2.GobbleRAM(0); |
|
233 test.Printf(_L(" Gobbled: %dK\n"), taken/1024); |
|
234 test_Equal(0, FreeRam()); |
|
235 |
|
236 |
|
237 // no memory to allocate shadow page... |
227 // no memory to allocate shadow page... |
238 test_Equal(KErrNoMemory,Shadow.Alloc(aPageAddr)); |
228 test_Equal(KErrNoMemory,Shadow.Alloc(aPageAddr)); |
239 // unlock all of RAM in chunk... |
229 // unlock all of RAM in chunk... |
240 test_KErrNone(testChunk.Unlock(0,commitEnd)); |
230 test_KErrNone(testChunk.Unlock(0,commitEnd)); |
241 // should have memory now... |
231 // should have memory now... |