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