First public contribution.
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies).
2 // All rights reserved.
3 // This component and the accompanying materials are made available
4 // under the terms of the License "Eclipse Public License v1.0"
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // e32test\realtime\t_frag.cpp
20 #include "../misc/prbs.h"
22 RTest test(_L("T_FRAG"));
23 const TInt KHeapSize=4096;
25 LOCAL_C TInt ThreadFunction(TAny* aRandomNumber)
28 seed[0]=(TUint)aRandomNumber;
32 TInt r=c.CreateLocal(0x1000,0x01000000); // initial 4k max 16Mb
34 User::Panic(_L("T_FRAG"),r);
37 TUint wait=Random(seed);
38 wait &= 16383; // delay in us between 0 and 16383
40 TUint size=Random(seed);
41 size &= 4194303; // size in bytes between 0 and 4194303
42 c.Adjust(size); // adjust chunk, ignore any errors
46 GLDEF_C TInt E32Main()
49 test.Start(_L("Testing allocation/deallocation with fragmented memory"));
55 r=t1.Create(_L("Thread1"),ThreadFunction,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)0xb504f334);
57 t1.SetPriority(EPriorityLess);
63 r=t2.Create(_L("Thread2"),ThreadFunction,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)0xddb3d743);
65 t2.SetPriority(EPriorityMuchLess);
71 r=t3.Create(_L("Thread3"),ThreadFunction,KDefaultStackSize,KHeapSize,KHeapSize,(TAny*)0xc90fdaa2);
73 t3.SetPriority(EPriorityMuchLess);
77 User::WaitForAnyRequest();
79 if (s1!=KRequestPending)
81 TExitCategoryName t1ExitCategory = t1.ExitCategory();
82 test.Printf(_L("Thread1 exited %d,%d,%S\n"),t1.ExitType(),t1.ExitReason(),&t1ExitCategory);
84 if (s2!=KRequestPending)
86 TExitCategoryName t2ExitCategory = t2.ExitCategory();
87 test.Printf(_L("Thread2 exited %d,%d,%S\n"),t2.ExitType(),t2.ExitReason(),&t2ExitCategory);
89 if (s3!=KRequestPending)
91 TExitCategoryName t3ExitCategory = t3.ExitCategory();
92 test.Printf(_L("Thread3 exited %d,%d,%S\n"),t3.ExitType(),t3.ExitReason(),&t3ExitCategory);