author | hgs |
Wed, 22 Sep 2010 10:53:45 +0100 | |
changeset 271 | dc268b18d709 |
parent 148 | 31ea0f8e3c99 |
child 293 | 0659d0e1a03c |
permissions | -rw-r--r-- |
271 | 1 |
// Copyright (c) 1995-2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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\mmu\t_chunk.cpp |
|
15 |
// Overview: |
|
16 |
// Test RChunk class |
|
17 |
// API Information: |
|
18 |
// RChunk, RChangeNotifier, TFindChunk |
|
19 |
// Details: |
|
20 |
// - Test adjusting chunks: create a global chunk, adjust it, do some size |
|
21 |
// checks, verify Create() rounds up to chunk multiple, verify that adjust |
|
22 |
// request for size greater than MaxSize returns an error. |
|
23 |
// - Test creating chunks with small sizes (0 and 1), verify results are as expected. |
|
24 |
// - Create multiple local and global chunks, verify that Size,MaxSize,Name & FullName methods |
|
25 |
// are as expected. |
|
26 |
// Check Create method of global chunk if the name is already in use. Check the name can be |
|
27 |
// reused after the chunk is closed. |
|
28 |
// - Perform adjust tests on a chunk, verify results are as expected. |
|
29 |
// - Open and test global chunks with multiple references, verify results are as expected. |
|
30 |
// - Open and test local chunks, check TFindChunk::Next method, verify results are as expected. |
|
31 |
// - Check user thread is panicked if it creates or adjusts chunk with negative size or of an |
|
32 |
// invalid type or with an invalid name. |
|
33 |
// - Check the chunk is filled in with the appropriate clear value after creation, verify results |
|
34 |
// are as expected. |
|
35 |
// - Test sharing a chunk between threads, verify results are as expected. |
|
36 |
// - Create a thread to watch for notification of changes in free memory and |
|
37 |
// changes in out of memory status. Verify adjusting an RChunk generates |
|
38 |
// the expected notifications. |
|
39 |
// - Test finding a global chunk by name and verify results are as expected. |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
40 |
// - Check read-only global chunks cannot be written to by other processes. |
271 | 41 |
// - Test Top and Bottom API with DoubleEnded chunk |
0 | 42 |
// Platforms/Drives/Compatibility: |
43 |
// All. |
|
44 |
// Assumptions/Requirement/Pre-requisites: |
|
45 |
// Failures and causes: |
|
46 |
// Base Port information: |
|
47 |
// |
|
48 |
// |
|
49 |
||
50 |
#define __E32TEST_EXTENSION__ |
|
51 |
||
52 |
#include <e32test.h> |
|
53 |
#include <e32panic.h> |
|
54 |
#include <e32svr.h> |
|
148 | 55 |
#include <hal.h> |
0 | 56 |
#include "mmudetect.h" |
57 |
#include "d_gobble.h" |
|
58 |
#include "freeram.h" |
|
59 |
||
60 |
const TInt KHeapSize=0x200; |
|
61 |
||
62 |
//const TInt KNumberOfChunks=10; can't have that many |
|
63 |
const TInt KNumberOfChunks=3; |
|
64 |
||
65 |
const TInt KChunkNum=5; |
|
66 |
const TInt KNormalReturn=194; |
|
67 |
||
68 |
#ifdef __WINS__ |
|
69 |
const TInt KMinChunkSizeInBytesMinus1=0x0000ffff; |
|
70 |
const TUint KMinChunkSizeInBytesMask=0xffff0000; |
|
71 |
#elif defined (__X86__) |
|
72 |
const TInt KMinChunkSizeInBytesMinus1=0x003fffff; |
|
73 |
const TUint KMinChunkSizeInBytesMask=0xffc00000; |
|
74 |
#else |
|
75 |
const TInt KMinChunkSizeInBytesMinus1=0x000fffff; |
|
76 |
const TUint KMinChunkSizeInBytesMask=0xfff00000; |
|
77 |
#endif |
|
78 |
||
79 |
const TInt KMinPageSizeInBytesMinus1=0x00000fff; |
|
80 |
const TUint KMinPageSizeInBytesMask=0xfffff000; |
|
81 |
TInt gPageSize; |
|
82 |
||
83 |
LOCAL_D RTest test(_L("T_CHUNK")); |
|
84 |
LOCAL_D RTest t(_L("ShareThread")); |
|
85 |
LOCAL_D RChunk gChunk; |
|
86 |
||
87 |
LOCAL_D TPtr nullPtr(NULL,0); |
|
88 |
||
89 |
TUint32 MemModel; |
|
90 |
||
91 |
enum TDirective |
|
92 |
{ |
|
93 |
ENormal, |
|
94 |
ECreateNegative, |
|
95 |
EAdjustNegative, |
|
96 |
ECreateInvalidType, |
|
97 |
ECreateInvalidName, |
|
98 |
ECreateNoName, |
|
99 |
}; |
|
100 |
||
101 |
const TUint8 KDfltClearByte = 0x3; |
|
102 |
TBool CheckChunkCleared(RChunk& aRC, TInt aOffset=0, TUint8 aClearByte = KDfltClearByte) |
|
103 |
{ |
|
104 |
TUint8* base = aRC.Base()+aOffset; |
|
105 |
TInt size = aRC.Size(); |
|
106 |
test.Printf(_L("Testing chunk for 0x%x - size: %d!\n"), aClearByte, size); |
|
107 |
TBool ret=ETrue; |
|
108 |
for(TInt i = 0; i<size; i++) |
|
109 |
if(base[i] != aClearByte) |
|
110 |
ret=EFalse; |
|
111 |
memset((TAny*)base, 0x05, size); |
|
112 |
return ret; |
|
113 |
} |
|
114 |
||
115 |
TInt roundToPageSize(TInt aSize) |
|
116 |
{ |
|
117 |
||
118 |
return(((aSize+KMinPageSizeInBytesMinus1)&KMinPageSizeInBytesMask)); |
|
119 |
} |
|
120 |
||
121 |
TInt roundToChunkSize(TInt aSize) |
|
122 |
{ |
|
123 |
if(MemModel==EMemModelTypeFlexible) |
|
124 |
return roundToPageSize(aSize); |
|
125 |
return(((aSize+KMinChunkSizeInBytesMinus1)&KMinChunkSizeInBytesMask)); |
|
126 |
} |
|
127 |
||
128 |
TInt ThreadEntry2(TAny* /*aParam*/) |
|
129 |
// |
|
130 |
// Thread to read from shared chunk |
|
131 |
// |
|
132 |
{ |
|
133 |
RChunk c; |
|
134 |
TInt r; |
|
135 |
r=c.OpenGlobal(_L("Marmalade"),ETrue); |
|
136 |
t(r==KErrNone); |
|
137 |
TUint8* base=c.Base(); |
|
138 |
for (TInt8 i=0;i<10;i++) |
|
139 |
t(*base++==i); // check the chunk has 0-9 |
|
140 |
c.Close(); |
|
141 |
return(KErrNone); |
|
142 |
} |
|
143 |
||
144 |
TInt ThreadEntry(TAny* aDirective) |
|
145 |
// |
|
146 |
// Thread to create a Panic in a variety of ways |
|
147 |
// |
|
148 |
{ |
|
149 |
||
150 |
switch((TUint)aDirective) |
|
151 |
{ |
|
152 |
case ENormal: |
|
153 |
{ |
|
154 |
return KNormalReturn; |
|
155 |
} |
|
156 |
case ECreateNegative: |
|
157 |
{ |
|
158 |
gChunk.CreateLocal(0x10,-0x10); |
|
159 |
test(EFalse); |
|
160 |
} |
|
161 |
case EAdjustNegative: |
|
162 |
{ |
|
163 |
gChunk.Adjust(-0x10); |
|
164 |
test(EFalse); |
|
165 |
} |
|
166 |
case ECreateInvalidType : |
|
167 |
{ |
|
168 |
TChunkCreateInfo createInfo; |
|
169 |
createInfo.SetCode(gPageSize, gPageSize); |
|
170 |
_LIT(KChunkName, "Chunky"); |
|
171 |
createInfo.SetGlobal(KChunkName); |
|
172 |
RChunk chunk; |
|
173 |
chunk.Create(createInfo); |
|
174 |
test(EFalse); |
|
175 |
} |
|
176 |
default: |
|
177 |
test(EFalse); |
|
178 |
} |
|
179 |
return(KErrNone); |
|
180 |
} |
|
181 |
||
182 |
// |
|
183 |
// Test the clear flags for the specified chunk. |
|
184 |
// Assumes chunk has one commited region from base to aBytes. |
|
185 |
// |
|
186 |
void TestClearChunk(RChunk& aChunk, TUint aBytes, TUint8 aClearByte) |
|
187 |
{ |
|
188 |
test_Equal(ETrue, CheckChunkCleared(aChunk, 0, aClearByte)); |
|
189 |
test_KErrNone(aChunk.Adjust(0)); |
|
190 |
test_KErrNone(aChunk.Adjust(aBytes)); |
|
191 |
test_Equal(ETrue, CheckChunkCleared(aChunk, 0, aClearByte)); |
|
192 |
aChunk.Close(); |
|
193 |
} |
|
194 |
||
195 |
||
196 |
// |
|
197 |
// Create the specified thread and verify the exit reason. |
|
198 |
// |
|
199 |
void TestThreadExit(TExitType aExitType, TInt aExitReason, TThreadFunction aFunc, TAny* aThreadParam) |
|
200 |
{ |
|
201 |
RThread thread; |
|
202 |
test_KErrNone(thread.Create(_L("RChunkPanicThread"), aFunc, KDefaultStackSize, |
|
203 |
KHeapSize, KHeapSize, aThreadParam)); |
|
204 |
// Disable JIT debugging. |
|
205 |
TBool justInTime=User::JustInTime(); |
|
206 |
User::SetJustInTime(EFalse); |
|
207 |
||
208 |
TRequestStatus status; |
|
209 |
thread.Logon(status); |
|
210 |
thread.Resume(); |
|
211 |
User::WaitForRequest(status); |
|
212 |
test_Equal(aExitType, thread.ExitType()); |
|
213 |
test_Equal(aExitReason, status.Int()); |
|
214 |
test_Equal(aExitReason, thread.ExitReason()); |
|
215 |
if (aExitType == EExitPanic) |
|
216 |
test(thread.ExitCategory()==_L("USER")); |
|
217 |
CLOSE_AND_WAIT(thread); |
|
218 |
||
219 |
// Put JIT debugging back to previous status. |
|
220 |
User::SetJustInTime(justInTime); |
|
221 |
} |
|
222 |
||
223 |
||
224 |
// |
|
225 |
// Thread function to create a chunk with invalid attributes |
|
226 |
// |
|
227 |
TInt ChunkPanicThread(TAny* aCreateInfo) |
|
228 |
{ |
|
229 |
// This should panic. |
|
230 |
RChunk chunk; |
|
231 |
chunk.Create((*(TChunkCreateInfo*) aCreateInfo)); |
|
232 |
test(EFalse); |
|
233 |
||
234 |
return KErrGeneral; // Shouldn't reach here. |
|
235 |
} |
|
236 |
||
237 |
void testInitialise() |
|
238 |
{ |
|
239 |
test.Next(_L("Load gobbler LDD")); |
|
240 |
TInt r = User::LoadLogicalDevice(KGobblerLddFileName); |
|
241 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
242 |
||
243 |
// get system info... |
|
244 |
MemModel = UserSvr::HalFunction(EHalGroupKernel, EKernelHalMemModelInfo, NULL, NULL) & EMemModelTypeMask; |
|
245 |
||
246 |
test_KErrNone(UserHal::PageSizeInBytes(gPageSize)); |
|
247 |
} |
|
248 |
||
249 |
||
250 |
void test1() |
|
251 |
// |
|
252 |
// Test creating chunks with silly sizes |
|
253 |
// |
|
254 |
{ |
|
255 |
||
256 |
__KHEAP_MARK; |
|
257 |
RChunk chunk; |
|
258 |
TInt r; |
|
259 |
test.Start(_L("Create global chunks")); |
|
260 |
r=chunk.CreateGlobal(_L("Fopp"),1,1); |
|
261 |
test(r==KErrNone); |
|
262 |
chunk.Close(); |
|
263 |
r=chunk.CreateGlobal(_L("Fopp"),0,0); |
|
264 |
test(r==KErrArgument); |
|
265 |
||
266 |
__KHEAP_CHECK(0); |
|
267 |
||
268 |
test.Next(_L("Create local chunks")); |
|
269 |
r=chunk.CreateLocal(1,1); |
|
270 |
test(r==KErrNone); |
|
271 |
chunk.Close(); |
|
272 |
r=chunk.CreateLocal(0,0); |
|
273 |
test(r==KErrArgument); |
|
274 |
test.End(); |
|
275 |
__KHEAP_MARKEND; |
|
276 |
} |
|
277 |
||
278 |
||
279 |
void test2(TInt aSize) |
|
280 |
// |
|
281 |
// Test local/global chunk creation |
|
282 |
// |
|
283 |
{ |
|
284 |
||
285 |
RChunk lchunk[KNumberOfChunks]; |
|
286 |
RChunk gchunk[KNumberOfChunks]; |
|
287 |
RChunk chunk; |
|
288 |
||
289 |
__KHEAP_MARK; |
|
290 |
test.Start(_L("Create multiple local and global chunks")); |
|
291 |
||
292 |
TInt i; |
|
293 |
TBuf<0x40> name; |
|
294 |
TFullName fullname; |
|
295 |
for (i=0; i<KNumberOfChunks; i++) |
|
296 |
{ |
|
297 |
TInt r; |
|
298 |
// create a local chunk |
|
299 |
r=lchunk[i].CreateLocal(aSize,aSize); |
|
300 |
test(r==KErrNone); |
|
301 |
r=lchunk[i].MaxSize(); |
|
302 |
test(r==roundToChunkSize(aSize)); |
|
303 |
test(lchunk[i].Size()==roundToPageSize(aSize)); // was 0 |
|
304 |
test(lchunk[i].Name().Left(6)==_L("Local-")); |
|
305 |
||
306 |
fullname=RProcess().Name(); |
|
307 |
fullname+=_L("::"); |
|
308 |
fullname+=lchunk[i].Name(); |
|
309 |
test(lchunk[i].FullName().CompareF(fullname)==0); |
|
310 |
||
311 |
// create a global chunk |
|
312 |
name.Format(_L("Chunk%d"),i); |
|
313 |
r=gchunk[i].CreateGlobal(name,aSize,aSize); |
|
314 |
test(r==KErrNone); |
|
315 |
test(gchunk[i].MaxSize()==roundToChunkSize(aSize)); |
|
316 |
test(gchunk[i].Size()==roundToPageSize(aSize)); // was 0 |
|
317 |
test(gchunk[i].Name()==name); |
|
318 |
} |
|
319 |
||
320 |
// make room for another chunk |
|
321 |
lchunk[KNumberOfChunks-1].Close(); |
|
322 |
gchunk[KNumberOfChunks-1].Close(); |
|
323 |
||
324 |
// Try to create a global chunk with a duplicate name |
|
325 |
test.Next(_L("Create a chunk with a duplicate name")); |
|
326 |
TInt r=chunk.CreateGlobal(_L("Chunk0"),aSize,aSize); |
|
327 |
test(r==KErrAlreadyExists); |
|
328 |
||
329 |
test.Next(_L("Close all chunks")); |
|
330 |
for (i=0; i<KNumberOfChunks-1; i++) |
|
331 |
{ |
|
332 |
lchunk[i].Close(); |
|
333 |
gchunk[i].Close(); |
|
334 |
} |
|
335 |
||
336 |
test.Next(_L("Reuse a name")); |
|
337 |
r=chunk.CreateGlobal(_L("Chunk1"),aSize,aSize); |
|
338 |
test(r==KErrNone); |
|
339 |
test(chunk.MaxSize()==roundToChunkSize(aSize)); |
|
340 |
test(chunk.Size()==roundToPageSize(aSize)); |
|
341 |
test(chunk.Name()==_L("Chunk1")); |
|
342 |
chunk.Close(); |
|
343 |
||
344 |
test.End(); |
|
345 |
__KHEAP_MARKEND; |
|
346 |
} |
|
347 |
||
348 |
void test3_2(RChunk& aChunk, TInt aSize) |
|
349 |
// |
|
350 |
// Perform Adjust tests on aChunk |
|
351 |
// |
|
352 |
{ |
|
353 |
||
354 |
TInt r; |
|
355 |
test.Start(_L("Adjust to full size")); |
|
356 |
r=aChunk.Adjust(aSize); |
|
357 |
test(r==KErrNone); |
|
358 |
test(aChunk.Size()==roundToPageSize(aSize)); |
|
359 |
test(aChunk.MaxSize()==roundToChunkSize(aSize)); |
|
360 |
||
361 |
test.Next(_L("Adjust a chunk to half size")); |
|
362 |
r=aChunk.Adjust(aSize/2); |
|
363 |
test(r==KErrNone); |
|
364 |
test(aChunk.Size()==roundToPageSize(aSize/2)); |
|
365 |
test(aChunk.MaxSize()==roundToChunkSize(aSize)); |
|
366 |
||
367 |
test.Next(_L("Adjust to same size")); |
|
368 |
r=aChunk.Adjust(aSize/2); |
|
369 |
test(r==KErrNone); |
|
370 |
test(aChunk.Size()==roundToPageSize(aSize/2)); |
|
371 |
test(aChunk.MaxSize()==roundToChunkSize(aSize)); |
|
372 |
||
373 |
test.Next(_L("Adjusting to size=0")); |
|
374 |
r=aChunk.Adjust(0); |
|
375 |
test(r==KErrNone); |
|
376 |
test(aChunk.Size()==0); |
|
377 |
test(aChunk.MaxSize()==roundToChunkSize(aSize)); |
|
378 |
||
379 |
test.Next(_L("Adjust back to half size")); |
|
380 |
r=aChunk.Adjust(aSize/2); |
|
381 |
test(r==KErrNone); |
|
382 |
test(aChunk.Size()==roundToPageSize(aSize/2)); |
|
383 |
test(aChunk.MaxSize()==roundToChunkSize(aSize)); |
|
384 |
||
385 |
test.End(); |
|
386 |
} |
|
387 |
||
388 |
||
389 |
void test3(TInt aSize) |
|
390 |
// |
|
391 |
// Test Adjust size of chunk |
|
392 |
// |
|
393 |
{ |
|
394 |
||
395 |
RChunk chunk; |
|
396 |
__KHEAP_MARK; |
|
397 |
TInt r; |
|
398 |
// Run Adjust tests with a local chunk |
|
399 |
test.Start(_L("Local Chunk.Adjust()")); |
|
400 |
r=chunk.CreateLocal(aSize,aSize); |
|
401 |
test3_2(chunk, aSize); |
|
402 |
chunk.Close(); |
|
403 |
// Run Adjust tests with a global chunk |
|
404 |
test.Next(_L("Global Chunk.Adjust()")); |
|
405 |
r=chunk.CreateGlobal(_L("Fopp"),aSize,aSize); |
|
406 |
test(KErrNone==r); |
|
407 |
test3_2(chunk,aSize); |
|
408 |
chunk.Close(); |
|
409 |
test.End(); |
|
410 |
__KHEAP_MARKEND; |
|
411 |
} |
|
412 |
||
413 |
void test4(TInt aSize) |
|
414 |
// |
|
415 |
// Test OpenGlobal |
|
416 |
// |
|
417 |
{ |
|
418 |
||
419 |
RChunk chunk[KChunkNum]; |
|
420 |
RChunk c1, c2, c3; |
|
421 |
TName name; |
|
422 |
||
423 |
__KHEAP_MARK; |
|
424 |
TInt i,r; |
|
425 |
for (i=0; i<KChunkNum; i++) |
|
426 |
{ |
|
427 |
name.Format(_L("Chunk%d"), i); |
|
428 |
r=chunk[i].CreateGlobal(name,aSize,aSize); |
|
429 |
} |
|
430 |
||
431 |
test.Start(_L("Open Global chunks")); |
|
432 |
r=c1.OpenGlobal(_L("Chunk1"),EFalse); // 2nd ref to this chunk |
|
433 |
test(r==KErrNone); |
|
434 |
r=c2.OpenGlobal(_L("Chunk3"),EFalse); // 2nd ref to this chunk |
|
435 |
test(r==KErrNone); |
|
436 |
r=c3.OpenGlobal(_L("Chunk4"),EFalse); // 2nd ref to this chunk |
|
437 |
test(r==KErrNone); |
|
438 |
c3.Close(); |
|
439 |
||
440 |
test.Next(_L("Attempt Open non-existant chunk")); |
|
441 |
r=c3.OpenGlobal(_L("Non Existant Chunk"),EFalse); |
|
442 |
test(r==KErrNotFound); |
|
443 |
||
444 |
for (i=0; i<KChunkNum; i++) |
|
445 |
{ |
|
446 |
test.Printf(_L("Closing chunk %d\n"),i); |
|
447 |
chunk[i].Close(); |
|
448 |
} |
|
449 |
||
450 |
test.Next(_L("Test chunks with multiple references are still valid")); |
|
451 |
r=c1.Adjust(aSize/2); |
|
452 |
test(r==KErrNone); |
|
453 |
test(c1.MaxSize()==roundToChunkSize(aSize)); |
|
454 |
test(c1.Size()==roundToPageSize(aSize/2)); |
|
455 |
test(c1.Name()==_L("Chunk1")); |
|
456 |
||
457 |
r=c2.Adjust(aSize/2); |
|
458 |
test(r==KErrNone); |
|
459 |
test(c2.MaxSize()==roundToChunkSize(aSize)); |
|
460 |
test(c2.Size()==roundToPageSize(aSize/2)); |
|
461 |
test(c2.Name()==_L("Chunk3")); |
|
462 |
||
463 |
// Open another reference to a chunk |
|
464 |
r=c3.OpenGlobal(_L("Chunk3"),EFalse); |
|
465 |
test(r==KErrNone); |
|
466 |
test(c3.Base()==c2.Base()); |
|
467 |
test(c3.Size()==c2.Size()); |
|
468 |
test(c2.Size()!=aSize); |
|
469 |
// Adjust with one reference |
|
470 |
r=c3.Adjust(aSize); |
|
471 |
test(r==KErrNone); |
|
472 |
// Test sizes from the other |
|
473 |
test(c2.Size()==roundToPageSize(aSize)); |
|
474 |
test(c2.MaxSize()==roundToChunkSize(aSize)); |
|
475 |
||
476 |
c1.Close(); |
|
477 |
c2.Close(); |
|
478 |
c3.Close(); |
|
479 |
||
480 |
test.Next(_L("And check the heap...")); |
|
481 |
test.End(); |
|
482 |
__KHEAP_MARKEND; |
|
483 |
} |
|
484 |
||
485 |
void test5(TInt aSize) |
|
486 |
// |
|
487 |
// Test Open |
|
488 |
// |
|
489 |
{ |
|
490 |
||
491 |
RChunk chunk[2*KNumberOfChunks]; |
|
492 |
RChunk c1; |
|
493 |
||
494 |
test.Start(_L("Creating Local and Global Chunks")); |
|
495 |
__KHEAP_MARK; |
|
496 |
TInt i,r; |
|
497 |
TBuf<0x40> b; |
|
498 |
||
499 |
// Create KNumberOfChunks Global chunks |
|
500 |
for (i=0; i<KNumberOfChunks; i++) |
|
501 |
{ |
|
502 |
b.Format(_L("Chunk%d"), i); |
|
503 |
r=chunk[i].CreateGlobal(b,aSize,aSize); |
|
504 |
test(chunk[i].Name()==b); |
|
505 |
test(r==KErrNone); |
|
506 |
||
507 |
b.Format(_L("This is chunk %d"), i); |
|
508 |
b.Append(TChar(0)); |
|
509 |
chunk[i].Adjust(aSize); |
|
510 |
Mem::Copy(chunk[i].Base(), b.Ptr(), b.Size()); |
|
511 |
test(chunk[i].MaxSize()==roundToChunkSize(aSize)); |
|
512 |
test(chunk[i].Size()==roundToPageSize(aSize)); |
|
513 |
} |
|
514 |
||
515 |
test.Next(_L("Find and Open the Chunks")); |
|
516 |
TFindChunk find; |
|
517 |
TFullName name; |
|
518 |
for (i=0; i<KNumberOfChunks; i++) |
|
519 |
{ |
|
520 |
test.Printf(_L("Opening chunk %d\n"),i); |
|
521 |
find.Find(chunk[i].FullName()); |
|
522 |
r = find.Next(name); |
|
523 |
test(r==KErrNone); |
|
524 |
c1.Open(find); |
|
525 |
b=TPtrC((TText*)c1.Base()); |
|
526 |
name.Format(_L("This is chunk %d"), i); |
|
527 |
test(b==name); |
|
528 |
c1.Close(); |
|
529 |
} |
|
530 |
||
531 |
test.Next(_L("Close chunks")); |
|
532 |
for (i=0; i<KNumberOfChunks; i++) |
|
533 |
chunk[i].Close(); |
|
534 |
||
535 |
test.End(); |
|
536 |
__KHEAP_MARKEND; |
|
537 |
} |
|
538 |
||
539 |
||
540 |
void test7(TInt aSize) |
|
541 |
// |
|
542 |
// Deliberately cause RChunk panics |
|
543 |
// |
|
544 |
{ |
|
545 |
__KHEAP_MARK; |
|
546 |
||
547 |
// ENormal |
|
548 |
test.Start(_L("Test panic thread")); |
|
549 |
TestThreadExit(EExitKill, KNormalReturn, ThreadEntry, (TAny*)ENormal); |
|
550 |
||
551 |
// ECreateNegative |
|
552 |
test.Next(_L("Create Chunk with a negative size")); |
|
553 |
TestThreadExit(EExitPanic, EChkCreateMaxSizeNegative, ThreadEntry, (TAny*) ECreateNegative); |
|
554 |
||
555 |
// EAdjustNegative |
|
556 |
test.Next(_L("Adjust a Chunk to Size = -0x10")); |
|
557 |
gChunk.CreateLocal(aSize,aSize); |
|
558 |
TestThreadExit(EExitPanic, EChkAdjustNewSizeNegative, ThreadEntry, (TAny*) EAdjustNegative); |
|
559 |
gChunk.Close(); |
|
560 |
||
561 |
// ECreateInvalidType |
|
562 |
test.Next(_L("Create chunk of invalid type")); |
|
563 |
TestThreadExit(EExitPanic, EChkCreateInvalidType, ThreadEntry, (TAny*) ECreateInvalidType); |
|
564 |
||
565 |
test.End(); |
|
566 |
||
567 |
__KHEAP_MARKEND; |
|
568 |
} |
|
569 |
||
570 |
||
571 |
void testClear(TInt aSize) |
|
572 |
{ |
|
573 |
__KHEAP_MARK; |
|
574 |
test.Start(_L("Test clearing memory (Platform Security)")); |
|
575 |
||
576 |
RChunk c1,c2,c3,c4,c5,c6,c7,c8,c9,c10; |
|
577 |
TInt r; |
|
578 |
||
579 |
TBuf<0x40> b; |
|
580 |
||
581 |
b.Copy(_L("Chunk")); |
|
582 |
||
583 |
r=c1.CreateGlobal(b,aSize,aSize); |
|
584 |
test(r==KErrNone); |
|
585 |
||
586 |
test((TBool)ETrue==CheckChunkCleared(c1)); |
|
587 |
c1.Close(); |
|
588 |
||
589 |
r=c2.CreateLocal(aSize,aSize,EOwnerProcess); |
|
590 |
test(r==KErrNone); |
|
591 |
||
592 |
test((TBool)ETrue==CheckChunkCleared(c2)); |
|
593 |
c2.Close(); |
|
594 |
||
595 |
r=c3.CreateLocalCode(aSize,aSize,EOwnerProcess); |
|
596 |
test(r==KErrNone); |
|
597 |
||
598 |
test((TBool)ETrue==CheckChunkCleared(c3)); |
|
599 |
c3.Close(); |
|
600 |
||
601 |
r=c4.CreateDoubleEndedLocal(0x1000,0x1000+aSize,0x100000); |
|
602 |
test(r==KErrNone); |
|
603 |
||
604 |
test((TBool)ETrue==CheckChunkCleared(c4,c4.Bottom())); |
|
605 |
c4.Close(); |
|
606 |
||
607 |
r=c5.CreateDoubleEndedGlobal(b,0x1000,0x1000+aSize,0x100000,EOwnerProcess); |
|
608 |
test(r==KErrNone); |
|
609 |
||
610 |
test((TBool)ETrue==CheckChunkCleared(c5,c5.Bottom())); |
|
611 |
c5.Close(); |
|
612 |
||
613 |
r=c6.CreateDisconnectedLocal(0x1000,0x1000+aSize,0x100000); |
|
614 |
test(r==KErrNone); |
|
615 |
||
616 |
test((TBool)ETrue==CheckChunkCleared(c6,0x1000)); |
|
617 |
c6.Close(); |
|
618 |
||
619 |
r=c7.CreateDisconnectedGlobal(b,0x1000,0x1000+aSize,0x100000,EOwnerProcess); |
|
620 |
test(r==KErrNone); |
|
621 |
||
622 |
test((TBool)ETrue==CheckChunkCleared(c7,0x1000)); |
|
623 |
c7.Close(); |
|
624 |
||
625 |
test.Next(_L("Test setting the clear byte of RChunk::Create()")); |
|
626 |
||
627 |
TChunkCreateInfo createInfo; |
|
628 |
createInfo.SetNormal(aSize, aSize); |
|
629 |
test_KErrNone(c10.Create(createInfo)); |
|
630 |
TestClearChunk(c10, aSize, KDfltClearByte); |
|
631 |
||
632 |
createInfo.SetClearByte(0x0); |
|
633 |
test_KErrNone(c8.Create(createInfo)); |
|
634 |
TestClearChunk(c8, aSize, 0x0); |
|
635 |
||
636 |
createInfo.SetClearByte(0xff); |
|
637 |
test_KErrNone(c9.Create(createInfo)); |
|
638 |
TestClearChunk(c9, aSize, 0xff); |
|
639 |
||
640 |
test.End(); |
|
641 |
__KHEAP_MARKEND; |
|
642 |
} |
|
643 |
||
644 |
void testShare() |
|
645 |
// |
|
646 |
// Test sharing a chunk between threads |
|
647 |
// |
|
648 |
{ |
|
649 |
test.Start(_L("Test chunk sharing between threads")); |
|
650 |
||
651 |
test.Next(_L("Create chunk Marmalade")); |
|
652 |
TInt r=0; |
|
653 |
RChunk chunk; |
|
654 |
TInt size=0x1000; |
|
655 |
TInt maxSize=0x5000; |
|
656 |
r=0; |
|
657 |
r=chunk.CreateGlobal(_L("Marmalade"),size,maxSize); |
|
658 |
test(r==KErrNone); |
|
659 |
test.Next(_L("Write 0-9 to it")); |
|
660 |
TUint8* base=chunk.Base(); |
|
661 |
for (TInt8 j=0;j<10;j++) |
|
662 |
*base++=j; // write 0 - 9 to the chunk |
|
663 |
||
664 |
RThread t; |
|
665 |
TRequestStatus stat; |
|
666 |
test.Next(_L("Create reader thread")); |
|
667 |
r=t.Create(_L("RChunkShareThread"), ThreadEntry2, KDefaultStackSize,KHeapSize,KHeapSize,NULL); |
|
668 |
test(r==KErrNone); |
|
669 |
t.Logon(stat); |
|
670 |
test.Next(_L("Resume reader thread")); |
|
671 |
t.Resume(); |
|
672 |
User::WaitForRequest(stat); |
|
673 |
CLOSE_AND_WAIT(t); |
|
674 |
chunk.Close(); |
|
675 |
||
676 |
test.End(); |
|
677 |
} |
|
678 |
||
679 |
void FindChunks() |
|
680 |
{ // taken from some code written by SteveG |
|
681 |
test.Start(_L("Finding chunks...\n")); |
|
682 |
||
683 |
TFullName name=_L("*"); |
|
684 |
TFindChunk find(name); |
|
685 |
TInt i=0; |
|
686 |
||
687 |
||
688 |
while (find.Next(name)==KErrNone) |
|
689 |
{ |
|
690 |
RChunk chunk; |
|
691 |
test.Printf(_L("Chunk name %S\n"),&name); |
|
692 |
TInt err=chunk.Open(find); |
|
693 |
if (err) |
|
694 |
test.Printf(_L("Error %d opening chunk"),err); |
|
695 |
else |
|
696 |
{ |
|
697 |
TBuf<16> access; |
|
698 |
if (chunk.IsWritable()) |
|
699 |
access=_L("ReadWrite"); |
|
700 |
else if (chunk.IsReadable()) |
|
701 |
access=_L("ReadOnly"); |
|
702 |
else |
|
703 |
access=_L("No Access"); |
|
704 |
test.Printf(_L("Chunk size %08x bytes, %S\n"),chunk.Size(),&access); |
|
705 |
chunk.Close(); |
|
706 |
i++; |
|
707 |
} |
|
708 |
User::After(1000000); |
|
709 |
} |
|
710 |
test.End(); |
|
711 |
} |
|
712 |
||
713 |
void testAdjustChunk() |
|
714 |
{ |
|
715 |
test.Start(_L("Test adjusting chunks")); |
|
716 |
||
717 |
RChunk hermione; |
|
718 |
||
719 |
test.Next(_L("Create global chunk")); |
|
720 |
TInt r=hermione.CreateGlobal(_L("Hermione"),0x1000,0x100000); |
|
721 |
test(r==KErrNone); |
|
722 |
TUint32* base=(TUint32*)hermione.Base(); |
|
723 |
TUint32* top=(TUint32*)(hermione.Base()+hermione.Size()); |
|
724 |
TUint32* i; |
|
725 |
||
726 |
test.Printf(_L("Base = %08x, Top = %08x\n"),base,top); |
|
727 |
test.Next(_L("Check I can write to all of it")); |
|
728 |
for (i=base;i<top;i++) |
|
729 |
*i=0xdeaddead; |
|
730 |
||
731 |
test.Next(_L("Adjust the chunk")); |
|
732 |
r=hermione.Adjust(0x1400); |
|
733 |
test(r==KErrNone); |
|
734 |
||
735 |
base=(TUint32*)hermione.Base(); |
|
736 |
top=(TUint32*)(hermione.Base()+hermione.Size()); |
|
737 |
test.Printf(_L("Base = %08x, Top = %08x\n"),base,top); |
|
738 |
test.Next(_L("Check I can write to all of the bigger chunk")); |
|
739 |
for (i=base;i<top;i++) |
|
740 |
*i=0xdeaddead; |
|
741 |
||
742 |
hermione.Close(); |
|
743 |
||
744 |
test.Next(_L("Do some size checks")); |
|
745 |
RChunk wibble; |
|
746 |
r=wibble.CreateGlobal(_L("Wibble"),0x1,gPageSize*8); |
|
747 |
test(r==KErrNone); |
|
748 |
test.Next(_L("Check create rounds up to page multiple")); |
|
749 |
test(wibble.Size()==(TInt)gPageSize); |
|
750 |
test.Next(_L("Check create rounds up to chunk multiple")); |
|
751 |
test(wibble.MaxSize()==roundToChunkSize(gPageSize*8)); |
|
752 |
||
753 |
test.Next(_L("Check adjust rounds up to page multiple")); |
|
754 |
r=wibble.Adjust((gPageSize*6)-12); |
|
755 |
test(r==KErrNone); |
|
756 |
test(wibble.Size()==gPageSize*6); |
|
757 |
||
758 |
test.Next(_L("Different number, same size")); |
|
759 |
r=wibble.Adjust((gPageSize*6)-18); |
|
760 |
test(r==KErrNone); |
|
761 |
test(wibble.Size()==gPageSize*6); |
|
762 |
||
763 |
test.Next(_L("Check adjust > MaxSize returns error")); |
|
764 |
r=wibble.Adjust(wibble.MaxSize()+gPageSize); |
|
765 |
test(r==KErrArgument); |
|
766 |
||
767 |
wibble.Close(); |
|
768 |
test.End(); |
|
769 |
} |
|
770 |
||
771 |
TInt NotifierCount=0; |
|
772 |
TInt OOMCount=0; |
|
773 |
RChangeNotifier Notifier; |
|
774 |
RThread NtfThrd; |
|
775 |
_LIT(KNotifierThreadName,"NotifierThread"); |
|
776 |
||
777 |
TInt NotifierThread(TAny*) |
|
778 |
{ |
|
779 |
TInt r=Notifier.Create(); |
|
780 |
while (r==KErrNone) |
|
781 |
{ |
|
782 |
TRequestStatus s; |
|
783 |
r=Notifier.Logon(s); |
|
784 |
if (r!=KErrNone) |
|
785 |
break; |
|
786 |
User::WaitForRequest(s); |
|
787 |
if (s.Int()&EChangesFreeMemory) |
|
788 |
++NotifierCount; |
|
789 |
if (s.Int()&EChangesOutOfMemory) |
|
790 |
++OOMCount; |
|
791 |
} |
|
792 |
Notifier.Close(); |
|
793 |
return r; |
|
794 |
} |
|
795 |
||
796 |
||
797 |
void WaitForNotifier() |
|
798 |
{ |
|
799 |
User::After(500000); // wait for notifier |
|
800 |
} |
|
801 |
||
802 |
||
803 |
void CheckNotifierCount(TInt aLevel, TInt aOom) |
|
804 |
{ |
|
805 |
WaitForNotifier(); |
|
806 |
if (NtfThrd.ExitType()!=EExitPending) |
|
807 |
{ |
|
808 |
TExitCategoryName exitCat=NtfThrd.ExitCategory(); |
|
809 |
test.Printf(_L("Thread exited: %d,%d,%S"),NtfThrd.ExitType(),NtfThrd.ExitReason(),&exitCat); |
|
810 |
test(0); |
|
811 |
} |
|
812 |
TInt c1=NotifierCount; |
|
813 |
TInt c2=OOMCount; |
|
814 |
if (c1!=aLevel || c2!=aOom) |
|
815 |
{ |
|
816 |
test.Printf(_L("Count %d,%d Expected %d,%d"),c1,c2,aLevel,aOom); |
|
817 |
test(0); |
|
818 |
} |
|
819 |
} |
|
820 |
||
821 |
void testNotifiers() |
|
822 |
{ |
|
823 |
RGobbler gobbler; |
|
824 |
TInt r = gobbler.Open(); |
|
148 | 825 |
test_KErrNone(r); |
0 | 826 |
TUint32 taken = gobbler.GobbleRAM(128*1024*1024); |
827 |
test.Printf(_L("Gobbled: %dK\n"), taken/1024); |
|
828 |
test.Printf(_L("Free RAM 0x%08X bytes\n"),FreeRam()); |
|
829 |
||
830 |
test.Next(_L("Create thread")); |
|
831 |
r=NtfThrd.Create(KNotifierThreadName,NotifierThread,KDefaultStackSize,NULL,NULL); |
|
148 | 832 |
test_KErrNone(r); |
0 | 833 |
NtfThrd.SetPriority(EPriorityMore); |
834 |
NtfThrd.Resume(); |
|
835 |
test.Next(_L("Check for initial notifier")); |
|
836 |
CheckNotifierCount(1,1); |
|
837 |
TInt free=FreeRam(); |
|
838 |
test.Printf(_L("Free RAM: %dK\n"),free/1024); |
|
148 | 839 |
test_Value(free, free >= 1048576); |
0 | 840 |
test.Next(_L("Set thresholds")); |
841 |
r=UserSvr::SetMemoryThresholds(65536,524288); // low=64K good=512K |
|
148 | 842 |
test_KErrNone(r); |
0 | 843 |
test.Next(_L("Create chunk")); |
844 |
// Chunk must not be paged otherwise it will not effect the amount |
|
845 |
// of free ram reported plus on h4 swap size is less than the total ram. |
|
148 | 846 |
TInt totalRam; |
847 |
test_KErrNone(HAL::Get(HAL::EMemoryRAM, totalRam)); |
|
0 | 848 |
TChunkCreateInfo createInfo; |
148 | 849 |
createInfo.SetNormal(0, totalRam); |
0 | 850 |
createInfo.SetPaging(TChunkCreateInfo::EUnpaged); |
851 |
RChunk c; |
|
852 |
test_KErrNone(c.Create(createInfo)); |
|
853 |
const TInt KBufferSpace = 768*1024; // 768K buffer |
|
854 |
CheckNotifierCount(1,1); |
|
855 |
test.Next(_L("Leave 768K")); |
|
856 |
r=c.Adjust(free-KBufferSpace); // leave 768K |
|
857 |
test(r==KErrNone); |
|
858 |
CheckNotifierCount(1,1); // shouldn't get notifier |
|
859 |
TInt free2=FreeRam(); |
|
860 |
test.Printf(_L("Free RAM: %dK\n"),free2/1024); |
|
861 |
test(free2<=KBufferSpace); |
|
862 |
TInt free3=free-(KBufferSpace-free2); // this accounts for space used by page tables |
|
863 |
test.Next(_L("Leave 32K")); |
|
864 |
r=c.Adjust(free3-32768); // leave 32K |
|
148 | 865 |
test_KErrNone(r); |
0 | 866 |
CheckNotifierCount(2,1); // should get notifier |
867 |
test.Next(_L("Leave 28K")); |
|
868 |
r=c.Adjust(free3-28672); // leave 28K |
|
148 | 869 |
test_KErrNone(r); |
0 | 870 |
CheckNotifierCount(2,1); // shouldn't get another notifier |
871 |
test.Next(_L("Ask for too much")); |
|
148 | 872 |
r=c.Adjust(totalRam); // try to get more than available |
873 |
test_Equal(KErrNoMemory, r); |
|
0 | 874 |
CheckNotifierCount(2,2); // should get another notifier |
875 |
test.Next(_L("Leave 128K")); |
|
876 |
r=c.Adjust(free3-131072); // leave 128K |
|
148 | 877 |
test_KErrNone(r);; |
0 | 878 |
CheckNotifierCount(2,2); // shouldn't get another notifier |
879 |
test.Next(_L("Leave 640K")); |
|
880 |
r=c.Adjust(free3-655360); // leave 640K |
|
148 | 881 |
test_KErrNone(r); |
0 | 882 |
CheckNotifierCount(3,2); // should get another notifier |
883 |
test.Next(_L("Leave 1M")); |
|
884 |
r=c.Adjust(free3-1048576); // leave 1M |
|
148 | 885 |
test_KErrNone(r); |
0 | 886 |
CheckNotifierCount(3,2); // shouldn't get another notifier |
887 |
test.Next(_L("Ask for too much")); |
|
148 | 888 |
r=c.Adjust(totalRam); // try to get more than available |
889 |
test_Equal(KErrNoMemory, r); |
|
0 | 890 |
|
891 |
TInt notifierCount = 3; |
|
892 |
if(MemModel==EMemModelTypeFlexible) |
|
893 |
{ |
|
894 |
// on flexible memory model, we get memory changed notifiers |
|
895 |
// on failed memory allocation; this hack lets the test code |
|
896 |
// pass this as acceptable behaviour... |
|
897 |
WaitForNotifier(); |
|
898 |
notifierCount = NotifierCount; // expect whatever we actually got |
|
899 |
} |
|
900 |
||
901 |
CheckNotifierCount(notifierCount,3); // should get another notifier |
|
902 |
test.Next(_L("Leave 1M")); |
|
903 |
r=c.Adjust(free3-1048576); // leave 1M |
|
148 | 904 |
test_KErrNone(r); |
0 | 905 |
CheckNotifierCount(notifierCount,3); // shouldn't get another notifier |
906 |
||
907 |
c.Close(); |
|
908 |
TRequestStatus s; |
|
909 |
NtfThrd.Logon(s); |
|
910 |
NtfThrd.Kill(0); |
|
911 |
User::WaitForRequest(s); |
|
912 |
CLOSE_AND_WAIT(NtfThrd); |
|
913 |
Notifier.Close(); |
|
914 |
gobbler.Close(); |
|
915 |
} |
|
916 |
||
917 |
||
918 |
// TestFullAddressSpace is used to stress the memory allocation mechanism(beyond the 1GB limit). |
|
919 |
// However, the memory model can introduce limitations in the total amount of memory a single |
|
920 |
// process is allowed to allocate. To make the test more generic before closing the reserved |
|
921 |
// chunks for this test we trigger the creation of a new process. This process executes |
|
922 |
// t_chunk again, passing argument "extended". The result is that more chunks will be created |
|
923 |
// through another call to TestFullAddressSpace, with the parameter extendedFlag set to true. |
|
924 |
// Eventually the total amount of allocated space will overcome the 1Gb limit in any case. |
|
925 |
||
926 |
void TestFullAddressSpace(TBool extendedFlag ) |
|
927 |
{ |
|
928 |
test.Start(_L("Fill process address space with chunks\n")); |
|
929 |
RChunk chunk[2][11]; |
|
930 |
TInt total = 0; |
|
931 |
TInt i; |
|
932 |
TInt j; |
|
933 |
TInt r; |
|
934 |
||
935 |
for(j=0; j<=1; j++) |
|
936 |
{ |
|
937 |
if(!j) |
|
938 |
test.Next(_L("Creating local chunks")); |
|
939 |
else |
|
940 |
test.Next(_L("Creating global chunks")); |
|
941 |
for(i=10; i>=0; --i) |
|
942 |
{ |
|
943 |
TInt size = 1<<(20+i); |
|
944 |
||
945 |
if(!j) |
|
946 |
r = chunk[j][i].CreateDisconnectedLocal(0,0,size); |
|
947 |
else |
|
948 |
r = chunk[j][i].CreateDisconnectedGlobal(KNullDesC,0,0,size); |
|
949 |
TBuf<128> text; |
|
950 |
text.AppendFormat(_L("Create %dMB chunk returns %d"),1<<i,r); |
|
951 |
test.Next(text); |
|
952 |
if(r!=KErrNoMemory) |
|
953 |
{ |
|
954 |
test(r==KErrNone); |
|
955 |
// commit memory to each 1MB region, |
|
956 |
// this excercises page table allocation |
|
957 |
volatile TUint8* base = (TUint8*)chunk[j][i].Base(); |
|
958 |
for(TInt o=0; o<size; o+=1<<20) |
|
959 |
{ |
|
960 |
r = chunk[j][i].Commit(o,1); |
|
961 |
test(r==KErrNone); |
|
962 |
// access the commited memory... |
|
963 |
base[o] = (TUint8)(o&0xff); |
|
964 |
test(base[o]==(TUint8)(o&0xff)); |
|
965 |
base[o] = (TUint8)~(o&0xff); |
|
966 |
test(base[o]==(TUint8)~(o&0xff)); |
|
967 |
} |
|
968 |
total += 1<<i; |
|
969 |
} |
|
970 |
} |
|
971 |
} |
|
972 |
||
973 |
if (extendedFlag == EFalse) |
|
974 |
{ |
|
975 |
||
976 |
test.Printf(_L("Total chunk size created was %d MB\n\n"),total); |
|
977 |
||
978 |
if(total<1024) |
|
979 |
{ |
|
980 |
_LIT(KOtherProcessName,"t_chunk"); |
|
981 |
_LIT(KProcessArgs,"extended"); |
|
982 |
||
983 |
RProcess process; |
|
984 |
r=process.Create(KOtherProcessName,KProcessArgs ); |
|
985 |
test.Printf(_L("Creating new process( t_chunk extended) returns %d\n"),r ); |
|
986 |
test( r == KErrNone); |
|
987 |
||
988 |
TRequestStatus status; |
|
989 |
process.Logon(status); |
|
990 |
process.Resume(); |
|
991 |
||
992 |
User::WaitForRequest(status); |
|
993 |
||
994 |
test(process.ExitType() == EExitKill); |
|
995 |
test(process.ExitReason() == 0); |
|
996 |
process.Close(); |
|
997 |
} |
|
998 |
||
999 |
} |
|
1000 |
else |
|
1001 |
test.Printf(_L("Total chunk size created by the new process was %d MB\n"),total); |
|
1002 |
||
1003 |
for(j=0; j<=1; j++) |
|
1004 |
for(i=10; i>=0; --i) |
|
1005 |
chunk[j][i].Close(); |
|
1006 |
test.End(); |
|
1007 |
} |
|
1008 |
||
1009 |
||
1010 |
#ifdef __WINS__ |
|
1011 |
void TestExecLocalCode() |
|
1012 |
{ |
|
1013 |
RChunk c; |
|
1014 |
TInt size = 10 * 1024; |
|
1015 |
TInt rc = c.CreateLocalCode(size, size, EOwnerProcess); |
|
1016 |
test_KErrNone(rc); |
|
1017 |
TUint8 *p = c.Base(); |
|
1018 |
TUint32 (*func)() = (TUint32 (*)())p; |
|
1019 |
test.Printf(_L("Create small function in the new code chunk\n")); |
|
1020 |
*p++ = 0xB8; // mov eax, 0x12345678 |
|
1021 |
*p++ = 0x78; |
|
1022 |
*p++ = 0x56; |
|
1023 |
*p++ = 0x34; |
|
1024 |
*p++ = 0x12; |
|
1025 |
*p = 0xC3; // ret |
|
1026 |
test.Printf(_L("Going to call the new function\n")); |
|
1027 |
TUint32 res = (*func)(); |
|
1028 |
test_Equal(0x12345678, res); |
|
1029 |
c.Close(); |
|
1030 |
} |
|
1031 |
#endif // __WINS__ |
|
1032 |
||
1033 |
||
1034 |
_LIT(KChunkName, "CloseChunk"); |
|
1035 |
||
1036 |
struct TRequestData |
|
1037 |
{ |
|
1038 |
RSemaphore requestSem; |
|
1039 |
RSemaphore completionSem; |
|
1040 |
RSemaphore nextItSem; |
|
1041 |
}; |
|
1042 |
||
1043 |
TInt CloseThread(TAny* data) |
|
1044 |
{ |
|
1045 |
TRequestData* reqData = (TRequestData*)data; |
|
1046 |
ASSERT(reqData); |
|
1047 |
||
1048 |
for(;;) |
|
1049 |
{ |
|
1050 |
// Wait for a request to open and close the chunk. |
|
1051 |
reqData->requestSem.Wait(); |
|
1052 |
||
1053 |
// Try to open the chunk (may have already been closed by another thread). |
|
1054 |
RChunk chunk; |
|
1055 |
TInt r = chunk.OpenGlobal(KChunkName, EFalse, EOwnerThread); |
|
1056 |
if (r != KErrNone) |
|
1057 |
{ |
|
1058 |
// The chunk was already closed... |
|
1059 |
r = (r == KErrNotFound) ? KErrNone : r; // Ensure no debug output for expected failures. |
|
1060 |
||
1061 |
if(r != KErrNone) |
|
1062 |
{ |
|
1063 |
test.Printf(_L("CloseThread RChunk::OpenGlobal Err: %d\n"), r); |
|
1064 |
test_KErrNone(r); |
|
1065 |
} |
|
1066 |
} |
|
1067 |
else |
|
1068 |
{ |
|
1069 |
// Close the chunk. |
|
1070 |
chunk.Close(); |
|
1071 |
} |
|
1072 |
||
1073 |
// Tell our parent we have completed this iteration and wait for the next. |
|
1074 |
reqData->completionSem.Signal(); |
|
1075 |
reqData->nextItSem.Wait(); |
|
1076 |
} |
|
1077 |
} |
|
1078 |
||
1079 |
void TestClosure() |
|
1080 |
{ |
|
1081 |
const TUint KCloseThreads = 50; |
|
1082 |
RThread thread[KCloseThreads]; |
|
1083 |
TRequestStatus dead[KCloseThreads]; |
|
1084 |
||
1085 |
// We need three semaphores or we risk signal stealing if one thread gets ahead of the |
|
1086 |
// others and starts a second iteration before the other threads have been signalled |
|
1087 |
// and have begun their first iteration. Such a situation results in deadlock so we |
|
1088 |
// force all threads to finish the iteration first using the nextItSem semaphore to |
|
1089 |
// ensure we can only move to the next iteration once every thread has completed the |
|
1090 |
// current iteration. |
|
1091 |
TRequestData reqData; |
|
1092 |
test_KErrNone(reqData.requestSem.CreateLocal(0)); |
|
1093 |
test_KErrNone(reqData.completionSem.CreateLocal(0)); |
|
1094 |
test_KErrNone(reqData.nextItSem.CreateLocal(0)); |
|
1095 |
||
1096 |
TUint i = 0; |
|
1097 |
||
1098 |
// Create thread pool. We do this rather than create 50 threads |
|
1099 |
// over and over again for 800 times - the kernel's garbage collection |
|
1100 |
// does not keep up and we run out of backing store. |
|
1101 |
for (; i < KCloseThreads; i++) |
|
1102 |
{ |
|
1103 |
test_KErrNone(thread[i].Create(KNullDesC, CloseThread, KDefaultStackSize, NULL, (TAny*)&reqData)); |
|
1104 |
thread[i].Logon(dead[i]); |
|
1105 |
thread[i].SetPriority(EPriorityMuchLess); |
|
1106 |
thread[i].Resume(); |
|
1107 |
} |
|
1108 |
||
1109 |
for (TUint delay = 200; delay < 1000; delay++) |
|
1110 |
{ |
|
1111 |
test.Printf(_L("Closure delay %dus\r"), delay); |
|
1112 |
||
1113 |
// Create a global chunk. |
|
1114 |
RChunk chunk; |
|
1115 |
test_KErrNone(chunk.CreateGlobal(KChunkName, gPageSize, gPageSize)); |
|
1116 |
||
1117 |
// Release the threads so they can try to close the handle. |
|
1118 |
reqData.requestSem.Signal(KCloseThreads); |
|
1119 |
||
1120 |
// Wait for the delay then close the handle ourselves. |
|
1121 |
User::AfterHighRes(delay); |
|
1122 |
chunk.Close(); |
|
1123 |
||
1124 |
// Wait for the threads to complete then release them for the next iteration. |
|
1125 |
for (i = 0; i < KCloseThreads; i++) |
|
1126 |
{ |
|
1127 |
reqData.completionSem.Wait(); |
|
1128 |
} |
|
1129 |
reqData.nextItSem.Signal(KCloseThreads); |
|
1130 |
||
1131 |
// Ensure garbage collection is complete to prevent the kernel's |
|
1132 |
// garbage collection from being overwhelmed and causing the |
|
1133 |
// backing store to be exhausted. |
|
1134 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
1135 |
} |
|
1136 |
||
1137 |
// Kill thread pool. |
|
1138 |
for (i = 0; i < KCloseThreads; i++) |
|
1139 |
{ |
|
1140 |
thread[i].Kill(KErrNone); |
|
1141 |
User::WaitForRequest(dead[i]); |
|
1142 |
test(KErrNone == thread[i].ExitReason()); |
|
1143 |
test_Equal(EExitKill, thread[i].ExitType()); |
|
1144 |
thread[i].Close(); |
|
1145 |
} |
|
1146 |
||
1147 |
reqData.requestSem.Close(); |
|
1148 |
reqData.completionSem.Close(); |
|
1149 |
reqData.nextItSem.Close(); |
|
1150 |
||
1151 |
// Ensure garbage collection is complete to prevent false positive |
|
1152 |
// kernel memory leaks. |
|
1153 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
1154 |
} |
|
1155 |
||
1156 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1157 |
/**Returns true if argument is found in the command line*/ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1158 |
TBool IsInCommandLine(const TDesC& aArg) |
0 | 1159 |
{ |
1160 |
TBuf<64> c; |
|
1161 |
User::CommandLine(c); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1162 |
if (c.FindF(aArg) >= 0) |
0 | 1163 |
return ETrue; |
1164 |
return EFalse; |
|
1165 |
} |
|
1166 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1167 |
_LIT(KTestChunkReadOnly, "TestReadOnlyChunk"); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1168 |
_LIT(KTestSemaphoreReadOnly, "TestReadOnlySemaphore"); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1169 |
_LIT(KTestParamRo, "restro"); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1170 |
_LIT(KTestParamRw, "restrw"); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1171 |
_LIT(KTestParamWait, "restwait"); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1172 |
_LIT(KTestParamWritableChunk, "restwritable"); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1173 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1174 |
enum TTestProcessParameters |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1175 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1176 |
ETestRw = 0x1, |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1177 |
ETestWait = 0x2, |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1178 |
ETestWritableChunk = 0x4, |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1179 |
}; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1180 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1181 |
void TestReadOnlyProcess(TUint aParams) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1182 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1183 |
TInt r; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1184 |
RChunk chunk; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1185 |
RSemaphore sem; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1186 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1187 |
test.Start(_L("Open global chunk")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1188 |
r = chunk.OpenGlobal(KTestChunkReadOnly, EFalse); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1189 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1190 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1191 |
test(chunk.IsReadable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1192 |
r = chunk.Adjust(1); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1193 |
if (aParams & ETestWritableChunk) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1194 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1195 |
test(chunk.IsWritable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1196 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1197 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1198 |
else |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1199 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1200 |
test(!chunk.IsWritable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1201 |
test_Equal(KErrAccessDenied, r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1202 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1203 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1204 |
if (aParams & ETestWait) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1205 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1206 |
RProcess::Rendezvous(KErrNone); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1207 |
test.Next(_L("Wait on semaphore")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1208 |
r = sem.OpenGlobal(KTestSemaphoreReadOnly); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1209 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1210 |
sem.Wait(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1211 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1212 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1213 |
test.Next(_L("Read")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1214 |
TUint8 read = *(volatile TUint8*) chunk.Base(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1215 |
(void) read; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1216 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1217 |
if (aParams & ETestRw) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1218 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1219 |
test.Next(_L("Write")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1220 |
TUint8* write = chunk.Base(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1221 |
*write = 0x3d; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1222 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1223 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1224 |
chunk.Close(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1225 |
if (aParams & ETestWait) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1226 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1227 |
sem.Close(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1228 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1229 |
test.End(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1230 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1231 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1232 |
void TestReadOnly() |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1233 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1234 |
TInt r; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1235 |
RChunk chunk; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1236 |
RProcess process1; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1237 |
RProcess process2; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1238 |
RSemaphore sem; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1239 |
TRequestStatus rs; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1240 |
TRequestStatus rv; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1241 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1242 |
// Assumption is made that any memory model from Flexible onwards that supports |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1243 |
// read-only memory also supports read-only chunks |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1244 |
if (MemModelType() < EMemModelTypeFlexible || !HaveWriteProt()) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1245 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1246 |
test.Printf(_L("Memory model is not expected to support Read-Only Chunks\n")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1247 |
return; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1248 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1249 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1250 |
TBool jit = User::JustInTime(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1251 |
User::SetJustInTime(EFalse); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1252 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1253 |
test.Start(_L("Create writable global chunk")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1254 |
TChunkCreateInfo info; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1255 |
info.SetNormal(0, 1234567); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1256 |
info.SetGlobal(KTestChunkReadOnly); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1257 |
r = chunk.Create(info); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1258 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1259 |
test(chunk.IsReadable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1260 |
test(chunk.IsWritable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1261 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1262 |
test.Next(_L("Adjust size")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1263 |
r = chunk.Adjust(1); // add one page |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1264 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1265 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1266 |
test.Next(_L("Attempt read/write 1")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1267 |
r = process1.Create(RProcess().FileName(), KTestParamWritableChunk); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1268 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1269 |
process1.Logon(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1270 |
process1.Resume(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1271 |
User::WaitForRequest(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1272 |
test_Equal(EExitKill, process1.ExitType()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1273 |
test_KErrNone(process1.ExitReason()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1274 |
CLOSE_AND_WAIT(process1); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1275 |
CLOSE_AND_WAIT(chunk); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1276 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1277 |
test.Next(_L("Create read-only global chunk")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1278 |
info.SetReadOnly(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1279 |
r = chunk.Create(info); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1280 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1281 |
test(chunk.IsReadable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1282 |
test(chunk.IsWritable()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1283 |
// To keep in sync with the 'process2' process |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1284 |
r = sem.CreateGlobal(KTestSemaphoreReadOnly, 0); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1285 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1286 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1287 |
test.Next(_L("Attempt read 1")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1288 |
r = process1.Create(RProcess().FileName(), KTestParamRo); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1289 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1290 |
process1.Logon(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1291 |
process1.Resume(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1292 |
User::WaitForRequest(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1293 |
test_Equal(EExitPanic, process1.ExitType()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1294 |
test_Equal(3, process1.ExitReason()); // KERN-EXEC 3 assumed |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1295 |
CLOSE_AND_WAIT(process1); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1296 |
// Create second process before commiting memory and make it wait |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1297 |
r = process2.Create(RProcess().FileName(), KTestParamWait); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1298 |
test_KErrNone(r) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1299 |
process2.Rendezvous(rv); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1300 |
process2.Resume(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1301 |
User::WaitForRequest(rv); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1302 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1303 |
test.Next(_L("Adjust size")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1304 |
r = chunk.Adjust(1); // add one page |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1305 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1306 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1307 |
test.Next(_L("Attempt read 2")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1308 |
r = process1.Create(RProcess().FileName(), KTestParamRo); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1309 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1310 |
process1.Logon(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1311 |
process1.Resume(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1312 |
User::WaitForRequest(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1313 |
test_Equal(EExitKill, process1.ExitType()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1314 |
test_KErrNone(process1.ExitReason()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1315 |
CLOSE_AND_WAIT(process1); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1316 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1317 |
test.Next(_L("Attempt read/write 1")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1318 |
r = process1.Create(RProcess().FileName(), KTestParamRw); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1319 |
test_KErrNone(r); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1320 |
process1.Logon(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1321 |
process1.Resume(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1322 |
User::WaitForRequest(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1323 |
test_Equal(EExitPanic, process1.ExitType()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1324 |
test_Equal(3, process1.ExitReason()); // KERN-EXEC 3 assumed |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1325 |
CLOSE_AND_WAIT(process1); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1326 |
// Controlling process is not affected |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1327 |
TUint8* write = chunk.Base(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1328 |
*write = 0x77; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1329 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1330 |
test.Next(_L("Attempt read/write 2")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1331 |
test_Equal(EExitPending, process2.ExitType()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1332 |
process2.Logon(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1333 |
sem.Signal(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1334 |
User::WaitForRequest(rs); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1335 |
test_Equal(EExitPanic, process2.ExitType()); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1336 |
test_Equal(3, process2.ExitReason()); // KERN-EXEC 3 assumed |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1337 |
CLOSE_AND_WAIT(process2); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1338 |
|
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1339 |
chunk.Close(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1340 |
sem.Close(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1341 |
test.End(); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1342 |
User::SetJustInTime(jit); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1343 |
} |
0 | 1344 |
|
271 | 1345 |
|
1346 |
void TestTopBottom() |
|
1347 |
// |
|
1348 |
// test chunk top and bottom exec calls and check size |
|
1349 |
// |
|
1350 |
{ |
|
1351 |
RChunk chunk; |
|
1352 |
TInt r; |
|
1353 |
TInt init_bottom = 0x1000; |
|
1354 |
TInt init_top = 0x5000; |
|
1355 |
TInt max=0x10000; |
|
1356 |
||
1357 |
TInt top; |
|
1358 |
TInt bottom; |
|
1359 |
||
1360 |
r=chunk.CreateDoubleEndedLocal(init_bottom,init_top,max); |
|
1361 |
test_KErrNone(r); |
|
1362 |
||
1363 |
top=chunk.Top(); |
|
1364 |
bottom=chunk.Bottom(); |
|
1365 |
test_Equal(top, init_top); |
|
1366 |
test_Equal(bottom, init_bottom); |
|
1367 |
||
1368 |
r=chunk.AdjustDoubleEnded(init_bottom+0x1000, init_top-0x1000); |
|
1369 |
test_KErrNone(r); |
|
1370 |
||
1371 |
top=chunk.Top(); |
|
1372 |
bottom=chunk.Bottom(); |
|
1373 |
test_Equal(top, init_top-0x1000); |
|
1374 |
test_Equal(bottom, init_bottom+0x1000); |
|
1375 |
||
1376 |
chunk.Close(); |
|
1377 |
} |
|
1378 |
||
1379 |
||
0 | 1380 |
TInt E32Main() |
1381 |
// |
|
1382 |
// Test RChunk class |
|
1383 |
// |
|
1384 |
{ |
|
1385 |
test.Title(); |
|
1386 |
if (!HaveVirtMem()) |
|
1387 |
{ |
|
1388 |
test.Printf(_L("This test requires an MMU\n")); |
|
1389 |
return KErrNone; |
|
1390 |
} |
|
1391 |
testInitialise(); |
|
1392 |
||
1393 |
// Turn off lazy dll unloading so the kernel heap checking isn't affected. |
|
1394 |
RLoader l; |
|
1395 |
test(l.Connect()==KErrNone); |
|
1396 |
test(l.CancelLazyDllUnload()==KErrNone); |
|
1397 |
l.Close(); |
|
1398 |
||
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1399 |
_LIT(KExtended,"extended"); |
0 | 1400 |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1401 |
if (IsInCommandLine(KExtended)) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1402 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1403 |
__KHEAP_MARK; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1404 |
test.Printf(_L("t_chunk extended was called. Ready to call TestFullAddressSpace(Etrue) \n")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1405 |
TestFullAddressSpace(ETrue); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1406 |
__KHEAP_MARKEND; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1407 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1408 |
else if (IsInCommandLine(KTestParamRo)) |
0 | 1409 |
{ |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1410 |
test_KErrNone(User::RenameProcess(KTestParamRo)); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1411 |
TestReadOnlyProcess(0); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1412 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1413 |
else if (IsInCommandLine(KTestParamRw)) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1414 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1415 |
test_KErrNone(User::RenameProcess(KTestParamRw)); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1416 |
TestReadOnlyProcess(ETestRw); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1417 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1418 |
else if (IsInCommandLine(KTestParamWait)) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1419 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1420 |
test_KErrNone(User::RenameProcess(KTestParamWait)); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1421 |
TestReadOnlyProcess(ETestRw | ETestWait); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1422 |
} |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1423 |
else if (IsInCommandLine(KTestParamWritableChunk)) |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1424 |
{ |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1425 |
test_KErrNone(User::RenameProcess(KTestParamWritableChunk)); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1426 |
TestReadOnlyProcess(ETestWritableChunk | ETestRw); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1427 |
} |
0 | 1428 |
else |
1429 |
{ |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1430 |
__KHEAP_MARK; |
0 | 1431 |
test.Start(_L("Testing..")); |
1432 |
testAdjustChunk(); |
|
1433 |
test.Next(_L("Test1")); |
|
1434 |
test1(); |
|
1435 |
test.Next(_L("Test2")); |
|
1436 |
test2(0x80); |
|
1437 |
test.Next(_L("Test3")); |
|
1438 |
test3(0x7000); |
|
1439 |
test.Next(_L("Test4")); |
|
1440 |
test4(0x7000); |
|
1441 |
test.Next(_L("Test5")); |
|
1442 |
test5(0x80); |
|
1443 |
test.Next(_L("Test7")); |
|
1444 |
test7(0x80); |
|
1445 |
test.Next(_L("Test chunk data clearing attributes")); |
|
1446 |
testClear(0x500); |
|
1447 |
testClear(07000); |
|
1448 |
test.Next(_L("Test9")); |
|
1449 |
testShare(); |
|
1450 |
test.Next(_L("Test memory notifiers")); |
|
1451 |
testNotifiers(); |
|
1452 |
test.Next(_L("FindChunks")); |
|
1453 |
FindChunks(); |
|
1454 |
||
1455 |
test.Next(_L("Test full address space")); |
|
1456 |
TestFullAddressSpace(EFalse); |
|
1457 |
||
1458 |
#ifdef __WINS__ |
|
1459 |
test.Next(_L("Test execution of code in a local code chunk on emulator")); |
|
1460 |
TestExecLocalCode(); |
|
1461 |
#endif // __WINS__ |
|
1462 |
||
1463 |
test.Next(_L("Test for race conditions in chunk closure")); |
|
1464 |
TestClosure(); |
|
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1465 |
test.Next(_L("Read-only chunks")); |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1466 |
TestReadOnly(); |
271 | 1467 |
|
1468 |
test.Next(_L("Test chunk top and bottom")); |
|
1469 |
TestTopBottom(); |
|
1470 |
||
0 | 1471 |
test.End(); |
31
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1472 |
__KHEAP_MARKEND; |
56f325a607ea
Revision: 200951
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1473 |
} |
0 | 1474 |
|
1475 |
test.Close(); |
|
1476 |
return(KErrNone); |
|
1477 |
} |