|
1 // Copyright (c) 1995-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // e32test\mmu\t_dchunk.cpp |
|
15 // |
|
16 // |
|
17 |
|
18 #include <e32test.h> |
|
19 #include <e32hal.h> |
|
20 #include <e32panic.h> |
|
21 #include <e32def.h> |
|
22 #include <e32def_private.h> |
|
23 |
|
24 LOCAL_D RTest test(_L("T_DCHUNK")); |
|
25 |
|
26 TInt E32Main() |
|
27 // |
|
28 // Test RChunk class |
|
29 // |
|
30 { |
|
31 |
|
32 test.Title(); |
|
33 test.Start(_L("Test double-ended chunks")); |
|
34 __KHEAP_MARK; |
|
35 TMemoryInfoV1Buf meminfo1,meminfo2; |
|
36 TInt r=UserHal::MemoryInfo(meminfo1); |
|
37 test(r==KErrNone); |
|
38 test.Printf(_L("Free RAM %08X bytes\n"),meminfo1().iFreeRamInBytes); |
|
39 |
|
40 RChunk chunk1; |
|
41 r=chunk1.CreateDoubleEndedLocal(0x1000,0x3000,2*meminfo1().iFreeRamInBytes); |
|
42 test(r==KErrNone); |
|
43 TInt size = chunk1.Size(); |
|
44 TInt bottom = chunk1.Bottom(); |
|
45 TInt top = chunk1.Top(); |
|
46 Mem::FillZ((TAny*)(chunk1.Base()+chunk1.Bottom()),chunk1.Size()); |
|
47 |
|
48 r=UserHal::MemoryInfo(meminfo1); |
|
49 test (r==KErrNone); |
|
50 test.Printf(_L("Free RAM %08X bytes\n"),meminfo1().iFreeRamInBytes); |
|
51 |
|
52 r=chunk1.AdjustDoubleEnded(0,2*meminfo1().iFreeRamInBytes); |
|
53 test(r==KErrNoMemory); |
|
54 test(size==chunk1.Size()); |
|
55 test(bottom==chunk1.Bottom()); |
|
56 test(top==chunk1.Top()); |
|
57 |
|
58 r=UserHal::MemoryInfo(meminfo2); |
|
59 test(r==KErrNone); |
|
60 test.Printf(_L("Free RAM %08X bytes\n"),meminfo2().iFreeRamInBytes); |
|
61 test(meminfo1().iFreeRamInBytes==meminfo2().iFreeRamInBytes); |
|
62 |
|
63 r=chunk1.AdjustDoubleEnded(0,0x6000); |
|
64 test(r==KErrNone); |
|
65 Mem::FillZ((TAny*)(chunk1.Base()+chunk1.Bottom()),chunk1.Size()); |
|
66 |
|
67 chunk1.Close(); |
|
68 |
|
69 test.End(); |
|
70 test.Close(); |
|
71 __KHEAP_MARKEND; |
|
72 return(KErrNone); |
|
73 } |
|
74 |
|
75 |