Update contrib.
1 // Copyright (c) 2008-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\demandpaging\t_chunkcreate.cpp
19 #define __E32TEST_EXTENSION__
30 _LIT(KGlobalChunkName, "TestChunk");
45 EPagingUnspec, // Has to be first as can't clear back to unspecified.
52 void VerifyChunkPaged(RChunk& aChunk, TBool aPaged, TInt aR)
57 test.Printf(_L("aPaged = %d, aChunk.IsPaged() = %d\n"), aPaged, aChunk.IsPaged());
58 test_Equal(aPaged, aChunk.IsPaged());
60 // Uses same name for global chunks so needs to be fully closed before next call
61 CLOSE_AND_WAIT(aChunk);
65 void VerifyChunkPaged(TChunkCreateInfo& aCreateInfo)
68 for (TInt i = 0; i < EPagingNumberAttribs; i++)
73 paged = gProcessPaged; // Should default to process's paged status.
74 test.Printf(_L("Should default to process's paged status\n"));
77 aCreateInfo.SetPaging(TChunkCreateInfo::EPaged);
79 test.Printf(_L("Paging should be on\n"));
82 aCreateInfo.SetPaging(TChunkCreateInfo::EUnpaged);
84 test.Printf(_L("Paging should be off\n"));
88 TInt r = chunk.Create(aCreateInfo);
89 VerifyChunkPaged(chunk, paged, r);
95 TInt PanicChunkCreate(TAny* aCreateInfo)
97 TChunkCreateInfo createInfo((*(TChunkCreateInfo*) aCreateInfo));
98 gChunk.Create(createInfo);
99 return KErrGeneral; // Should never reach here
103 void TestPanicChunkCreate1(TInt aType, TInt aSize, TInt aMaxSize, TInt aPanicCode)
105 TChunkCreateInfo createInfo;
109 createInfo.SetNormal(aSize, aMaxSize);
113 createInfo.SetCode(aSize, aMaxSize);
117 createInfo.SetNormal(aSize, aMaxSize);
118 createInfo.SetGlobal(KGlobalChunkName);
125 test_KErrNone(thread.Create(_L("Panic CreateChunk"), PanicChunkCreate, KDefaultStackSize, KMinHeapSize,
126 KMinHeapSize, (TAny*) &createInfo));
128 test_KErrNone(TestThreadExit(thread, EExitPanic, aPanicCode));
131 void TestPanicChunkCreate2(TInt aType, TInt aBottom, TInt aTop, TInt aMaxSize, TInt aPanicCode)
133 TChunkCreateInfo createInfo;
137 createInfo.SetDoubleEnded(aBottom, aTop, aMaxSize);
140 case ECreateGlobalDE:
141 createInfo.SetDoubleEnded(aBottom, aTop, aMaxSize);
142 createInfo.SetGlobal(KGlobalChunkName);
146 createInfo.SetDisconnected(aBottom, aTop, aMaxSize);
149 case ECreateGlobalDC:
150 createInfo.SetDisconnected(aBottom, aTop, aMaxSize);
151 createInfo.SetGlobal(KGlobalChunkName);
157 test_KErrNone(thread.Create(_L("Panic CreateChunk"), PanicChunkCreate, KDefaultStackSize, KMinHeapSize,
158 KMinHeapSize, (TAny*) &createInfo));
160 test_KErrNone(TestThreadExit(thread, EExitPanic, aPanicCode));
166 //----------------------------------------------------------------------------------------------
167 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
169 //! @SYMPREQ PREQ1954
170 //! @SYMTestCaseDesc Verify the local chunk creation implementation.
172 //! 1. Create a local chunk and specify the following paging options.
173 //! Following this, check the paging status of the chunk by calling IsPaged
177 //! 2. Create a local chunk and specify aMaxSize to be negative
178 //! 3. Create a local chunk and specify aSize to be negative
179 //! 4. Create a local chunk and specify aMaxSize to be less than aSize.
181 //! @SYMTestExpectedResults
182 //! 1. The following results are expected:
183 //! a. The chunk should take on the paging status of the process
190 //! @SYMTestPriority High
191 //! @SYMTestStatus Implemented
192 //----------------------------------------------------------------------------------------------
193 void TestLocalChunk()
195 test.Start(_L("Test RChunk::CreateLocal - paging attributes"));
197 TChunkCreateInfo createInfo;
198 createInfo.SetNormal(gPageSize, gPageSize);
199 VerifyChunkPaged(createInfo);
200 // Test default create method
201 TInt r = gChunk.CreateLocal(gPageSize, gPageSize);
202 VerifyChunkPaged(gChunk, gProcessPaged, r);
205 test.Next(_L("Test RChunk::CreateLocal - invalid max size"));
206 TestPanicChunkCreate1(ECreateNormal, gPageSize, -1, EChkCreateMaxSizeNegative);
208 test.Next(_L("Test RChunk::CreateLocal - invalid size"));
209 TestPanicChunkCreate1(ECreateNormal, -1, gPageSize, EChkCreateSizeNotPositive);
212 test.Next(_L("Test RChunk::CreateLocal - aSize > aMaxSize"));
213 TestPanicChunkCreate1(ECreateNormal, gPageSize << 1, gPageSize, EChkCreateMaxLessThanMin);
220 //----------------------------------------------------------------------------------------------
221 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
223 //! @SYMPREQ PREQ1954
224 //! @SYMTestCaseDesc Verify the user code chunk creation implementation
226 //! 1. Create a user code chunk and specify the following paging options.
227 //! Following this check the paging status of the chunk by calling IsPaged().
231 //! 2. Create a user code chunk and specify aMaxSize to be negative
232 //! 3. Create a user code chunk and specify aSize to be negative
233 //! 4. Create a user code chunk and specify aMaxSize to be less than aSize.
235 //! @SYMTestExpectedResults
236 //! 1. The following results are expected:
237 //! a. The chunk should take on the paging status of the process
244 //! @SYMTestPriority High
245 //! @SYMTestStatus Implemented
246 //----------------------------------------------------------------------------------------------
249 test.Start(_L("Test RChunk::CreateLocalCode - paging attributes"));
251 TChunkCreateInfo createInfo;
252 createInfo.SetCode(gPageSize, gPageSize);
253 VerifyChunkPaged(createInfo);
254 // Test default create method
255 TInt r = gChunk.CreateLocal(gPageSize, gPageSize);
256 VerifyChunkPaged(gChunk, gProcessPaged, r);
259 test.Next(_L("Test RChunk::CreateLocalCode - invalid max size"));
260 TestPanicChunkCreate1(ECreateCode, gPageSize, -1, EChkCreateMaxSizeNegative);
262 test.Next(_L("Test RChunk::CreateLocalCode - invalid size"));
263 TestPanicChunkCreate1(ECreateCode, -1, gPageSize, EChkCreateSizeNotPositive);
266 test.Next(_L("Test RChunk::CreateLocalCode - aSize > aMaxSize"));
267 TestPanicChunkCreate1(ECreateCode, gPageSize << 1, gPageSize, EChkCreateMaxLessThanMin);
275 //----------------------------------------------------------------------------------------------
276 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
278 //! @SYMPREQ PREQ1954
279 //! @SYMTestCaseDesc Verify the global chunk creation implementation
281 //! 1. Create a global chunk and specify the following paging options.
282 //! Following this check the paging status of the chunk by calling IsPaged().
286 //! 1. Create a global chunk and specify aMaxSize to be negative
287 //! 2. Create a global chunk and specify aSize to be negative
288 //! 3. Create a global chunk and specify aMaxSize to be less than aSize.
290 //! @SYMTestExpectedResults
291 //! 1. The following results are expected:
292 //! a. The chunk should take on the paging status of the process
299 //! @SYMTestPriority High
300 //! @SYMTestStatus Implemented
301 //----------------------------------------------------------------------------------------------
302 void TestGlobalChunk()
304 test.Start(_L("Test RChunk::CreateGlobal - paging attributes"));
306 TChunkCreateInfo createInfo;
307 createInfo.SetNormal(gPageSize, gPageSize);
308 createInfo.SetGlobal(KGlobalChunkName);
309 VerifyChunkPaged(createInfo);
310 // Test default create method
311 TInt r = gChunk.CreateLocal(gPageSize, gPageSize);
312 VerifyChunkPaged(gChunk, gProcessPaged, r);
315 test.Next(_L("Test RChunk::CreateGlobal - invalid max size"));
316 TestPanicChunkCreate1(ECreateGlobal, gPageSize, -1, EChkCreateMaxSizeNegative);
318 test.Next(_L("Test RChunk::CreateGlobal - invalid size"));
319 TestPanicChunkCreate1(ECreateGlobal, -1, gPageSize, EChkCreateSizeNotPositive);
322 test.Next(_L("Test RChunk::CreateGlobal - aSize > aMaxSize"));
323 TestPanicChunkCreate1(ECreateGlobal, gPageSize << 1, gPageSize, EChkCreateMaxLessThanMin);
331 //----------------------------------------------------------------------------------------------
332 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
334 //! @SYMPREQ PREQ1954
335 //! @SYMTestCaseDesc Verify the local double ended chunk creation implementation
337 //! 1. Create a local, double ended, chunk and specify the following paging options.
338 //! Following this check the paging status of the chunk by calling IsPaged().
342 //! 2. Create a local, double ended, chunk and specify aMaxSize to be negative
343 //! 3. Create a local, double ended, chunk and specify aInitialBottom to be negative
344 //! 4. Create a local, double ended, chunk and specify aInitialTop to be negative.
345 //! 5. Create a local, double ended, chunk and specify aInitialBottom to be greater than aInitialTop.
346 //! 6. Create a local, double ended, chunk and specify aInitialTop to be greater than aMaxSize.
348 //! @SYMTestExpectedResults
349 //! 1. 1. The following results are expected:
350 //! a. The chunk should take on the paging status of the process
359 //! @SYMTestPriority High
360 //! @SYMTestStatus Implemented
361 //----------------------------------------------------------------------------------------------
362 void TestLocDEChunk()
364 test.Start(_L("Test RChunk::CreateDoubleEndedLocal - paging attributes"));
366 TChunkCreateInfo createInfo;
367 createInfo.SetDoubleEnded(0, gPageSize, gPageSize);
368 VerifyChunkPaged(createInfo);
369 // Test default create method
370 TInt r = gChunk.CreateDoubleEndedLocal(0, gPageSize, gPageSize);
371 VerifyChunkPaged(gChunk, gProcessPaged, r);
375 test.Next(_L("Test RChunk::CreateDoubleEndedLocal - invalid max size"));
376 TestPanicChunkCreate2(ECreateLocalDE, 0, gPageSize, -1, EChkCreateMaxSizeNegative);
378 test.Next(_L("Test RChunk::CreateDoubleEndedLocal - invalid bottom"));
379 TestPanicChunkCreate2(ECreateLocalDE, -1, gPageSize, gPageSize, EChkCreateBottomNegative);
381 test.Next(_L("Test RChunk::CreateDoubleEndedLocal - invalid top"));
382 TestPanicChunkCreate2(ECreateLocalDE, 0, -1, gPageSize, EChkCreateTopNegative);
384 test.Next(_L("Test RChunk::CreateDoubleEndedLocal - bottom > top"));
385 TestPanicChunkCreate2(ECreateLocalDE, gPageSize, 0, gPageSize, EChkCreateTopLessThanBottom);
387 test.Next(_L("Test RChunk::CreateDoubleEndedLocal - top > max size"));
388 TestPanicChunkCreate2(ECreateLocalDE, 0, gPageSize << 1, gPageSize, EChkCreateTopBiggerThanMax);
397 //----------------------------------------------------------------------------------------------
398 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
400 //! @SYMPREQ PREQ1954
401 //! @SYMTestCaseDesc Verify the global double ended chunk creation implementation
403 //! 1. Create a global, double ended, chunk and specify the following paging options.
404 //! Following this check the paging status of the chunk by calling IsPaged().
408 //! 2. Create a global, double ended, chunk and specify aMaxSize to be negative
409 //! 3. Create a global, double ended, chunk and specify aInitialBottom to be negative
410 //! 4. Create a global, double ended, chunk and specify aInitialTop to be negative.
411 //! 5. Create a global, double ended, chunk and specify aInitialBottom to be greater than aInitialTop.
412 //! 6. Create a global, double ended, chunk and specify aInitialBottom to be greater than aMaxSize.
413 //! 7. Create a global, double ended, chunk and specify aInitialTop to be greater than aMaxSize.
415 //! @SYMTestExpectedResults
416 //! 1. 1. The following results are expected:
417 //! a. The chunk should take on the paging status of the process
427 //! @SYMTestPriority High
428 //! @SYMTestStatus Implemented
429 //----------------------------------------------------------------------------------------------
430 void TestGlobDEChunk()
432 test.Start(_L("Test RChunk::CreateDoubleEndedGlobal - paging attributes"));
434 TChunkCreateInfo createInfo;
435 createInfo.SetDoubleEnded(0, gPageSize, gPageSize);
436 createInfo.SetGlobal(KGlobalChunkName);
437 VerifyChunkPaged(createInfo);
438 // Test default create method
439 TInt r = gChunk.CreateDoubleEndedLocal(0, gPageSize, gPageSize);
440 VerifyChunkPaged(gChunk, gProcessPaged, r);
444 test.Next(_L("Test RChunk::CreateDoubleEndedGlobal - invalid max size"));
445 TestPanicChunkCreate2(ECreateGlobalDE, 0, gPageSize, -1, EChkCreateMaxSizeNegative);
447 test.Next(_L("Test RChunk::CreateDoubleEndedGlobal - invalid bottom"));
448 TestPanicChunkCreate2(ECreateGlobalDE, -1, gPageSize, gPageSize, EChkCreateBottomNegative);
450 test.Next(_L("Test RChunk::CreateDoubleEndedGlobal - invalid top"));
451 TestPanicChunkCreate2(ECreateGlobalDE, 0, -1, gPageSize, EChkCreateTopNegative);
453 test.Next(_L("Test RChunk::CreateDoubleEndedGlobal - bottom > top"));
454 TestPanicChunkCreate2(ECreateGlobalDE, gPageSize, 0, gPageSize, EChkCreateTopLessThanBottom);
456 test.Next(_L("Test RChunk::CreateDoubleEndedGlobal - top > max size"));
457 TestPanicChunkCreate2(ECreateGlobalDE, 0, gPageSize << 1, gPageSize, EChkCreateTopBiggerThanMax);
465 //----------------------------------------------------------------------------------------------
466 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
468 //! @SYMPREQ PREQ1954
469 //! @SYMTestCaseDesc Verify the local disconnected chunk creation implementation
471 //! 1. Create a local, disconnected chunk and specify the following paging options.
472 //! Following this check the paging status of the chunk by calling IsPaged().
476 //! 2. Create a local, disconnected chunk and specify aMaxSize to be negative
477 //! 3. Create a local, disconnected chunk and specify aInitialBottom to be negative
478 //! 4. Create a local, disconnected chunk and specify aInitialTop to be negative.
479 //! 5. Create a local, disconnected chunk and specify aInitialBottom to be greater than aInitialTop.
480 //! 6. Create a local, disconnected chunk and specify aInitialBottom to be greater than aMaxSize.
481 //! 7. Create local, disconnected chunk and specify aInitialTop to be greater than aMaxSize.
483 //! @SYMTestExpectedResults
484 //! 1. 1. The following results are expected:
485 //! a. The chunk should take on the paging status of the process
495 //! @SYMTestPriority High
496 //! @SYMTestStatus Implemented
497 //----------------------------------------------------------------------------------------------
498 void TestLocDiscChunk()
500 test.Start(_L("Test RChunk::CreateDisconnectedLocal - paging attributes"));
502 TChunkCreateInfo createInfo;
503 createInfo.SetDisconnected(0, gPageSize, gPageSize);
504 VerifyChunkPaged(createInfo);
505 // Test default create method
506 TInt r = gChunk.CreateDoubleEndedLocal(0, gPageSize, gPageSize);
507 VerifyChunkPaged(gChunk, gProcessPaged, r);
511 test.Next(_L("Test RChunk::CreateDisconnectedLocal - invalid max size"));
512 TestPanicChunkCreate2(ECreateLocalDC, 0, gPageSize, -1, EChkCreateMaxSizeNegative);
514 test.Next(_L("Test RChunk::CreateDisconnectedLocal - invalid bottom"));
515 TestPanicChunkCreate2(ECreateLocalDC, -1, gPageSize, gPageSize, EChkCreateBottomNegative);
517 test.Next(_L("Test RChunk::CreateDisconnectedLocal - invalid top"));
518 TestPanicChunkCreate2(ECreateLocalDC, 0, -1, gPageSize, EChkCreateTopNegative);
520 test.Next(_L("Test RChunk::CreateDisconnectedLocal - bottom > top"));
521 TestPanicChunkCreate2(ECreateLocalDC, gPageSize, 0, gPageSize, EChkCreateTopLessThanBottom);
523 test.Next(_L("Test RChunk::CreateDisconnectedLocal - top > max size"));
524 TestPanicChunkCreate2(ECreateLocalDC, 0, gPageSize << 1, gPageSize, EChkCreateTopBiggerThanMax);
533 //----------------------------------------------------------------------------------------------
534 //! @SYMTestCaseID KBASE-T_CHUNKCREATE-xxxx
536 //! @SYMPREQ PREQ1954
537 //! @SYMTestCaseDesc Verify the global disconnected chunk creation implementation
539 //! 1. Create a global, disconnected chunk and specify the following paging options.
540 //! Following this check the paging status of the chunk by calling IsPaged().
544 //! 2. Create a global, disconnected chunk and specify aMaxSize to be negative
545 //! 3. Create a global, disconnected chunk and specify aInitialBottom to be negative
546 //! 4. Create a global, disconnected chunk and specify aInitialTop to be negative.
547 //! 5. Create a global, disconnected chunk and specify aInitialBottom to be greater than aInitialTop.
548 //! 6. Create a global, disconnected chunk and specify aInitialBottom to be greater than aMaxSize.
549 //! 7. Create global, disconnected chunk and specify aInitialTop to be greater than aMaxSize.
551 //! @SYMTestExpectedResults
552 //! 1. 1. The following results are expected:
553 //! a. The chunk should take on the paging status of the process
563 //! @SYMTestPriority High
564 //! @SYMTestStatus Implemented
565 //----------------------------------------------------------------------------------------------
566 void TestGlobDiscChunk()
568 test.Start(_L("Test RChunk::CreateDisconnectedGlobal - paging attributes"));
570 TChunkCreateInfo createInfo;
571 createInfo.SetDisconnected(0, gPageSize, gPageSize);
572 createInfo.SetGlobal(KGlobalChunkName);
573 VerifyChunkPaged(createInfo);
574 // Test default create method
575 TInt r = gChunk.CreateDoubleEndedLocal(0, gPageSize, gPageSize);
576 VerifyChunkPaged(gChunk, gProcessPaged, r);
580 test.Next(_L("Test RChunk::CreateDisconnectedGlobal - invalid max size"));
581 TestPanicChunkCreate2(ECreateGlobalDC, 0, gPageSize, -1, EChkCreateMaxSizeNegative);
583 test.Next(_L("Test RChunk::CreateDisconnectedGlobal - invalid bottom"));
584 TestPanicChunkCreate2(ECreateGlobalDC, -1, gPageSize, gPageSize, EChkCreateBottomNegative);
586 test.Next(_L("Test RChunk::CreateDisconnectedGlobal - invalid top"));
587 TestPanicChunkCreate2(ECreateGlobalDC, 0, -1, gPageSize, EChkCreateTopNegative);
589 test.Next(_L("Test RChunk::CreateDisconnectedGlobal - bottom > top"));
590 TestPanicChunkCreate2(ECreateGlobalDC, gPageSize, 0, gPageSize, EChkCreateTopLessThanBottom);
592 test.Next(_L("Test RChunk::CreateDisconnectedGlobal - top > max size"));
593 TestPanicChunkCreate2(ECreateGlobalDC, 0, gPageSize << 1, gPageSize, EChkCreateTopBiggerThanMax);
601 TInt TestingTChunkCreate()
603 test.Start(_L("Test TChunkCreateInfo - Local Chunk"));
606 test.Next(_L("Test TChunkCreateInfo - Code Chunk"));
609 test.Next(_L("Test TChunkCreateInfo - Global Chunk"));
612 test.Next(_L("Test TChunkCreateInfo - Local Double Ended Chunk"));
615 test.Next(_L("Test TChunkCreateInfo - Global Double Ended Chunk"));
618 test.Next(_L("Test TChunkCreateInfo - Local Disconnected Chunk"));
621 test.Next(_L("Test TChunkCreateInfo - Global Disconnected Chunk"));