0
|
1 |
// Copyright (c) 1998-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\misc\t_mem.cpp
|
|
15 |
//
|
|
16 |
//
|
|
17 |
|
|
18 |
#include <e32test.h>
|
|
19 |
#include "u32std.h"
|
|
20 |
#include "../misc/prbs.h"
|
|
21 |
|
|
22 |
RTest test(_L("T_MEM"));
|
|
23 |
|
|
24 |
TInt E32Main()
|
|
25 |
{
|
|
26 |
test.Title();
|
|
27 |
test.Start(_L("Create chunk"));
|
|
28 |
TMemoryInfoV1 minfo;
|
|
29 |
TPckg<TMemoryInfoV1> infoPckg(minfo);
|
|
30 |
TInt r = UserHal::MemoryInfo(infoPckg);
|
|
31 |
test(r==KErrNone);
|
|
32 |
test.Printf(_L("MaxFree = %08x\n"), minfo.iMaxFreeRamInBytes);
|
|
33 |
test.Printf(_L("Free = %08x\n"), minfo.iFreeRamInBytes);
|
|
34 |
TInt overhead = ((minfo.iFreeRamInBytes + 0x003FFFFF)>>22)<<12;
|
|
35 |
test.Printf(_L("Overhead = %08x\n"), overhead);
|
|
36 |
TInt size = Min(minfo.iFreeRamInBytes-0x00100000, minfo.iFreeRamInBytes-overhead);
|
|
37 |
test.Printf(_L("Initial = %08x\n"), size);
|
|
38 |
RChunk c;
|
|
39 |
r=c.CreateLocal(size, minfo.iFreeRamInBytes);
|
|
40 |
test(r==KErrNone);
|
|
41 |
while (r==KErrNone)
|
|
42 |
{
|
|
43 |
r = c.Adjust(size + 0x1000);
|
|
44 |
if (r==KErrNone)
|
|
45 |
size += 0x1000;
|
|
46 |
};
|
|
47 |
test.Printf(_L("Final = %08x\n"), size);
|
|
48 |
|
|
49 |
TUint seed[2];
|
|
50 |
seed[0]=User::NTickCount();
|
|
51 |
seed[1]=0;
|
|
52 |
TUint8* p=c.Base();
|
|
53 |
test.Printf(_L("Chunk Base %08x\n"),p);
|
|
54 |
Mem::FillZ(p,size);
|
|
55 |
TInt sizepg = size>>12;
|
|
56 |
TUint iterations = 0;
|
|
57 |
FOREVER
|
|
58 |
{
|
|
59 |
TUint x=Random(seed);
|
|
60 |
x%=TUint(sizepg);
|
|
61 |
TInt offset=x<<12;
|
|
62 |
TUint init=Random(seed);
|
|
63 |
TUint seed2[2];
|
|
64 |
seed2[0]=init;
|
|
65 |
seed2[1]=0;
|
|
66 |
TUint* pW=(TUint*)(p+offset);
|
|
67 |
*pW++=init;
|
|
68 |
TInt i;
|
|
69 |
for (i=1; i<1024; i++)
|
|
70 |
*pW++=Random(seed2);
|
|
71 |
TInt j;
|
|
72 |
for (j=0; j<19; j++)
|
|
73 |
{
|
|
74 |
x=Random(seed);
|
|
75 |
x%=TUint(sizepg);
|
|
76 |
offset=x<<12;
|
|
77 |
pW=(TUint*)(p+offset);
|
|
78 |
seed2[0]=*pW++;
|
|
79 |
seed2[1]=0;
|
|
80 |
for (i=1; i<1024; i++)
|
|
81 |
{
|
|
82 |
TUint actual=*pW++;
|
|
83 |
TUint expected=Random(seed2);
|
|
84 |
TUint diff = actual ^ expected;
|
|
85 |
if (diff)
|
|
86 |
{
|
|
87 |
test.Printf(_L("Address %08x: Got %08x Expected %08x Diff %08x\n"),pW-1,actual,expected,diff);
|
|
88 |
pW[-1] = expected;
|
|
89 |
// test.Getch();
|
|
90 |
// test(0);
|
|
91 |
}
|
|
92 |
}
|
|
93 |
}
|
|
94 |
++iterations;
|
|
95 |
if ((iterations & 0x3ff)==0)
|
|
96 |
test.Printf(_L("%u\n"),iterations);
|
|
97 |
}
|
|
98 |
}
|