sl@0
|
1 |
// Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of the License "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
// e32test\misc\t_mem.cpp
|
sl@0
|
15 |
//
|
sl@0
|
16 |
//
|
sl@0
|
17 |
|
sl@0
|
18 |
#include <e32test.h>
|
sl@0
|
19 |
#include "u32std.h"
|
sl@0
|
20 |
#include "../misc/prbs.h"
|
sl@0
|
21 |
|
sl@0
|
22 |
RTest test(_L("T_MEM"));
|
sl@0
|
23 |
|
sl@0
|
24 |
TInt E32Main()
|
sl@0
|
25 |
{
|
sl@0
|
26 |
test.Title();
|
sl@0
|
27 |
test.Start(_L("Create chunk"));
|
sl@0
|
28 |
TMemoryInfoV1 minfo;
|
sl@0
|
29 |
TPckg<TMemoryInfoV1> infoPckg(minfo);
|
sl@0
|
30 |
TInt r = UserHal::MemoryInfo(infoPckg);
|
sl@0
|
31 |
test(r==KErrNone);
|
sl@0
|
32 |
test.Printf(_L("MaxFree = %08x\n"), minfo.iMaxFreeRamInBytes);
|
sl@0
|
33 |
test.Printf(_L("Free = %08x\n"), minfo.iFreeRamInBytes);
|
sl@0
|
34 |
TInt overhead = ((minfo.iFreeRamInBytes + 0x003FFFFF)>>22)<<12;
|
sl@0
|
35 |
test.Printf(_L("Overhead = %08x\n"), overhead);
|
sl@0
|
36 |
TInt size = Min(minfo.iFreeRamInBytes-0x00100000, minfo.iFreeRamInBytes-overhead);
|
sl@0
|
37 |
test.Printf(_L("Initial = %08x\n"), size);
|
sl@0
|
38 |
RChunk c;
|
sl@0
|
39 |
r=c.CreateLocal(size, minfo.iFreeRamInBytes);
|
sl@0
|
40 |
test(r==KErrNone);
|
sl@0
|
41 |
while (r==KErrNone)
|
sl@0
|
42 |
{
|
sl@0
|
43 |
r = c.Adjust(size + 0x1000);
|
sl@0
|
44 |
if (r==KErrNone)
|
sl@0
|
45 |
size += 0x1000;
|
sl@0
|
46 |
};
|
sl@0
|
47 |
test.Printf(_L("Final = %08x\n"), size);
|
sl@0
|
48 |
|
sl@0
|
49 |
TUint seed[2];
|
sl@0
|
50 |
seed[0]=User::NTickCount();
|
sl@0
|
51 |
seed[1]=0;
|
sl@0
|
52 |
TUint8* p=c.Base();
|
sl@0
|
53 |
test.Printf(_L("Chunk Base %08x\n"),p);
|
sl@0
|
54 |
Mem::FillZ(p,size);
|
sl@0
|
55 |
TInt sizepg = size>>12;
|
sl@0
|
56 |
TUint iterations = 0;
|
sl@0
|
57 |
FOREVER
|
sl@0
|
58 |
{
|
sl@0
|
59 |
TUint x=Random(seed);
|
sl@0
|
60 |
x%=TUint(sizepg);
|
sl@0
|
61 |
TInt offset=x<<12;
|
sl@0
|
62 |
TUint init=Random(seed);
|
sl@0
|
63 |
TUint seed2[2];
|
sl@0
|
64 |
seed2[0]=init;
|
sl@0
|
65 |
seed2[1]=0;
|
sl@0
|
66 |
TUint* pW=(TUint*)(p+offset);
|
sl@0
|
67 |
*pW++=init;
|
sl@0
|
68 |
TInt i;
|
sl@0
|
69 |
for (i=1; i<1024; i++)
|
sl@0
|
70 |
*pW++=Random(seed2);
|
sl@0
|
71 |
TInt j;
|
sl@0
|
72 |
for (j=0; j<19; j++)
|
sl@0
|
73 |
{
|
sl@0
|
74 |
x=Random(seed);
|
sl@0
|
75 |
x%=TUint(sizepg);
|
sl@0
|
76 |
offset=x<<12;
|
sl@0
|
77 |
pW=(TUint*)(p+offset);
|
sl@0
|
78 |
seed2[0]=*pW++;
|
sl@0
|
79 |
seed2[1]=0;
|
sl@0
|
80 |
for (i=1; i<1024; i++)
|
sl@0
|
81 |
{
|
sl@0
|
82 |
TUint actual=*pW++;
|
sl@0
|
83 |
TUint expected=Random(seed2);
|
sl@0
|
84 |
TUint diff = actual ^ expected;
|
sl@0
|
85 |
if (diff)
|
sl@0
|
86 |
{
|
sl@0
|
87 |
test.Printf(_L("Address %08x: Got %08x Expected %08x Diff %08x\n"),pW-1,actual,expected,diff);
|
sl@0
|
88 |
pW[-1] = expected;
|
sl@0
|
89 |
// test.Getch();
|
sl@0
|
90 |
// test(0);
|
sl@0
|
91 |
}
|
sl@0
|
92 |
}
|
sl@0
|
93 |
}
|
sl@0
|
94 |
++iterations;
|
sl@0
|
95 |
if ((iterations & 0x3ff)==0)
|
sl@0
|
96 |
test.Printf(_L("%u\n"),iterations);
|
sl@0
|
97 |
}
|
sl@0
|
98 |
}
|