sl@0
|
1 |
// Copyright (c) 1995-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\mmu\t_chunk4.cpp
|
sl@0
|
15 |
// Overview:
|
sl@0
|
16 |
// Test disconnected chunks
|
sl@0
|
17 |
// API Information:
|
sl@0
|
18 |
// RChunk, CBase
|
sl@0
|
19 |
// Details:
|
sl@0
|
20 |
// - Check Allocate/Commit/Decommit methods on local disconnected chunk and write/read
|
sl@0
|
21 |
// access to both committed and uncommitted regions.
|
sl@0
|
22 |
// - Check IPC that involves local disconnected chunk and verify results are as expected.
|
sl@0
|
23 |
// Platforms/Drives/Compatibility:
|
sl@0
|
24 |
// All.
|
sl@0
|
25 |
// Assumptions/Requirement/Pre-requisites:
|
sl@0
|
26 |
// Failures and causes:
|
sl@0
|
27 |
// Base Port information:
|
sl@0
|
28 |
//
|
sl@0
|
29 |
//
|
sl@0
|
30 |
|
sl@0
|
31 |
#define __E32TEST_EXTENSION__
|
sl@0
|
32 |
#include <e32test.h>
|
sl@0
|
33 |
#include "u32std.h"
|
sl@0
|
34 |
#include "mmudetect.h"
|
sl@0
|
35 |
#include "../misc/prbs.h"
|
sl@0
|
36 |
#include "d_memorytest.h"
|
sl@0
|
37 |
#include "freeram.h"
|
sl@0
|
38 |
|
sl@0
|
39 |
RTest test(_L("T_CHUNK4"));
|
sl@0
|
40 |
|
sl@0
|
41 |
RMemoryTestLdd TestLdd;
|
sl@0
|
42 |
|
sl@0
|
43 |
TUint RndSeed[2];
|
sl@0
|
44 |
|
sl@0
|
45 |
class CChunk : public CBase
|
sl@0
|
46 |
{
|
sl@0
|
47 |
public:
|
sl@0
|
48 |
static CChunk* New(TInt aMaxSize);
|
sl@0
|
49 |
public:
|
sl@0
|
50 |
virtual ~CChunk();
|
sl@0
|
51 |
TInt Verify();
|
sl@0
|
52 |
TInt Commit(TInt anOffset, TInt aSize);
|
sl@0
|
53 |
TInt Allocate(TInt aSize);
|
sl@0
|
54 |
TInt Decommit(TInt anOffset, TInt aSize);
|
sl@0
|
55 |
void CheckL(volatile TUint* aPtr);
|
sl@0
|
56 |
TInt AddPages(TInt anOffset, TInt aSize);
|
sl@0
|
57 |
TInt RemovePages(TInt anOffset, TInt aSize);
|
sl@0
|
58 |
public:
|
sl@0
|
59 |
RChunk iChunk;
|
sl@0
|
60 |
TUint8* iPageInfo;
|
sl@0
|
61 |
TInt iPageSize;
|
sl@0
|
62 |
TInt iMaxSize;
|
sl@0
|
63 |
TInt iNumPages;
|
sl@0
|
64 |
};
|
sl@0
|
65 |
|
sl@0
|
66 |
CChunk* CChunk::New(TInt aMaxSize)
|
sl@0
|
67 |
{
|
sl@0
|
68 |
CChunk* pC=new CChunk;
|
sl@0
|
69 |
if (pC)
|
sl@0
|
70 |
{
|
sl@0
|
71 |
TInt p;
|
sl@0
|
72 |
UserHal::PageSizeInBytes(p);
|
sl@0
|
73 |
pC->iPageSize=p;
|
sl@0
|
74 |
pC->iMaxSize=aMaxSize;
|
sl@0
|
75 |
TInt n=aMaxSize/p;
|
sl@0
|
76 |
pC->iNumPages=n;
|
sl@0
|
77 |
TInt r=pC->iChunk.CreateDisconnectedLocal(0,0,aMaxSize);
|
sl@0
|
78 |
if (r==KErrNone)
|
sl@0
|
79 |
{
|
sl@0
|
80 |
TUint8* pI=(TUint8*)User::Alloc(n);
|
sl@0
|
81 |
if (pI)
|
sl@0
|
82 |
{
|
sl@0
|
83 |
pC->iPageInfo=pI;
|
sl@0
|
84 |
Mem::FillZ(pI,n);
|
sl@0
|
85 |
}
|
sl@0
|
86 |
else
|
sl@0
|
87 |
r=KErrNoMemory;
|
sl@0
|
88 |
}
|
sl@0
|
89 |
if (r!=KErrNone)
|
sl@0
|
90 |
{
|
sl@0
|
91 |
delete pC;
|
sl@0
|
92 |
pC=NULL;
|
sl@0
|
93 |
}
|
sl@0
|
94 |
}
|
sl@0
|
95 |
return pC;
|
sl@0
|
96 |
}
|
sl@0
|
97 |
|
sl@0
|
98 |
CChunk::~CChunk()
|
sl@0
|
99 |
{
|
sl@0
|
100 |
delete iPageInfo;
|
sl@0
|
101 |
iChunk.Close();
|
sl@0
|
102 |
}
|
sl@0
|
103 |
|
sl@0
|
104 |
void CChunk::CheckL(volatile TUint* aPtr)
|
sl@0
|
105 |
{
|
sl@0
|
106 |
TUint x=*aPtr;
|
sl@0
|
107 |
*aPtr=x;
|
sl@0
|
108 |
}
|
sl@0
|
109 |
|
sl@0
|
110 |
TInt CChunk::Verify()
|
sl@0
|
111 |
{
|
sl@0
|
112 |
// test.Getch();
|
sl@0
|
113 |
TInt i;
|
sl@0
|
114 |
TUint8* base=iChunk.Base();
|
sl@0
|
115 |
for (i=0; i<iNumPages; i++)
|
sl@0
|
116 |
{
|
sl@0
|
117 |
volatile TUint* pX=(volatile TUint*)base;
|
sl@0
|
118 |
TInt r=TestLdd.ReadWriteMemory((TAny*)pX);
|
sl@0
|
119 |
TUint8 info=iPageInfo[i];
|
sl@0
|
120 |
if (info==0 && r==KErrNone)
|
sl@0
|
121 |
return KErrGeneral;
|
sl@0
|
122 |
if (info!=0 && r!=KErrNone)
|
sl@0
|
123 |
return KErrAccessDenied;
|
sl@0
|
124 |
if (info!=0)
|
sl@0
|
125 |
{
|
sl@0
|
126 |
TUint seed[2];
|
sl@0
|
127 |
seed[0]=info<<8;
|
sl@0
|
128 |
seed[1]=0;
|
sl@0
|
129 |
TInt j;
|
sl@0
|
130 |
for (j=0; j<iPageSize; j+=4)
|
sl@0
|
131 |
{
|
sl@0
|
132 |
if (*pX++!=Random(seed))
|
sl@0
|
133 |
return KErrArgument;
|
sl@0
|
134 |
}
|
sl@0
|
135 |
}
|
sl@0
|
136 |
base+=iPageSize;
|
sl@0
|
137 |
}
|
sl@0
|
138 |
return KErrNone;
|
sl@0
|
139 |
}
|
sl@0
|
140 |
|
sl@0
|
141 |
TInt CChunk::AddPages(TInt anOffset, TInt aSize)
|
sl@0
|
142 |
{
|
sl@0
|
143 |
TInt i=anOffset/iPageSize;
|
sl@0
|
144 |
TInt n=aSize/iPageSize;
|
sl@0
|
145 |
TInt e=i+n;
|
sl@0
|
146 |
TUint* p=(TUint*)(iChunk.Base()+anOffset);
|
sl@0
|
147 |
for (; i<e; i++)
|
sl@0
|
148 |
{
|
sl@0
|
149 |
TUint8 s=(TUint8)Random(RndSeed);
|
sl@0
|
150 |
if (s==0)
|
sl@0
|
151 |
s=1;
|
sl@0
|
152 |
iPageInfo[i]=s;
|
sl@0
|
153 |
TUint seed[2];
|
sl@0
|
154 |
seed[0]=s<<8;
|
sl@0
|
155 |
seed[1]=0;
|
sl@0
|
156 |
TInt j;
|
sl@0
|
157 |
for (j=0; j<iPageSize; j+=4)
|
sl@0
|
158 |
{
|
sl@0
|
159 |
*p++=Random(seed);
|
sl@0
|
160 |
}
|
sl@0
|
161 |
}
|
sl@0
|
162 |
return KErrNone;
|
sl@0
|
163 |
}
|
sl@0
|
164 |
|
sl@0
|
165 |
TInt CChunk::RemovePages(TInt anOffset, TInt aSize)
|
sl@0
|
166 |
{
|
sl@0
|
167 |
TInt i=anOffset/iPageSize;
|
sl@0
|
168 |
TInt n=aSize/iPageSize;
|
sl@0
|
169 |
TInt e=i+n;
|
sl@0
|
170 |
for (; i<e; i++)
|
sl@0
|
171 |
iPageInfo[i]=0;
|
sl@0
|
172 |
return KErrNone;
|
sl@0
|
173 |
}
|
sl@0
|
174 |
|
sl@0
|
175 |
TInt CChunk::Commit(TInt anOffset, TInt aSize)
|
sl@0
|
176 |
{
|
sl@0
|
177 |
TInt r=iChunk.Commit(anOffset,aSize);
|
sl@0
|
178 |
if (r==KErrNone)
|
sl@0
|
179 |
{
|
sl@0
|
180 |
AddPages(anOffset,aSize);
|
sl@0
|
181 |
}
|
sl@0
|
182 |
return r;
|
sl@0
|
183 |
}
|
sl@0
|
184 |
|
sl@0
|
185 |
TInt CChunk::Allocate(TInt aSize)
|
sl@0
|
186 |
{
|
sl@0
|
187 |
TInt r=iChunk.Allocate(aSize);
|
sl@0
|
188 |
if (r>=0)
|
sl@0
|
189 |
{
|
sl@0
|
190 |
AddPages(r,aSize);
|
sl@0
|
191 |
}
|
sl@0
|
192 |
return r;
|
sl@0
|
193 |
}
|
sl@0
|
194 |
|
sl@0
|
195 |
TInt CChunk::Decommit(TInt anOffset, TInt aSize)
|
sl@0
|
196 |
{
|
sl@0
|
197 |
TInt r=iChunk.Decommit(anOffset,aSize);
|
sl@0
|
198 |
if (r==KErrNone)
|
sl@0
|
199 |
{
|
sl@0
|
200 |
RemovePages(anOffset,aSize);
|
sl@0
|
201 |
}
|
sl@0
|
202 |
return r;
|
sl@0
|
203 |
}
|
sl@0
|
204 |
|
sl@0
|
205 |
// Stuff to test remote writes
|
sl@0
|
206 |
_LIT(KServerName, "Chunk4Test");
|
sl@0
|
207 |
|
sl@0
|
208 |
class CTestSession : public CSession2
|
sl@0
|
209 |
{
|
sl@0
|
210 |
public:
|
sl@0
|
211 |
CTestSession();
|
sl@0
|
212 |
virtual void ServiceL(const RMessage2& aMessage);
|
sl@0
|
213 |
};
|
sl@0
|
214 |
|
sl@0
|
215 |
class CTestServer : public CServer2
|
sl@0
|
216 |
{
|
sl@0
|
217 |
public:
|
sl@0
|
218 |
CTestServer();
|
sl@0
|
219 |
virtual CSession2* NewSessionL(const TVersion& aVersion, const RMessage2& aMessage) const;
|
sl@0
|
220 |
};
|
sl@0
|
221 |
|
sl@0
|
222 |
class RTestSession : public RSessionBase
|
sl@0
|
223 |
{
|
sl@0
|
224 |
public:
|
sl@0
|
225 |
enum {ETestIpc, ETestStop};
|
sl@0
|
226 |
TInt Connect();
|
sl@0
|
227 |
void Stop();
|
sl@0
|
228 |
TInt TestRemoteWrite(TInt aLength, TInt anOffset1, TInt anOffset2, TInt anOffset3, TInt anOffset4);
|
sl@0
|
229 |
TInt IpcWrite(TDes8* aRemoteDest, const TAny* aLocalSrc, TInt aOffset);
|
sl@0
|
230 |
};
|
sl@0
|
231 |
|
sl@0
|
232 |
CTestSession::CTestSession()
|
sl@0
|
233 |
{
|
sl@0
|
234 |
}
|
sl@0
|
235 |
|
sl@0
|
236 |
void CTestSession::ServiceL(const RMessage2& aMessage)
|
sl@0
|
237 |
{
|
sl@0
|
238 |
switch (aMessage.Function())
|
sl@0
|
239 |
{
|
sl@0
|
240 |
case RTestSession::ETestIpc:
|
sl@0
|
241 |
{
|
sl@0
|
242 |
const TDesC8& localSrc = *(const TDesC8*)aMessage.Ptr1();
|
sl@0
|
243 |
TInt offset = aMessage.Int2();
|
sl@0
|
244 |
TInt r = aMessage.Write(0, localSrc, offset);
|
sl@0
|
245 |
aMessage.Complete(r);
|
sl@0
|
246 |
break;
|
sl@0
|
247 |
}
|
sl@0
|
248 |
case RTestSession::ETestStop:
|
sl@0
|
249 |
CActiveScheduler::Stop();
|
sl@0
|
250 |
break;
|
sl@0
|
251 |
default:
|
sl@0
|
252 |
User::Invariant();
|
sl@0
|
253 |
}
|
sl@0
|
254 |
}
|
sl@0
|
255 |
|
sl@0
|
256 |
CTestServer::CTestServer()
|
sl@0
|
257 |
: CServer2(0)
|
sl@0
|
258 |
{
|
sl@0
|
259 |
}
|
sl@0
|
260 |
|
sl@0
|
261 |
CSession2* CTestServer::NewSessionL(const TVersion& /*aVersion*/, const RMessage2& /*aMessage*/) const
|
sl@0
|
262 |
{
|
sl@0
|
263 |
return new (ELeave) CTestSession;
|
sl@0
|
264 |
}
|
sl@0
|
265 |
|
sl@0
|
266 |
TInt ServerThread(TAny*)
|
sl@0
|
267 |
{
|
sl@0
|
268 |
CActiveScheduler* pA = new CActiveScheduler;
|
sl@0
|
269 |
CTestServer* pS = new CTestServer;
|
sl@0
|
270 |
if (!pA || !pS)
|
sl@0
|
271 |
return KErrNoMemory;
|
sl@0
|
272 |
CActiveScheduler::Install(pA);
|
sl@0
|
273 |
TInt r = pS->Start(KServerName);
|
sl@0
|
274 |
if (r!=KErrNone)
|
sl@0
|
275 |
return r;
|
sl@0
|
276 |
RThread::Rendezvous(KErrNone);
|
sl@0
|
277 |
CActiveScheduler::Start();
|
sl@0
|
278 |
return KErrNone;
|
sl@0
|
279 |
}
|
sl@0
|
280 |
|
sl@0
|
281 |
TInt RTestSession::Connect()
|
sl@0
|
282 |
{
|
sl@0
|
283 |
RThread t;
|
sl@0
|
284 |
TInt r = t.Create(KServerName, ServerThread, 0x1000, 0x1000, 0x10000, NULL);
|
sl@0
|
285 |
test(r==KErrNone);
|
sl@0
|
286 |
t.SetPriority(EPriorityMore);
|
sl@0
|
287 |
TRequestStatus s;
|
sl@0
|
288 |
t.Rendezvous(s);
|
sl@0
|
289 |
test(s==KRequestPending);
|
sl@0
|
290 |
t.Resume();
|
sl@0
|
291 |
User::WaitForRequest(s);
|
sl@0
|
292 |
test(t.ExitType()==EExitPending);
|
sl@0
|
293 |
test(s==KErrNone);
|
sl@0
|
294 |
t.Close();
|
sl@0
|
295 |
r = CreateSession(KServerName, TVersion());
|
sl@0
|
296 |
return r;
|
sl@0
|
297 |
}
|
sl@0
|
298 |
|
sl@0
|
299 |
void RTestSession::Stop()
|
sl@0
|
300 |
{
|
sl@0
|
301 |
TInt r = SendReceive(ETestStop);
|
sl@0
|
302 |
test(r==KErrServerTerminated);
|
sl@0
|
303 |
Close();
|
sl@0
|
304 |
}
|
sl@0
|
305 |
|
sl@0
|
306 |
TInt RTestSession::IpcWrite(TDes8* aRemoteDest, const TAny* aLocalSrc, TInt aOffset)
|
sl@0
|
307 |
{
|
sl@0
|
308 |
return SendReceive(ETestIpc, TIpcArgs(aRemoteDest, aLocalSrc, aOffset));
|
sl@0
|
309 |
}
|
sl@0
|
310 |
|
sl@0
|
311 |
TInt RTestSession::TestRemoteWrite(TInt aLength, TInt anOffset1, TInt anOffset2, TInt anOffset3, TInt anOffset4)
|
sl@0
|
312 |
{
|
sl@0
|
313 |
test.Printf(_L("%x %x %x %x %x\n"),aLength,anOffset1,anOffset2,anOffset3,anOffset4);
|
sl@0
|
314 |
|
sl@0
|
315 |
TBool ptr=(anOffset1>=0);
|
sl@0
|
316 |
TDes8* pDes;
|
sl@0
|
317 |
TUint8* pData;
|
sl@0
|
318 |
RChunk c;
|
sl@0
|
319 |
TInt r=c.CreateDisconnectedLocal(0,0,0x800000);
|
sl@0
|
320 |
test(r==KErrNone);
|
sl@0
|
321 |
TUint8* base=c.Base();
|
sl@0
|
322 |
if (ptr)
|
sl@0
|
323 |
{
|
sl@0
|
324 |
r=c.Commit(anOffset1,(TInt)sizeof(TPtr8));
|
sl@0
|
325 |
test(r==KErrNone);
|
sl@0
|
326 |
pDes=(TDes8*)(base+anOffset1);
|
sl@0
|
327 |
Mem::FillZ(pDes,(TInt)sizeof(TPtr8));
|
sl@0
|
328 |
r=c.Commit(anOffset2,aLength);
|
sl@0
|
329 |
test(r==KErrNone);
|
sl@0
|
330 |
pData=base+anOffset2;
|
sl@0
|
331 |
Mem::FillZ(pData,aLength);
|
sl@0
|
332 |
new(pDes) TPtr8(pData,0,aLength);
|
sl@0
|
333 |
test(pDes->Length()==0);
|
sl@0
|
334 |
test(pDes->MaxLength()==aLength);
|
sl@0
|
335 |
test(pDes->Ptr()==pData);
|
sl@0
|
336 |
}
|
sl@0
|
337 |
else
|
sl@0
|
338 |
{
|
sl@0
|
339 |
TInt len=(TInt)sizeof(TDes8)+aLength;
|
sl@0
|
340 |
r=c.Commit(anOffset2,len);
|
sl@0
|
341 |
test(r==KErrNone);
|
sl@0
|
342 |
pDes=(TDes8*)(base+anOffset2);
|
sl@0
|
343 |
Mem::FillZ(pDes,len);
|
sl@0
|
344 |
pData=base+anOffset2+(TInt)sizeof(TDes8);
|
sl@0
|
345 |
new(pDes) TBuf8<1>;
|
sl@0
|
346 |
((TInt*)pDes)[1]=aLength;
|
sl@0
|
347 |
test(pDes->Length()==0);
|
sl@0
|
348 |
test(pDes->MaxLength()==aLength);
|
sl@0
|
349 |
test(pDes->Ptr()==pData);
|
sl@0
|
350 |
}
|
sl@0
|
351 |
TInt slen=aLength-anOffset3;
|
sl@0
|
352 |
TUint8* pS=(TUint8*)User::Alloc(aLength);
|
sl@0
|
353 |
test(pS!=NULL);
|
sl@0
|
354 |
Mem::FillZ(pS,aLength);
|
sl@0
|
355 |
TPtrC8 src(pS+anOffset3,slen);
|
sl@0
|
356 |
TInt i;
|
sl@0
|
357 |
for (i=anOffset3; i<aLength; i++)
|
sl@0
|
358 |
pS[i]=(TUint8)Random(RndSeed);
|
sl@0
|
359 |
if (anOffset4>=0)
|
sl@0
|
360 |
c.Decommit(anOffset4,0x1000);
|
sl@0
|
361 |
r = IpcWrite(pDes, &src, anOffset3);
|
sl@0
|
362 |
if (r==KErrNone)
|
sl@0
|
363 |
{
|
sl@0
|
364 |
TPtrC8 tsrc(pS,aLength);
|
sl@0
|
365 |
if (*pDes!=tsrc)
|
sl@0
|
366 |
r=KErrCorrupt;
|
sl@0
|
367 |
}
|
sl@0
|
368 |
User::Free(pS);
|
sl@0
|
369 |
c.Close();
|
sl@0
|
370 |
test.Printf(_L("Return value %d\n"),r);
|
sl@0
|
371 |
return r;
|
sl@0
|
372 |
}
|
sl@0
|
373 |
|
sl@0
|
374 |
GLDEF_C TInt E32Main()
|
sl@0
|
375 |
{
|
sl@0
|
376 |
RndSeed[0]=0xddb3d743;
|
sl@0
|
377 |
RndSeed[1]=0;
|
sl@0
|
378 |
|
sl@0
|
379 |
test.Title();
|
sl@0
|
380 |
if (!HaveVirtMem())
|
sl@0
|
381 |
{
|
sl@0
|
382 |
test.Printf(_L("This test requires an MMU\n"));
|
sl@0
|
383 |
return KErrNone;
|
sl@0
|
384 |
}
|
sl@0
|
385 |
test.Start(_L("Testing Disconnected Chunks"));
|
sl@0
|
386 |
|
sl@0
|
387 |
test.Printf(_L("Load test LDD\n"));
|
sl@0
|
388 |
test(TestLdd.Open()==KErrNone);
|
sl@0
|
389 |
|
sl@0
|
390 |
CChunk* pC=CChunk::New(0x800000);
|
sl@0
|
391 |
test(pC!=NULL);
|
sl@0
|
392 |
TInt free=FreeRam();
|
sl@0
|
393 |
test.Printf(_L("Free RAM %08x\n"),free);
|
sl@0
|
394 |
test(pC->Verify()==KErrNone);
|
sl@0
|
395 |
test.Printf(_L("Commit 0+0x1000\n"));
|
sl@0
|
396 |
test(pC->Commit(0,0x1000)==KErrNone);
|
sl@0
|
397 |
test(pC->Verify()==KErrNone);
|
sl@0
|
398 |
test.Printf(_L("Commit 0+0x1000 (again)\n"));
|
sl@0
|
399 |
test(pC->Commit(0,0x1000)==KErrAlreadyExists);
|
sl@0
|
400 |
test(pC->Verify()==KErrNone);
|
sl@0
|
401 |
test.Printf(_L("Commit 0x3000+0x1000\n"));
|
sl@0
|
402 |
test(pC->Commit(0x3000,0x1000)==KErrNone);
|
sl@0
|
403 |
test(pC->Verify()==KErrNone);
|
sl@0
|
404 |
test.Printf(_L("Commit 0x2000+0x3000 (overlaps previous)\n"));
|
sl@0
|
405 |
test(pC->Commit(0x2000,0x3000)==KErrAlreadyExists);
|
sl@0
|
406 |
test(pC->Verify()==KErrNone);
|
sl@0
|
407 |
test.Printf(_L("Allocate 0x5000\n"));
|
sl@0
|
408 |
test(pC->Allocate(0x5000)==0x4000);
|
sl@0
|
409 |
test(pC->Verify()==KErrNone);
|
sl@0
|
410 |
test.Printf(_L("Allocate 0x1000\n"));
|
sl@0
|
411 |
test(pC->Allocate(0x1000)==0x1000);
|
sl@0
|
412 |
test(pC->Verify()==KErrNone);
|
sl@0
|
413 |
test.Printf(_L("Decommit 0+0x4000\n"));
|
sl@0
|
414 |
test(pC->Decommit(0,0x4000)==KErrNone);
|
sl@0
|
415 |
test(pC->Verify()==KErrNone);
|
sl@0
|
416 |
test.Printf(_L("Decommit 0+0x4000 (again)\n"));
|
sl@0
|
417 |
test(pC->Decommit(0,0x4000)==KErrNone);
|
sl@0
|
418 |
test(pC->Verify()==KErrNone);
|
sl@0
|
419 |
test.Printf(_L("Allocate 0x4000\n"));
|
sl@0
|
420 |
test(pC->Allocate(0x4000)==0x0000);
|
sl@0
|
421 |
test(pC->Verify()==KErrNone);
|
sl@0
|
422 |
test.Printf(_L("Decommit 0+0x10000\n"));
|
sl@0
|
423 |
test(pC->Decommit(0,0x10000)==KErrNone);
|
sl@0
|
424 |
test(pC->Verify()==KErrNone);
|
sl@0
|
425 |
test.Printf(_L("Check Free RAM\n"));
|
sl@0
|
426 |
test(FreeRam()==free);
|
sl@0
|
427 |
|
sl@0
|
428 |
test.Printf(_L("Commit 0x700000+0x10000\n"));
|
sl@0
|
429 |
test(pC->Commit(0x700000,0x10000)==KErrNone);
|
sl@0
|
430 |
test(pC->Verify()==KErrNone);
|
sl@0
|
431 |
test.Printf(_L("Allocate 0x4000\n"));
|
sl@0
|
432 |
test(pC->Allocate(0x4000)==0x0000);
|
sl@0
|
433 |
test(pC->Verify()==KErrNone);
|
sl@0
|
434 |
test.Printf(_L("Decommit 0+0x800000\n"));
|
sl@0
|
435 |
test(pC->Decommit(0,0x800000)==KErrNone);
|
sl@0
|
436 |
test(pC->Verify()==KErrNone);
|
sl@0
|
437 |
test.Printf(_L("Check Free RAM\n"));
|
sl@0
|
438 |
test(FreeRam()==free);
|
sl@0
|
439 |
|
sl@0
|
440 |
delete pC;
|
sl@0
|
441 |
|
sl@0
|
442 |
// Test decommiting from a chunk which has no memory commited
|
sl@0
|
443 |
// in the first megabyte. On the moving memory model, such
|
sl@0
|
444 |
// chunks have a non-zero iHomeRegionOffset value and has been
|
sl@0
|
445 |
// the cause of defects (DEF121857)
|
sl@0
|
446 |
test.Printf(_L("Create new chunk\n"));
|
sl@0
|
447 |
pC=CChunk::New(0x800000);
|
sl@0
|
448 |
test(pC!=NULL);
|
sl@0
|
449 |
test.Printf(_L("Commit 0x100000+0x3000\n"));
|
sl@0
|
450 |
test(pC->Commit(0x100000,0x3000)==KErrNone);
|
sl@0
|
451 |
test(pC->Verify()==KErrNone);
|
sl@0
|
452 |
test.Printf(_L("Decommit 0+0x101000\n"));
|
sl@0
|
453 |
test(pC->Decommit(0,0x101000)==KErrNone);
|
sl@0
|
454 |
test(pC->Verify()==KErrNone);
|
sl@0
|
455 |
test.Printf(_L("Decommit 0x101000+0x1000\n"));
|
sl@0
|
456 |
test(pC->Decommit(0x101000,0x1000)==KErrNone);
|
sl@0
|
457 |
test(pC->Verify()==KErrNone);
|
sl@0
|
458 |
test.Printf(_L("Decommit 0x100000+0x100000\n"));
|
sl@0
|
459 |
test(pC->Decommit(0x100000,0x100000)==KErrNone);
|
sl@0
|
460 |
test(pC->Verify()==KErrNone);
|
sl@0
|
461 |
delete pC;
|
sl@0
|
462 |
|
sl@0
|
463 |
test.Next(_L("Testing RThread::Write to disconnected chunks"));
|
sl@0
|
464 |
RTestSession ts;
|
sl@0
|
465 |
TInt r = ts.Connect();
|
sl@0
|
466 |
test(r==KErrNone);
|
sl@0
|
467 |
test(ts.TestRemoteWrite(64,0,0x3000,0,-1)==KErrNone);
|
sl@0
|
468 |
test(ts.TestRemoteWrite(64,0xffc,0x8000,0,-1)==KErrNone);
|
sl@0
|
469 |
test(ts.TestRemoteWrite(256,0xffc,0x7f80,0,-1)==KErrNone);
|
sl@0
|
470 |
test(ts.TestRemoteWrite(256,0xffc,0x7f80,128,-1)==KErrNone);
|
sl@0
|
471 |
test(ts.TestRemoteWrite(0x10000,0xffc,0x707f80,0,-1)==KErrNone);
|
sl@0
|
472 |
test(ts.TestRemoteWrite(0x10000,0xffc,0x707f80,0x2000,-1)==KErrNone);
|
sl@0
|
473 |
test(ts.TestRemoteWrite(64,-1,0x3000,0,-1)==KErrNone);
|
sl@0
|
474 |
test(ts.TestRemoteWrite(0x10000,-1,0xfff00,0x2000,-1)==KErrNone);
|
sl@0
|
475 |
test(ts.TestRemoteWrite(256,0xffc,0x7f80,16,0)==KErrBadDescriptor);
|
sl@0
|
476 |
test(ts.TestRemoteWrite(256,0xffc,0x7f80,16,0x1000)==KErrBadDescriptor);
|
sl@0
|
477 |
test(ts.TestRemoteWrite(256,0xffc,0x7f80,16,0x7000)==KErrBadDescriptor);
|
sl@0
|
478 |
test(ts.TestRemoteWrite(256,0xffc,0x7f80,16,0x8000)==KErrBadDescriptor);
|
sl@0
|
479 |
test(ts.TestRemoteWrite(0x10000,0xffc,0x707f80,0x2000,0x710000)==KErrBadDescriptor);
|
sl@0
|
480 |
test(ts.TestRemoteWrite(0x10000,-1,0xfff00,0x1000,0x100000)==KErrBadDescriptor);
|
sl@0
|
481 |
ts.Stop();
|
sl@0
|
482 |
|
sl@0
|
483 |
test.End();
|
sl@0
|
484 |
return 0;
|
sl@0
|
485 |
}
|