0
|
1 |
// Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
// e32test\heap\t_kheap.cpp
|
|
15 |
// Overview:
|
|
16 |
// Test clean-up after kernel heap allocation failures.
|
|
17 |
// API Information:
|
|
18 |
// RProcess, RThread, RServer, RMutex, RChunk, RSemaphore, RTimer.
|
|
19 |
// Details:
|
|
20 |
// - Tests allocation of kernel objects in low memory conditions and checks for
|
|
21 |
// leaks (OOM testing). The following objects are tested, with all
|
|
22 |
// combinations of attributes where applicable:
|
|
23 |
// - thread-relative timer.
|
|
24 |
// - local, global semaphore to the process, thread.
|
|
25 |
// - local, global mutex to the current process, thread.
|
|
26 |
// - server, handle to a file server session.
|
|
27 |
// - handle to a change notifier, a thread death notifier.
|
|
28 |
// - logical device driver, XIP and non-XIP (on hardware).
|
|
29 |
// - logical channel (hardware only excluding integrator).
|
|
30 |
// - chunks
|
|
31 |
// - chunks containg heaps (ie User::HeapChunk)
|
|
32 |
// - threads
|
|
33 |
// - Test that the kernel correctly zeros memory on allocation and reallocation
|
|
34 |
// Platforms/Drives/Compatibility:
|
|
35 |
// All.
|
|
36 |
// Assumptions/Requirement/Pre-requisites:
|
|
37 |
// Failures and causes:
|
|
38 |
// Base Port information:
|
|
39 |
//
|
|
40 |
//
|
|
41 |
|
|
42 |
//! @file
|
|
43 |
//! @SYMTestCaseID KBASE-T_KHEAP-0163
|
|
44 |
//! @SYMREQ N/A
|
|
45 |
//! @SYMTestPriority High
|
|
46 |
//! @SYMTestActions Test allocation of Kernel objects in low memory conditions.
|
|
47 |
//! @SYMTestExpectedResults Test runs until this message is emitted: RTEST: SUCCESS : T_KHEAP test completed O.K.
|
|
48 |
//! @SYMTestType UT
|
|
49 |
#define __E32TEST_EXTENSION__
|
|
50 |
#include <e32test.h>
|
|
51 |
#include <f32file.h>
|
|
52 |
#include <hal.h>
|
|
53 |
#include <e32svr.h>
|
|
54 |
#include <f32dbg.h>
|
|
55 |
#include "d_kheap.h"
|
|
56 |
|
189
|
57 |
RTest test(_L("T_KHEAP"));
|
0
|
58 |
RLoader LoaderSession;
|
|
59 |
|
|
60 |
#ifdef _DEBUG
|
|
61 |
_LIT(KTestLdd0FileName, "D_LDD.LDD");
|
|
62 |
_LIT(KTestLdd1FileName, "D_LDD_RAM.LDD");
|
|
63 |
_LIT(KTestLddName, "Test");
|
|
64 |
|
|
65 |
#include "../mmu/mmudetect.h"
|
|
66 |
#include "../mmu/d_memorytest.h"
|
|
67 |
|
|
68 |
TInt gPageSize;
|
|
69 |
TBool LargeChunkOK=EFalse;
|
|
70 |
const TInt KLargeChunk=0x80000000;
|
|
71 |
const TInt KOwnerThread=0x40000000;
|
|
72 |
const TInt KMaxKernelAllocations=1024;
|
|
73 |
_LIT(KName,"TestObj");
|
|
74 |
typedef TInt (*TTestFunction)(TInt);
|
|
75 |
|
|
76 |
TUint32 WaitABit;
|
|
77 |
|
|
78 |
RMemoryTestLdd TestLdd;
|
|
79 |
RKHeapDevice KHeapDevice;
|
|
80 |
|
|
81 |
void TraceOn()
|
|
82 |
{
|
|
83 |
User::SetDebugMask(0xefdfffff);
|
|
84 |
}
|
|
85 |
|
|
86 |
void TraceOff()
|
|
87 |
{
|
|
88 |
User::SetDebugMask(0x80000000);
|
|
89 |
}
|
|
90 |
|
|
91 |
TInt TestTimer(TInt)
|
|
92 |
{
|
|
93 |
RTimer t;
|
|
94 |
TInt r=t.CreateLocal();
|
|
95 |
if (r==KErrNone)
|
|
96 |
t.Close();
|
|
97 |
return r;
|
|
98 |
}
|
|
99 |
|
|
100 |
TInt TestLocalSem(TInt a)
|
|
101 |
{
|
|
102 |
TOwnerType ot=(TOwnerType)a;
|
|
103 |
RSemaphore s;
|
|
104 |
TInt r=s.CreateLocal(0, ot);
|
|
105 |
if (r==KErrNone)
|
|
106 |
s.Close();
|
|
107 |
return r;
|
|
108 |
}
|
|
109 |
|
|
110 |
TInt TestGlobalSem(TInt a)
|
|
111 |
{
|
|
112 |
TOwnerType ot=(TOwnerType)a;
|
|
113 |
RSemaphore s;
|
|
114 |
TInt r=s.CreateGlobal(KName, 0, ot);
|
|
115 |
if (r==KErrNone)
|
|
116 |
s.Close();
|
|
117 |
return r;
|
|
118 |
}
|
|
119 |
|
|
120 |
TInt TestLocalMutex(TInt a)
|
|
121 |
{
|
|
122 |
TOwnerType ot=(TOwnerType)a;
|
|
123 |
RMutex m;
|
|
124 |
TInt r=m.CreateLocal(ot);
|
|
125 |
if (r==KErrNone)
|
|
126 |
m.Close();
|
|
127 |
return r;
|
|
128 |
}
|
|
129 |
|
|
130 |
TInt TestGlobalMutex(TInt a)
|
|
131 |
{
|
|
132 |
TOwnerType ot=(TOwnerType)a;
|
|
133 |
RMutex m;
|
|
134 |
TInt r=m.CreateGlobal(KName, ot);
|
|
135 |
if (r==KErrNone)
|
|
136 |
m.Close();
|
|
137 |
return r;
|
|
138 |
}
|
|
139 |
|
|
140 |
TInt TestServer(TInt)
|
|
141 |
{
|
|
142 |
RServer2 s;
|
|
143 |
TInt r=s.CreateGlobal(KName);
|
|
144 |
if (r==KErrNone)
|
|
145 |
s.Close();
|
|
146 |
return r;
|
|
147 |
}
|
|
148 |
|
|
149 |
TInt TestSession(TInt)
|
|
150 |
{
|
|
151 |
RFs fs;
|
|
152 |
TInt r=fs.Connect();
|
|
153 |
if (r==KErrNone)
|
|
154 |
{
|
|
155 |
r=fs.ShareAuto();
|
|
156 |
fs.Close();
|
|
157 |
}
|
|
158 |
User::After(WaitABit); // allow asynchronous cleanup to happen
|
|
159 |
return r;
|
|
160 |
}
|
|
161 |
|
|
162 |
TInt TestChangeNotifier(TInt)
|
|
163 |
{
|
|
164 |
RChangeNotifier n;
|
|
165 |
TInt r=n.Create();
|
|
166 |
if (r==KErrNone)
|
|
167 |
n.Close();
|
|
168 |
return r;
|
|
169 |
}
|
|
170 |
|
|
171 |
TInt TestUndertaker(TInt)
|
|
172 |
{
|
|
173 |
RUndertaker u;
|
|
174 |
TInt r=u.Create();
|
|
175 |
if (r==KErrNone)
|
|
176 |
u.Close();
|
|
177 |
return r;
|
|
178 |
}
|
|
179 |
|
|
180 |
TInt TestLogicalDevice(TInt aDevice)
|
|
181 |
{
|
|
182 |
const TDesC* fileName = NULL;
|
|
183 |
const TDesC* objName = &KTestLddName();
|
189
|
184 |
User::FreeLogicalDevice(*objName);
|
0
|
185 |
switch (aDevice)
|
|
186 |
{
|
|
187 |
case 0:
|
|
188 |
fileName = &KTestLdd0FileName();
|
|
189 |
break;
|
|
190 |
case 1:
|
|
191 |
fileName = &KTestLdd1FileName();
|
|
192 |
break;
|
|
193 |
default:
|
|
194 |
test(0);
|
|
195 |
}
|
|
196 |
TInt r = User::LoadLogicalDevice(*fileName);
|
|
197 |
test_KErrNone(LoaderSession.CancelLazyDllUnload()); // make sure transient loader session has been destroyed
|
|
198 |
if (r==KErrNone)
|
|
199 |
{
|
|
200 |
r = User::FreeLogicalDevice(*objName);
|
|
201 |
test_KErrNone(r);
|
|
202 |
}
|
|
203 |
return r;
|
|
204 |
}
|
|
205 |
|
|
206 |
TInt TestLogicalChannel(TInt)
|
|
207 |
{
|
|
208 |
RKHeapDevice d;
|
|
209 |
TInt r=d.Open();
|
|
210 |
if (r==KErrNone)
|
|
211 |
d.Close();
|
|
212 |
return r;
|
|
213 |
}
|
|
214 |
|
|
215 |
TInt TestChunk(TInt att)
|
|
216 |
{
|
|
217 |
TChunkCreateInfo createInfo;
|
|
218 |
TInt maxSize = (att & KLargeChunk)? (33*1048576) : gPageSize;
|
|
219 |
createInfo.SetOwner((att & KOwnerThread)? EOwnerThread : EOwnerProcess);
|
|
220 |
|
|
221 |
if (att & TChunkCreate::EGlobal)
|
|
222 |
createInfo.SetGlobal(KName());
|
|
223 |
|
|
224 |
switch (att & (TChunkCreate::ENormal | TChunkCreate::EDoubleEnded | TChunkCreate::EDisconnected))
|
|
225 |
{
|
|
226 |
case TChunkCreate::ENormal:
|
|
227 |
createInfo.SetNormal(gPageSize, maxSize);
|
|
228 |
break;
|
|
229 |
case TChunkCreate::EDoubleEnded:
|
|
230 |
createInfo.SetDoubleEnded(0, gPageSize, maxSize);
|
|
231 |
break;
|
|
232 |
case TChunkCreate::EDisconnected:
|
|
233 |
createInfo.SetDisconnected(0, gPageSize, maxSize);
|
|
234 |
break;
|
|
235 |
default:
|
|
236 |
test(EFalse);
|
|
237 |
break;
|
|
238 |
}
|
|
239 |
RChunk c;
|
|
240 |
TInt r=c.Create(createInfo);
|
|
241 |
if (r==KErrNone)
|
|
242 |
c.Close();
|
|
243 |
return r;
|
|
244 |
}
|
|
245 |
|
|
246 |
TInt TestHeap(TInt att)
|
|
247 |
{
|
|
248 |
if (att < 2)
|
|
249 |
{
|
|
250 |
RHeap* h = UserHeap::ChunkHeap(&KNullDesC(), 0x1000, 0x10000, 1, 4, att);
|
|
251 |
if (h)
|
|
252 |
h->Close();
|
|
253 |
return h ? KErrNone : KErrNoMemory;
|
|
254 |
}
|
|
255 |
RChunk c;
|
|
256 |
TInt r = c.CreateLocal(0, 0x100000);
|
|
257 |
if (r != KErrNone)
|
|
258 |
return r;
|
|
259 |
RHeap* h = UserHeap::ChunkHeap(c, 0x1000, 1, 0, 4, att&1, (att&2) ? UserHeap::EChunkHeapDuplicate : 0);
|
|
260 |
if ((att & 2) || !h)
|
|
261 |
c.Close();
|
|
262 |
if (h)
|
|
263 |
h->Close();
|
|
264 |
return h ? KErrNone : KErrNoMemory;
|
|
265 |
}
|
|
266 |
|
|
267 |
TInt TestThreadFunction(TAny* a)
|
|
268 |
{
|
|
269 |
TInt x=(TInt)a;
|
|
270 |
return (x+1)*(x+1);
|
|
271 |
}
|
|
272 |
|
|
273 |
TInt TestThread(TInt att)
|
|
274 |
//
|
|
275 |
// bit 0 -> EOwnerThread
|
|
276 |
// bit 1 -> use name
|
|
277 |
// bit 2 -> let it run
|
|
278 |
// bit 3 -> use own heap
|
|
279 |
//
|
|
280 |
{
|
|
281 |
TOwnerType ot=(att&1)?EOwnerThread:EOwnerProcess;
|
|
282 |
const TDesC* name=(att&2)?&KName():&KNullDesC();
|
|
283 |
TBool run=att&4;
|
|
284 |
TBool ownheap=att&8;
|
|
285 |
RThread t;
|
|
286 |
TInt r=0;
|
|
287 |
if (ownheap)
|
|
288 |
r=t.Create(*name, TestThreadFunction, 0x1000, 0x1000, 0x10000, (TAny*)att, ot);
|
|
289 |
else
|
|
290 |
r=t.Create(*name, TestThreadFunction, 0x1000, NULL, (TAny*)att, ot);
|
|
291 |
if (r!=KErrNone)
|
|
292 |
{
|
|
293 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0);
|
|
294 |
return r;
|
|
295 |
}
|
|
296 |
t.SetPriority(EPriorityMore);
|
|
297 |
TRequestStatus s;
|
|
298 |
t.Logon(s);
|
|
299 |
if (run)
|
|
300 |
t.Resume();
|
|
301 |
else
|
|
302 |
t.Kill((att+1)*(att+1));
|
|
303 |
User::WaitForRequest(s);
|
|
304 |
if (s==KErrNoMemory) // if logon failed due to OOM ...
|
|
305 |
User::After(WaitABit); // ... allow thread to terminate before checking exit type
|
|
306 |
test(t.ExitType()==EExitKill);
|
|
307 |
r=s.Int();
|
|
308 |
if (r>=0)
|
|
309 |
{
|
|
310 |
test(r==(att+1)*(att+1));
|
|
311 |
r=KErrNone;
|
|
312 |
}
|
|
313 |
t.Close();
|
|
314 |
User::After(WaitABit); // let supervisor run - can't use destruct notifier since it involves memory allocation
|
|
315 |
return r;
|
|
316 |
}
|
|
317 |
|
|
318 |
void DoTest(TTestFunction aFunc, TInt aParam)
|
|
319 |
{
|
|
320 |
test.Printf(_L("DoTest f=%08x p=%08x\n"),aFunc,aParam);
|
|
321 |
__KHEAP_MARK;
|
|
322 |
__KHEAP_FAILNEXT(1);
|
|
323 |
test_Equal(KErrNoMemory, (*aFunc)(aParam));
|
|
324 |
test_KErrNone(UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0));
|
|
325 |
__KHEAP_MARKEND;
|
|
326 |
__KHEAP_RESET;
|
|
327 |
__KHEAP_MARK;
|
|
328 |
test_KErrNone((*aFunc)(aParam));
|
|
329 |
test_KErrNone(UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0));
|
|
330 |
__KHEAP_MARKEND;
|
|
331 |
|
|
332 |
TInt i;
|
|
333 |
TInt r=KErrNoMemory;
|
|
334 |
for (i=0; i<KMaxKernelAllocations && r==KErrNoMemory; i++)
|
|
335 |
{
|
|
336 |
__KHEAP_MARK;
|
|
337 |
__KHEAP_FAILNEXT(i);
|
|
338 |
r=(*aFunc)(aParam);
|
|
339 |
test_KErrNone(UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, (TAny*)5000, 0));
|
|
340 |
__KHEAP_MARKEND;
|
|
341 |
__KHEAP_RESET;
|
|
342 |
}
|
|
343 |
test.Printf(_L("Took %d tries\n"),i);
|
|
344 |
test_KErrNone(r);
|
|
345 |
}
|
|
346 |
|
|
347 |
_LIT(KLddName, "ECOMM");
|
|
348 |
#ifdef __EPOC32__
|
|
349 |
_LIT(KPddName, "EUART");
|
|
350 |
#else
|
|
351 |
_LIT(KPddName, "ECDRV");
|
|
352 |
#endif
|
|
353 |
TInt LoadDeviceDrivers()
|
|
354 |
//
|
|
355 |
// Load ECOMM.LDD and all PDDs with name EUART?.PDD
|
|
356 |
//
|
|
357 |
{
|
|
358 |
TInt c=0;
|
|
359 |
TInt r;
|
|
360 |
TInt i;
|
|
361 |
TFileName n=KPddName();
|
|
362 |
TInt p=n.Length();
|
|
363 |
for (i=-1; i<10; ++i)
|
|
364 |
{
|
|
365 |
if (i==0)
|
|
366 |
n.Append('0');
|
|
367 |
else if (i>0)
|
|
368 |
n[p]=TText('0'+i);
|
|
369 |
r=User::LoadPhysicalDevice(n);
|
|
370 |
if (r==KErrNone || r==KErrAlreadyExists)
|
|
371 |
{
|
|
372 |
c++;
|
|
373 |
test.Printf(_L("Loaded PDD %S\n"),&n);
|
|
374 |
}
|
|
375 |
}
|
|
376 |
r=User::LoadLogicalDevice(KLddName);
|
|
377 |
if (r==KErrNone || r==KErrAlreadyExists)
|
|
378 |
{
|
|
379 |
c+=255;
|
|
380 |
test.Printf(_L("Loaded LDD %S\n"),&KLddName());
|
|
381 |
}
|
|
382 |
return c;
|
|
383 |
}
|
|
384 |
|
|
385 |
void TestKernAllocZerosMemory()
|
|
386 |
{
|
|
387 |
test.Next(_L("Kern::Alloc memory initialisation"));
|
|
388 |
test_KErrNone(TestLdd.Open());
|
|
389 |
__KHEAP_MARK;
|
|
390 |
TInt r=TestLdd.TestAllocZerosMemory();
|
|
391 |
__KHEAP_MARKEND;
|
|
392 |
if (r)
|
|
393 |
test.Printf(_L("TestAllocZerosMemory returned %08x\n"), r);
|
|
394 |
test_KErrNone(r);
|
|
395 |
__KHEAP_MARK;
|
|
396 |
r=TestLdd.TestReAllocZerosMemory();
|
|
397 |
__KHEAP_MARKEND;
|
|
398 |
if (r)
|
|
399 |
test.Printf(_L("TestReAllocZerosMemory returned %08x\n"), r);
|
|
400 |
test_KErrNone(r);
|
|
401 |
}
|
|
402 |
|
|
403 |
TInt TestCreateSharedChunk(TInt)
|
|
404 |
{
|
|
405 |
TInt r = KHeapDevice.CreateSharedChunk();
|
|
406 |
User::After(WaitABit); // let supervisor run - can't use destruct notifier since it involves memory allocation
|
|
407 |
return r;
|
|
408 |
}
|
|
409 |
#ifdef __EPOC32__
|
|
410 |
TInt TestCreateHwChunk(TInt a)
|
|
411 |
{
|
|
412 |
TInt r = KHeapDevice.CreateHwChunk();
|
|
413 |
User::After(WaitABit); // let supervisor run - can't use destruct notifier since it involves memory allocation
|
|
414 |
return r;
|
|
415 |
}
|
|
416 |
#endif
|
|
417 |
|
|
418 |
GLDEF_C TInt E32Main()
|
|
419 |
//
|
|
420 |
// Test kernel alloc heaven with all out of memory possibilities
|
|
421 |
//
|
|
422 |
{
|
|
423 |
|
|
424 |
/* Objects
|
|
425 |
* Thread tested here
|
|
426 |
* Process tested by loader tests
|
|
427 |
* Chunk tested here
|
|
428 |
* Library tested by loader tests
|
|
429 |
* Semaphore tested here
|
|
430 |
* Mutex tested here
|
|
431 |
* Server tested here
|
|
432 |
* Session tested here
|
|
433 |
* LDev tested by loader tests (to do)
|
|
434 |
* PDev tested by loader tests (to do)
|
|
435 |
* LChan tested here
|
|
436 |
* ChangeNot tested here
|
|
437 |
* Undertaker tested here
|
|
438 |
*/
|
|
439 |
|
|
440 |
test.Title();
|
|
441 |
test.Start(_L("Testing kernel OOM handling"));
|
|
442 |
|
|
443 |
TInt factor = UserSvr::HalFunction(EHalGroupVariant, EVariantHalTimeoutExpansion, 0, 0);
|
|
444 |
if (factor<=0)
|
|
445 |
factor = 1;
|
|
446 |
if (factor>1024)
|
|
447 |
factor = 1024;
|
|
448 |
WaitABit = 200000 * (TUint32)factor;
|
|
449 |
|
|
450 |
#ifdef __EPOC32__ // no WINS serial drivers yet
|
|
451 |
test.Next(_L("Load comms drivers"));
|
|
452 |
test(LoadDeviceDrivers()>=256);
|
|
453 |
#endif
|
|
454 |
test_KErrNone(UserHal::PageSizeInBytes(gPageSize));
|
|
455 |
|
|
456 |
// Keep a session to the loader
|
|
457 |
TInt r;
|
|
458 |
r = LoaderSession.Connect();
|
|
459 |
test_KErrNone(r);
|
|
460 |
|
|
461 |
// Turn off lazy dll unloading
|
|
462 |
test_KErrNone(LoaderSession.CancelLazyDllUnload());
|
|
463 |
|
|
464 |
if (TestChunk(KLargeChunk) == KErrNone)
|
|
465 |
{
|
|
466 |
LargeChunkOK = ETrue;
|
|
467 |
}
|
|
468 |
test.Next(_L("Load/open d_kheap test driver"));
|
|
469 |
r = User::LoadLogicalDevice(KHeapTestDriverName);
|
|
470 |
test( r==KErrNone || r==KErrAlreadyExists);
|
|
471 |
if( KErrNone != (r=KHeapDevice.Open()) )
|
|
472 |
{
|
|
473 |
User::FreeLogicalDevice(KHeapTestDriverName);
|
|
474 |
test.Printf(_L("Could not open LDD"));
|
|
475 |
test(0);
|
|
476 |
}
|
|
477 |
|
|
478 |
test.Next(_L("Timer"));
|
|
479 |
DoTest(TestTimer, 0);
|
|
480 |
test.Next(_L("Local semaphore"));
|
|
481 |
DoTest(TestLocalSem, EOwnerProcess);
|
|
482 |
test.Next(_L("Global semaphore"));
|
|
483 |
DoTest(TestGlobalSem, EOwnerProcess);
|
|
484 |
test.Next(_L("Local semaphore"));
|
|
485 |
DoTest(TestLocalSem, EOwnerThread);
|
|
486 |
test.Next(_L("Global semaphore"));
|
|
487 |
DoTest(TestGlobalSem, EOwnerThread);
|
|
488 |
test.Next(_L("Local mutex"));
|
|
489 |
DoTest(TestLocalMutex, EOwnerProcess);
|
|
490 |
test.Next(_L("Global mutex"));
|
|
491 |
DoTest(TestGlobalMutex, EOwnerProcess);
|
|
492 |
test.Next(_L("Local mutex"));
|
|
493 |
DoTest(TestLocalMutex, EOwnerThread);
|
|
494 |
test.Next(_L("Global mutex"));
|
|
495 |
DoTest(TestGlobalMutex, EOwnerThread);
|
|
496 |
test.Next(_L("Server"));
|
|
497 |
DoTest(TestServer, 0);
|
|
498 |
test.Next(_L("Session"));
|
|
499 |
DoTest(TestSession, 0);
|
|
500 |
test.Next(_L("Change notifier"));
|
|
501 |
DoTest(TestChangeNotifier, 0);
|
|
502 |
test.Next(_L("Undertaker"));
|
|
503 |
DoTest(TestUndertaker, 0);
|
|
504 |
test.Next(_L("Logical Device (XIP)"));
|
|
505 |
DoTest(TestLogicalDevice, 0);
|
|
506 |
#ifdef __EPOC32__
|
|
507 |
test.Next(_L("Logical Device (Non-XIP)"));
|
|
508 |
//The first time a non-XIP LDD is loaded , Kernel permanently allocates some memory.
|
|
509 |
//The next line makes sure it happens before we start testing OOM condition.
|
|
510 |
TestLogicalDevice(1);
|
|
511 |
//Further non-XIP LDDs loadings must not leak the memory.
|
|
512 |
DoTest(TestLogicalDevice, 1);
|
|
513 |
|
|
514 |
// Temporary hack to avoid clash with debug output on Integrator
|
|
515 |
TInt muid;
|
|
516 |
r = HAL::Get(HAL::EMachineUid, muid);
|
|
517 |
test_KErrNone(r);
|
|
518 |
if (muid != HAL::EMachineUid_Integrator)
|
|
519 |
{
|
|
520 |
test.Next(_L("Logical Channel"));
|
|
521 |
r = User::LoadLogicalDevice(KHeapTestDriverName);
|
|
522 |
test(r==KErrNone || r==KErrAlreadyExists);
|
|
523 |
DoTest(TestLogicalChannel, 0);
|
|
524 |
}
|
|
525 |
#endif
|
|
526 |
TUint32 att;
|
|
527 |
TUint32 attlim=LargeChunkOK?0x100:0x80;
|
|
528 |
test.Next(_L("Chunk"));
|
|
529 |
for (att=0; att<attlim; ++att)
|
|
530 |
{
|
|
531 |
if ((att&0x0f)>2)
|
|
532 |
continue;
|
|
533 |
TInt arg=att&~0xc0;
|
|
534 |
if (att&0x40) arg|=KOwnerThread;
|
|
535 |
if (att&0x80) arg|=KLargeChunk;
|
|
536 |
DoTest(TestChunk, arg);
|
|
537 |
}
|
|
538 |
|
|
539 |
test.Next(_L("Heap"));
|
|
540 |
for (att=0; att<8; ++att)
|
|
541 |
{
|
|
542 |
if (att==2 || att==3)
|
|
543 |
continue;
|
|
544 |
DoTest(TestHeap, att);
|
|
545 |
}
|
|
546 |
|
|
547 |
test.Next(_L("Thread"));
|
|
548 |
for (att=0; att<16; ++att)
|
|
549 |
{
|
|
550 |
DoTest(TestThread, att);
|
|
551 |
}
|
|
552 |
|
|
553 |
TestKernAllocZerosMemory();
|
|
554 |
|
|
555 |
test.Next(_L("Shared Chunk"));
|
|
556 |
DoTest(TestCreateSharedChunk, 0);
|
|
557 |
#ifdef __EPOC32__
|
|
558 |
test.Next(_L("Hw Chunk"));
|
|
559 |
DoTest(TestCreateHwChunk, 0);
|
|
560 |
#endif
|
|
561 |
|
|
562 |
test.Next(_L("Close/unload d_kheap test driver"));
|
|
563 |
KHeapDevice.Close();
|
|
564 |
User::FreeLogicalDevice(KHeapTestDriverName);
|
|
565 |
LoaderSession.Close();
|
|
566 |
test.End();
|
|
567 |
return 0;
|
|
568 |
}
|
|
569 |
#else
|
|
570 |
GLDEF_C TInt E32Main()
|
|
571 |
//
|
|
572 |
// _KHEAP_SETFAIL etc. not available in release mode, so don't test
|
|
573 |
//
|
|
574 |
{
|
|
575 |
|
|
576 |
test.Title();
|
|
577 |
test.Start(_L("No tests in release mode"));
|
|
578 |
test.End();
|
|
579 |
return 0;
|
|
580 |
}
|
|
581 |
#endif
|
|
582 |
|
|
583 |
|