author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Tue, 31 Aug 2010 16:34:26 +0300 | |
branch | RCL_3 |
changeset 43 | c1f20ce4abcf |
parent 28 | 5b5d147c7838 |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2005-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_demandpaging.cpp |
|
15 |
// Functional tests for demand paging. The test suite covers simple |
|
16 |
// paging operations as well as HAL configuration and tuning functions. |
|
17 |
// 001.01 DPTest::Attributes |
|
18 |
// 001.02 DPTest::FlushCache |
|
19 |
// 001.03 DPTest::CacheSize |
|
20 |
// 001.04 DPTest::SetCacheSize |
|
21 |
// 001.04.01 Changing size of flushed VM cache |
|
22 |
// 001.04.02 Changing size of full VM cache |
|
23 |
// 002 Loading test drivers |
|
24 |
// 003 Test thread realtime state |
|
25 |
// 003.01 Enable KREALTIME tracing |
|
26 |
// 003.02 Test ERealtimeStateOff |
|
27 |
// 003.03 Test ERealtimeStateOn |
|
28 |
// 003.04 Test ERealtimeStateWarn |
|
29 |
// 003.05 Test server with ERealtimeStateOff |
|
30 |
// 003.06 Test server with ERealtimeStateOn |
|
31 |
// 003.07 Test server with ERealtimeStateWarn |
|
32 |
// 003.08 Disable KREALTIME tracing |
|
33 |
// 004 Lock Test |
|
34 |
// 005 Lock Test again |
|
35 |
// 006 Test writing to paged ROM |
|
36 |
// 007 Test IPC read from paged memory |
|
37 |
// 007.01 Create server |
|
38 |
// 007.02 IPC read from ROM |
|
39 |
// 007.03 Stop server |
|
40 |
// 008 Test contiguous RAM allocation reclaims paged memory |
|
41 |
// 008.01 Start... |
|
42 |
// 008.02 Contiguous RAM test: alloc size = 128K align = 16 |
|
43 |
// 008.03 Contiguous RAM test: alloc size = 128K align = 0 |
|
44 |
// 008.04 Contiguous RAM test: alloc size = 64K align = 15 |
|
45 |
// 008.05 Contiguous RAM test: alloc size = 64K align = 14 |
|
46 |
// 008.06 Contiguous RAM test: alloc size = 64K align = 13 |
|
47 |
// 008.07 Contiguous RAM test: alloc size = 64K align = 12 |
|
48 |
// 008.08 Contiguous RAM test: alloc size = 64K align = 0 |
|
49 |
// 008.09 Contiguous RAM test: alloc size = 8K align = 13 |
|
50 |
// 008.10 Contiguous RAM test: alloc size = 8K align = 12 |
|
51 |
// 008.11 Contiguous RAM test: alloc size = 8K align = 0 |
|
52 |
// 008.12 Contiguous RAM test: alloc size = 4K align = 13 |
|
53 |
// 008.13 Contiguous RAM test: alloc size = 4K align = 12 |
|
54 |
// 008.14 Contiguous RAM test: alloc size = 4K align = 0 |
|
55 |
// 009 Test no kernel faults when copying data from unpaged rom with mutex held |
|
56 |
// 010 Close test driver |
|
57 |
// 011 Test setting publish and subscribe properties from paged area |
|
58 |
// 012 Rom Paging Benchmark |
|
59 |
// 012.01 Benchmark ROM paging... |
|
60 |
// |
|
61 |
// |
|
62 |
||
63 |
//! @SYMTestCaseID KBASE-T_DEMANDPAGING-0334 |
|
64 |
//! @SYMTestType UT |
|
65 |
//! @SYMPREQ PREQ1110 |
|
66 |
//! @SYMTestCaseDesc Demand Paging functional tests. |
|
67 |
//! @SYMTestActions 001 Test HAL interface |
|
68 |
//! @SYMTestExpectedResults All tests should pass. |
|
69 |
//! @SYMTestPriority High |
|
70 |
//! @SYMTestStatus Implemented |
|
71 |
||
72 |
#define __E32TEST_EXTENSION__ |
|
73 |
#include <e32test.h> |
|
74 |
#include <dptest.h> |
|
75 |
#include <e32kpan.h> |
|
76 |
#include <e32property.h> |
|
77 |
#include <e32rom.h> |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
78 |
#include <u32hal.h> |
0 | 79 |
#include "d_memorytest.h" |
80 |
#include "d_demandpaging.h" |
|
81 |
#include "d_gobble.h" |
|
82 |
#include "mmudetect.h" |
|
83 |
#include "t_codepaging_dll.h" |
|
84 |
#include "freeram.h" |
|
85 |
||
86 |
RTest test(_L("T_DEMANDPAGING")); |
|
87 |
||
88 |
_LIT(KTCodePagingDll4, "t_codepaging_dll4.dll"); |
|
89 |
const TInt KMinBufferSize = 16384; |
|
90 |
const TInt KMaxIPCSize = 256*1024; |
|
91 |
||
92 |
TInt PageSize = 0; |
|
93 |
RDemandPagingTestLdd Ldd; |
|
94 |
RLibrary PagedLibrary; |
|
95 |
||
96 |
// A buffer containing paged memory, contents may or may not be paged in |
|
97 |
const TUint8* LargeBuffer = NULL; |
|
98 |
TInt LargeBufferSize = 0; |
|
99 |
||
100 |
// A buffer containing paged memeory, contents always paged out before access |
|
101 |
const TUint8* SmallBuffer = NULL; |
|
102 |
TInt SmallBufferSize = 0; |
|
103 |
||
104 |
// A shared buffer mapped to the global address range |
|
105 |
TInt SharedBufferSize = KMaxIPCSize+4096; |
|
106 |
TLinAddr SharedBufferAddr = 0; |
|
107 |
TUint8* SharedBuffer = NULL; |
|
108 |
||
109 |
// A descriptor whose header is in paged memory (actually just a pointer to a zero word) |
|
110 |
TDesC8* PagedHeaderDes = NULL; |
|
111 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
112 |
// An area of paged rom if rom paging is supported, or zero |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
113 |
TUint8* RomPagedBuffer = NULL; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
114 |
TInt RomPagedBufferSize = 0; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
115 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
116 |
// An area of paged code if code paging is supported, or zero |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
117 |
TUint8* CodePagedBuffer = NULL; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
118 |
TInt CodePagedBufferSize = 0; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
119 |
|
0 | 120 |
// A data paged chunk used as a buffer, if data paging is supported |
121 |
_LIT(KChunkName, "t_demandpaging chunk"); |
|
122 |
RChunk DataPagedChunk; |
|
123 |
TBool DataPagingSupported = EFalse; |
|
124 |
TUint8* DataPagedBuffer = NULL; |
|
125 |
||
126 |
TUint8 ReadByte(volatile TUint8* aPtr) |
|
127 |
{ |
|
128 |
return *aPtr; |
|
129 |
} |
|
130 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
131 |
TUint8 WriteByte(volatile TUint8* aPtr) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
132 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
133 |
return *aPtr = 1; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
134 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
135 |
|
0 | 136 |
#define READ(a) ReadByte((volatile TUint8*)(a)) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
137 |
#define WRITE(a) WriteByte((volatile TUint8*)(a)) |
0 | 138 |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
139 |
void ThrashPaging(TUint aBytes) |
0 | 140 |
{ |
141 |
TUint size = LargeBufferSize; |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
142 |
if(size > aBytes) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
143 |
size = aBytes; |
0 | 144 |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
145 |
TUint readCount = 5 * size/PageSize; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
146 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
147 |
test.Printf(_L("ThrashPaging %u %u\n"), size, readCount); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
148 |
|
0 | 149 |
TUint32 random=1; |
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
150 |
for(TUint i = 0 ; i < readCount ; ++i) |
0 | 151 |
{ |
152 |
READ(LargeBuffer+((TInt64(random)*TInt64(size))>>32)); |
|
153 |
random = random*69069+1; |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
void FragmentPagingCache(TUint aMaxBytes) |
|
158 |
{ |
|
159 |
DPTest::FlushCache(); |
|
160 |
||
161 |
TUint size = Min(LargeBufferSize, aMaxBytes); |
|
162 |
if(size<aMaxBytes) |
|
163 |
test.Printf(_L("WARNING: LargeBuffer not large enough! Have you built a full test ROM?\n")); |
|
164 |
||
165 |
RChunk chunk; |
|
166 |
test(KErrNone==chunk.CreateDisconnectedLocal(0,0,size)); |
|
167 |
||
168 |
TUint32 random = 0; |
|
169 |
for(TUint i=0; i<size; i += PageSize) |
|
170 |
{ |
|
171 |
random = random*69069+1; |
|
172 |
if(random<0x40000000) |
|
173 |
chunk.Commit(i,PageSize); // to make paging cache fragmented |
|
174 |
READ(LargeBuffer + i); |
|
175 |
} |
|
176 |
||
177 |
CLOSE_AND_WAIT(chunk); |
|
178 |
||
179 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
180 |
} |
|
181 |
||
182 |
||
183 |
void RomPagingBenchmark() |
|
184 |
{ |
|
185 |
TInt r=DPTest::FlushCache(); |
|
186 |
if(r!=KErrNone) |
|
187 |
return; |
|
188 |
||
189 |
test.Start(_L("Benchmark ROM paging...")); |
|
190 |
||
191 |
// change live list to be a small as possible |
|
192 |
test(KErrNone==DPTest::SetCacheSize(1,1)); |
|
193 |
||
194 |
RTimer timer; |
|
195 |
test(KErrNone==timer.CreateLocal()); |
|
196 |
TRequestStatus status; |
|
197 |
timer.After(status,1); |
|
198 |
User::WaitForRequest(status); |
|
199 |
||
200 |
TPckgBuf<DPTest::TEventInfo> events0; |
|
201 |
DPTest::EventInfo(events0); |
|
202 |
||
203 |
TInt KRunTime = 10*1000*1000; |
|
204 |
timer.After(status,KRunTime); |
|
205 |
while(status==KRequestPending) |
|
206 |
for(const TUint8* ptr=LargeBuffer; ptr<(LargeBuffer+LargeBufferSize); ptr+=PageSize) |
|
207 |
{ |
|
208 |
READ(ptr); |
|
209 |
if(status!=KRequestPending) |
|
210 |
break; |
|
211 |
} |
|
212 |
||
213 |
TPckgBuf<DPTest::TEventInfo> events1; |
|
214 |
DPTest::EventInfo(events1); |
|
215 |
||
216 |
User::WaitForRequest(status); |
|
217 |
||
218 |
TUint pages = events1().iPageInReadCount-events0().iPageInReadCount; |
|
219 |
test.Printf(_L("%d pages in %d seconds = %d us/page\n"),pages,KRunTime/1000/1000,KRunTime/pages); |
|
220 |
||
221 |
// restore live list to default size... |
|
222 |
test(KErrNone==DPTest::SetCacheSize(0,0)); |
|
223 |
||
224 |
test.End(); |
|
225 |
} |
|
226 |
||
227 |
||
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
228 |
TInt SetCacheSize(TUint aNewMin, TUint aNewMax) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
229 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
230 |
// set cache size and test 'get' function returns expected values |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
231 |
TInt r = DPTest::SetCacheSize(aNewMin, aNewMax); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
232 |
if (r == KErrNone) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
233 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
234 |
TUint min, max, current; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
235 |
test_KErrNone(DPTest::CacheSize(min,max,current)); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
236 |
test_Equal(aNewMin, min); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
237 |
test_Equal(aNewMax, max); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
238 |
test(current >= min && current <= max); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
239 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
240 |
return r; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
241 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
242 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
243 |
void DoResizeCache(TUint min, TUint max, TInt result, TUint& sizeMin, TUint& sizeMax, TUint originalMin, TUint originalMax) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
244 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
245 |
test.Printf(_L("DPTest::SetCacheSize min=%u, max=%u, expected result=%d\n"),min/PageSize,max/PageSize,result); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
246 |
TInt r=SetCacheSize(min,max); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
247 |
test_Equal(result, r); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
248 |
if(r==KErrNone) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
249 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
250 |
// we've successfully changed the cache size... |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
251 |
if(max) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
252 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
253 |
sizeMin = min; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
254 |
sizeMax = max; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
255 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
256 |
else |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
257 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
258 |
sizeMin = originalMin; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
259 |
sizeMax = originalMax; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
260 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
261 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
262 |
else if(r==KErrNoMemory) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
263 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
264 |
// cache size after OOM is unpredictable, so reset our values |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
test_KErrNone(SetCacheSize(sizeMin,sizeMax)); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
266 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
267 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
268 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
269 |
|
0 | 270 |
void TestResizeVMCache() |
271 |
{ |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
272 |
test.Start(_L("Test resizing VM cache")); |
0 | 273 |
TInt r = DPTest::SetCacheSize(0,0); // restore cache size to defaults |
274 |
test(r==KErrNone); |
|
275 |
TUint sizeMin = 0; |
|
276 |
TUint sizeMax = 0; |
|
277 |
TUint currentSize = 0; |
|
278 |
DPTest::CacheSize(sizeMin,sizeMax,currentSize); |
|
279 |
TUint originalMin = sizeMin; |
|
280 |
TUint originalMax = sizeMax; |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
281 |
test.Printf(_L("original min=%u, original max=%u, current=%u\n"), |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
282 |
originalMin/PageSize,originalMax/PageSize,currentSize/PageSize); |
0 | 283 |
|
284 |
int K = currentSize/PageSize+4; |
|
285 |
||
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
286 |
// Exercise the cache reszing code by testing all valid combinations of the relationships |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
287 |
// between the current min size, current max size, new min size and new max size. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
288 |
// |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
289 |
// This can be done using four cache size values. Every assignment of these four values to the |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
290 |
// four variables is generated, and invalid combinations rejected. This repeats some |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
291 |
// relationships but is simpler than calculating the minimum set of combinations exactly. |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
292 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
293 |
const TUint combinations = 256; // 4 ^ 4 |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
294 |
const TUint sizes[] = { K, K + 4, K + 8, K + 12, K + 16 }; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
295 |
for (TUint perm = 0 ; perm < combinations ; ++perm) |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
296 |
{ |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
297 |
TUint vars[4] = { sizes[ perm & 3 ], |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
298 |
sizes[ (perm >> 2) & 3 ], |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
299 |
sizes[ (perm >> 4) & 3 ], |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
300 |
sizes[ (perm >> 6) & 3 ]}; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
301 |
if ((vars[0] == vars[2] && vars[1] == vars[3]) || // ensure current != new |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
302 |
vars[0] > vars[1] || // ensure current min <= current max |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
303 |
vars[2] > vars[3]) // ensure new min <= new max |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
304 |
continue; |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
305 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
306 |
test.Printf(_L("Test changing cache sizes from %u, %u to %u %u\n"), |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
307 |
vars[0], vars[1], vars[2], vars[3]); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
308 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
309 |
test_KErrNone(SetCacheSize(PageSize * vars[0], PageSize * vars[1])); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
310 |
ThrashPaging(PageSize * vars[1]); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
311 |
test_KErrNone(SetCacheSize(PageSize * vars[2], PageSize * vars[3])); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
312 |
} |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
313 |
test_KErrNone(SetCacheSize(originalMin, originalMax)); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
314 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
315 |
// Now test some more specific resizings |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
316 |
|
0 | 317 |
struct |
318 |
{ |
|
319 |
TUint iMinPages; |
|
320 |
TUint iMaxPages; |
|
321 |
TInt iResult; |
|
322 |
} |
|
323 |
testArgs[] = |
|
324 |
{ |
|
325 |
{ K, K, KErrNone}, |
|
326 |
{ K-4, K, KErrNone}, |
|
327 |
{ K, K, KErrNone}, |
|
328 |
{ K, K*2, KErrNone}, |
|
329 |
{ K, K, KErrNone}, |
|
330 |
{ K-1, K, KErrNone}, |
|
331 |
{ K, K, KErrNone}, |
|
332 |
{ K, K+1, KErrNone}, |
|
333 |
{ K, K, KErrNone}, |
|
334 |
{ K+1, K, KErrArgument}, |
|
335 |
{ K, K-1, KErrArgument}, |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
336 |
{ K, K, KErrNone}, |
0 | 337 |
{ KMaxTInt, KMaxTInt, KErrNoMemory}, |
338 |
{ K, K, KErrNone}, |
|
339 |
||
340 |
{ 0, 0, KMaxTInt} // list end marker |
|
341 |
}; |
|
342 |
||
343 |
for(TInt j=0; j<2; ++j) |
|
344 |
{ |
|
345 |
if(!j) |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
346 |
test.Next(_L("Changing size of empty VM cache")); |
0 | 347 |
else |
348 |
test.Next(_L("Changing size of full VM cache")); |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
349 |
|
0 | 350 |
TInt i=0; |
351 |
while(testArgs[i].iResult!=KMaxTInt) |
|
352 |
{ |
|
353 |
TUint min=testArgs[i].iMinPages*PageSize; |
|
354 |
TUint max=testArgs[i].iMaxPages*PageSize; |
|
355 |
TInt result=testArgs[i].iResult; |
|
356 |
||
357 |
if(!j) |
|
358 |
DPTest::FlushCache(); |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
else |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
360 |
ThrashPaging(max); |
0 | 361 |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
362 |
DoResizeCache(min, max, result, sizeMin, sizeMax, originalMin, originalMax); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
363 |
|
0 | 364 |
++i; |
365 |
} |
|
366 |
} |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
367 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
368 |
test_KErrNone(SetCacheSize(originalMin, originalMax)); |
0 | 369 |
test.End(); |
370 |
} |
|
371 |
||
372 |
void TestResizeVMCache2() |
|
373 |
{ |
|
374 |
TUint originalMin = 0; |
|
375 |
TUint originalMax = 0; |
|
376 |
TUint currentSize = 0; |
|
377 |
test_KErrNone(DPTest::CacheSize(originalMax, originalMax, currentSize)); |
|
378 |
test_KErrNone(DPTest::SetCacheSize(1, originalMax)); |
|
379 |
TUint sizeMin = 0; |
|
380 |
TUint sizeMax = 0; |
|
381 |
test_KErrNone(DPTest::CacheSize(sizeMin, sizeMax, currentSize)); |
|
382 |
test(sizeMin > 1); |
|
383 |
test_KErrNone(DPTest::SetCacheSize(originalMin, originalMax)); |
|
384 |
} |
|
385 |
||
386 |
||
387 |
void TestHAL() |
|
388 |
{ |
|
389 |
test.Start(_L("DPTest::Attributes")); |
|
390 |
TUint32 attr=DPTest::Attributes(); |
|
391 |
test.Printf(_L("Attributes = %08x\n"),attr); |
|
392 |
||
393 |
test.Next(_L("DPTest::FlushCache")); |
|
394 |
TInt r=DPTest::FlushCache(); |
|
395 |
if(r==KErrNotSupported) |
|
396 |
test.Printf(_L("Not Supported\n")); |
|
397 |
else if(r<0) |
|
398 |
{ |
|
399 |
test.Printf(_L("Error = %d\n"),r); |
|
400 |
test(0); |
|
401 |
} |
|
402 |
||
403 |
test.Next(_L("DPTest::CacheSize")); |
|
404 |
TUint oldMin = 0; |
|
405 |
TUint oldMax = 0; |
|
406 |
TUint currentSize = 0; |
|
407 |
r=DPTest::CacheSize(oldMin,oldMax,currentSize); |
|
408 |
if(r==KErrNotSupported) |
|
409 |
test.Printf(_L("Not Supported\n")); |
|
410 |
else if(r<0) |
|
411 |
{ |
|
412 |
test.Printf(_L("Error = %d\n"),r); |
|
413 |
test(0); |
|
414 |
} |
|
415 |
else |
|
416 |
{ |
|
417 |
test.Printf(_L("Size = %dk,%dk,%dk\n"),oldMin>>10,oldMax>>10,currentSize>>10); |
|
418 |
} |
|
419 |
||
420 |
test.Next(_L("DPTest::SetCacheSize")); |
|
421 |
r=DPTest::SetCacheSize(oldMin,oldMax); |
|
422 |
if(r==KErrNotSupported) |
|
423 |
test.Printf(_L("Not Supported\n")); |
|
424 |
else if(r<0) |
|
425 |
{ |
|
426 |
test.Printf(_L("Error = %d\n"),r); |
|
427 |
test(0); |
|
428 |
} |
|
429 |
if(r==KErrNone) |
|
430 |
{ |
|
431 |
TestResizeVMCache(); |
|
432 |
TestResizeVMCache2(); |
|
433 |
} |
|
434 |
||
435 |
test.End(); |
|
436 |
} |
|
437 |
||
438 |
// Test IPC and realtime state |
|
439 |
||
440 |
enum TIpcDir |
|
441 |
{ |
|
442 |
EServerRead, |
|
443 |
EServerWrite |
|
444 |
}; |
|
445 |
||
446 |
enum TIpcObjectPaged |
|
447 |
{ |
|
448 |
ENothingPaged, |
|
449 |
EDesHeaderPaged, |
|
450 |
EDesContentPaged |
|
451 |
}; |
|
452 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
453 |
enum TThreadOutcome |
0 | 454 |
{ |
455 |
ENoError, |
|
456 |
EBadDescriptor, |
|
457 |
EServerTerminated, |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
458 |
ERealtimePanic, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
459 |
EAbortPanic |
0 | 460 |
}; |
461 |
||
462 |
class RTestSession : public RSessionBase |
|
463 |
{ |
|
464 |
public: |
|
465 |
TInt Create(RServer2 aServer) |
|
466 |
{ |
|
467 |
return CreateSession(aServer,TVersion(),-1); |
|
468 |
} |
|
469 |
inline TInt Send(const TIpcArgs& aArgs) |
|
470 |
{ |
|
471 |
return RSessionBase::SendReceive(0,aArgs); |
|
472 |
} |
|
473 |
}; |
|
474 |
||
475 |
RServer2 TestServer; |
|
476 |
||
477 |
TInt IpcTestServerFunc(TAny* aArg) |
|
478 |
{ |
|
479 |
TIpcDir dir = (TIpcDir)(((TInt)aArg) & 0xff); |
|
480 |
TIpcObjectPaged paged = (TIpcObjectPaged)((((TInt)aArg) >> 8) & 0xff); |
|
481 |
User::TRealtimeState realtime = (User::TRealtimeState)((((TInt)aArg) >> 16) & 0xff); |
|
482 |
User::TRealtimeState clientRealtime = (User::TRealtimeState)((((TInt)aArg) >> 24) & 0xff); |
|
483 |
||
484 |
TInt r; |
|
485 |
// We want the server to fault the client when it is realtime |
|
486 |
// and accessing paged out memory. |
|
487 |
r = TestServer.CreateGlobal(KNullDesC, EIpcSession_Sharable, EServerRole_Default, EServerOpt_PinClientDescriptorsDisable); |
|
488 |
if (r != KErrNone) |
|
489 |
return r; |
|
490 |
RThread::Rendezvous(KErrNone); |
|
491 |
||
492 |
RMessage2 message; |
|
493 |
TestServer.Receive(message); |
|
494 |
if ((clientRealtime == User::ERealtimeStateOn) != message.ClientIsRealtime()) |
|
495 |
return KErrGeneral; |
|
496 |
message.Complete(KErrNone); // complete connection request |
|
497 |
||
498 |
TRequestStatus s; |
|
499 |
TestServer.Receive(message,s); |
|
500 |
User::WaitForRequest(s); |
|
501 |
if (s != KErrNone) |
|
502 |
return s.Int(); |
|
503 |
||
504 |
TInt32 unpagedContent; |
|
505 |
TPtr8 unpagedDes((TUint8*)&unpagedContent, 4, 4); |
|
506 |
TPtrC8 pagedContentBuf(SmallBuffer,sizeof(TInt)); |
|
507 |
||
508 |
TPtr8* dataPagedHeaderDes = (TPtr8*)DataPagedBuffer; |
|
509 |
if (DataPagingSupported) |
|
510 |
new (dataPagedHeaderDes) TPtr8((TUint8*)&unpagedContent, 4); |
|
511 |
||
512 |
TPtr8 dataPagedContentDes(DataPagedBuffer + PageSize, 4); |
|
513 |
||
514 |
r = DPTest::FlushCache(); |
|
515 |
if(r != KErrNone) |
|
516 |
return r; |
|
517 |
||
518 |
User::SetRealtimeState(realtime); |
|
519 |
if (dir == EServerRead) |
|
520 |
{ |
|
521 |
switch (paged) |
|
522 |
{ |
|
523 |
case ENothingPaged: |
|
524 |
r = message.Read(0,unpagedDes); |
|
525 |
break; |
|
526 |
||
527 |
case EDesHeaderPaged: |
|
528 |
r = DataPagingSupported ? message.Read(0,*dataPagedHeaderDes) : KErrNotSupported; |
|
529 |
break; |
|
530 |
||
531 |
case EDesContentPaged: |
|
532 |
r = DataPagingSupported ? message.Read(0,dataPagedContentDes) : KErrNotSupported; |
|
533 |
break; |
|
534 |
||
535 |
default: |
|
536 |
r = KErrArgument; |
|
537 |
break; |
|
538 |
} |
|
539 |
} |
|
540 |
else if (dir == EServerWrite) |
|
541 |
{ |
|
542 |
switch (paged) |
|
543 |
{ |
|
544 |
case ENothingPaged: |
|
545 |
r = message.Write(0,unpagedDes); |
|
546 |
break; |
|
547 |
||
548 |
case EDesHeaderPaged: |
|
549 |
r = message.Write(0,*PagedHeaderDes); |
|
550 |
break; |
|
551 |
||
552 |
case EDesContentPaged: |
|
553 |
r = message.Write(0,pagedContentBuf); |
|
554 |
break; |
|
555 |
||
556 |
default: |
|
557 |
r = KErrArgument; |
|
558 |
break; |
|
559 |
} |
|
560 |
} |
|
561 |
else |
|
562 |
r = KErrArgument; |
|
563 |
User::SetRealtimeState(User::ERealtimeStateOff); |
|
564 |
||
565 |
message.Complete(KErrNone); |
|
566 |
return r; |
|
567 |
} |
|
568 |
||
569 |
TInt IpcTestClientFunc(TAny* aArg) |
|
570 |
{ |
|
571 |
TIpcDir dir = (TIpcDir)(((TInt)aArg) & 0xff); |
|
572 |
TIpcObjectPaged paged = (TIpcObjectPaged)((((TInt)aArg) >> 8) & 0xff); |
|
573 |
User::TRealtimeState realtime = (User::TRealtimeState)((((TInt)aArg) >> 16) & 0xff); |
|
574 |
||
575 |
RTestSession session; |
|
576 |
TInt r = session.Create(TestServer); |
|
577 |
if(r != KErrNone) |
|
578 |
return r; |
|
579 |
||
580 |
TInt32 unpagedContent; |
|
581 |
TPtr8 unpagedDes((TUint8*)&unpagedContent, 4, 4); |
|
582 |
TPtrC8 pagedContentBuf(SmallBuffer + PageSize, sizeof(TInt)); |
|
583 |
||
584 |
TPtr8* dataPagedHeaderDes = (TPtr8*)(DataPagedBuffer + (2 * PageSize)); |
|
585 |
if (DataPagingSupported) |
|
586 |
new (dataPagedHeaderDes) TPtr8((TUint8*)&unpagedContent, 4); |
|
587 |
||
588 |
TPtr8 dataPagedContentDes(DataPagedBuffer + (3 * PageSize), 4); |
|
589 |
||
590 |
r = DPTest::FlushCache(); |
|
591 |
if(r != KErrNone) |
|
592 |
return r; |
|
593 |
||
594 |
User::SetRealtimeState(realtime); |
|
595 |
if (dir == EServerRead) |
|
596 |
{ |
|
597 |
switch (paged) |
|
598 |
{ |
|
599 |
case ENothingPaged: |
|
600 |
r = session.Send(TIpcArgs(&unpagedDes)); |
|
601 |
break; |
|
602 |
||
603 |
case EDesHeaderPaged: |
|
604 |
r = session.Send(TIpcArgs(PagedHeaderDes)); |
|
605 |
break; |
|
606 |
||
607 |
case EDesContentPaged: |
|
608 |
r = session.Send(TIpcArgs(&pagedContentBuf)); |
|
609 |
break; |
|
610 |
||
611 |
default: |
|
612 |
r = KErrArgument; |
|
613 |
break; |
|
614 |
} |
|
615 |
} |
|
616 |
else if (dir == EServerWrite) |
|
617 |
{ |
|
618 |
switch (paged) |
|
619 |
{ |
|
620 |
case ENothingPaged: |
|
621 |
r = session.Send(TIpcArgs(&unpagedDes)); |
|
622 |
break; |
|
623 |
||
624 |
case EDesHeaderPaged: |
|
625 |
r = DataPagingSupported ? session.Send(TIpcArgs(dataPagedHeaderDes)) : KErrNotSupported; |
|
626 |
break; |
|
627 |
||
628 |
case EDesContentPaged: |
|
629 |
r = DataPagingSupported ? session.Send(TIpcArgs(&dataPagedContentDes)) : KErrNotSupported; |
|
630 |
break; |
|
631 |
||
632 |
default: |
|
633 |
r = KErrArgument; |
|
634 |
break; |
|
635 |
} |
|
636 |
} |
|
637 |
else |
|
638 |
r = KErrArgument; |
|
639 |
User::SetRealtimeState(User::ERealtimeStateOff); |
|
640 |
||
641 |
session.Close(); |
|
642 |
return r; |
|
643 |
} |
|
644 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
645 |
void TestThreadOutcome(RThread aThread, TThreadOutcome aOutcome) |
0 | 646 |
{ |
647 |
switch(aOutcome) |
|
648 |
{ |
|
649 |
case ENoError: |
|
650 |
test_Equal(EExitKill, aThread.ExitType()); |
|
651 |
test_KErrNone(aThread.ExitReason()); |
|
652 |
break; |
|
653 |
||
654 |
case EBadDescriptor: |
|
655 |
test_Equal(EExitKill, aThread.ExitType()); |
|
656 |
test_Equal(KErrBadDescriptor, aThread.ExitReason()); |
|
657 |
break; |
|
658 |
||
659 |
case EServerTerminated: |
|
660 |
test_Equal(EExitKill, aThread.ExitType()); |
|
661 |
test_Equal(KErrServerTerminated, aThread.ExitReason()); |
|
662 |
break; |
|
663 |
||
664 |
case ERealtimePanic: |
|
665 |
test_Equal(EExitPanic, aThread.ExitType()); |
|
666 |
test(aThread.ExitCategory()==_L("KERN-EXEC")); |
|
667 |
test_Equal(EIllegalFunctionForRealtimeThread, aThread.ExitReason()); |
|
668 |
break; |
|
669 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
670 |
case EAbortPanic: |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
671 |
test_Equal(EExitPanic, aThread.ExitType()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
672 |
// category for paging errors tested elsewhere |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
673 |
test_Equal(KErrAbort, aThread.ExitReason()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
674 |
break; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
675 |
|
0 | 676 |
default: |
677 |
test(EFalse); |
|
678 |
} |
|
679 |
} |
|
680 |
||
681 |
void TestPagedIpc(TIpcDir aIpcDir, |
|
682 |
TIpcObjectPaged aClientPaged, |
|
683 |
TIpcObjectPaged aServerPaged, |
|
684 |
User::TRealtimeState aClientState, |
|
685 |
User::TRealtimeState aServerState, |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
686 |
TThreadOutcome aClientOutcome, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
687 |
TThreadOutcome aServerOutcome, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
688 |
TPagingErrorContext aSimulatedError = EPagingErrorContextNone) |
0 | 689 |
{ |
690 |
test.Printf(_L("TestPagedIpc %d %d %d %d %d %d %d\n"), aIpcDir, aClientPaged, aServerPaged, |
|
691 |
aClientState, aServerState, aClientOutcome, aServerOutcome); |
|
692 |
||
693 |
RThread serverThread; |
|
694 |
RThread clientThread; |
|
695 |
TRequestStatus serverStatus; |
|
696 |
TRequestStatus clientStatus; |
|
697 |
||
698 |
TInt serverArg = aIpcDir | (aServerPaged << 8) | (aServerState << 16) | (aClientState << 24); |
|
699 |
test_KErrNone(serverThread.Create(KNullDesC, &IpcTestServerFunc, 0x1000, NULL, (TAny*)serverArg)); |
|
700 |
TName name; |
|
701 |
name = serverThread.Name(); |
|
702 |
test.Printf(_L(" server: %S\n"), &name); |
|
703 |
serverThread.Rendezvous(serverStatus); |
|
704 |
serverThread.Resume(); |
|
705 |
User::WaitForRequest(serverStatus); |
|
706 |
test_KErrNone(serverStatus.Int()); |
|
707 |
serverThread.Logon(serverStatus); |
|
708 |
||
709 |
TInt clientArg = aIpcDir | (aClientPaged << 8) | (aClientState << 16); |
|
710 |
test_KErrNone(clientThread.Create(KNullDesC, &IpcTestClientFunc, 0x1000, NULL, (TAny*)clientArg)); |
|
711 |
name = clientThread.Name(); |
|
712 |
test.Printf(_L(" client: %S\n"), &name); |
|
713 |
clientThread.Logon(clientStatus); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
714 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
715 |
// set up simulated failure if specifed |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
716 |
if (aSimulatedError != EPagingErrorContextNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
717 |
test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalDebugSetFail, (TAny*)aSimulatedError, 0)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
718 |
|
0 | 719 |
clientThread.Resume(); |
720 |
||
721 |
User::WaitForRequest(serverStatus); |
|
722 |
test.Printf(_L(" server exit type is %d %d\n"), serverThread.ExitType(), serverThread.ExitReason()); |
|
723 |
TestServer.Close(); // because handle is process-relative, it's not closed if the server dies |
|
724 |
||
725 |
User::WaitForRequest(clientStatus); |
|
726 |
test.Printf(_L(" client exit type is %d %d\n"), clientThread.ExitType(), clientThread.ExitReason()); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
727 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
728 |
// cancel any simulated failure |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
729 |
if (aSimulatedError != EPagingErrorContextNone) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
730 |
test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalDebugSetFail, (TAny*)EPagingErrorContextNone, 0)); |
0 | 731 |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
732 |
TestThreadOutcome(serverThread, aServerOutcome); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
733 |
TestThreadOutcome(clientThread, aClientOutcome); |
0 | 734 |
|
735 |
CLOSE_AND_WAIT(serverThread); |
|
736 |
CLOSE_AND_WAIT(clientThread); |
|
737 |
} |
|
738 |
||
739 |
TInt TestThreadFunction(TAny* aType) |
|
740 |
{ |
|
741 |
// Ensure that pageable memory is paged out |
|
742 |
TInt r=DPTest::FlushCache(); |
|
743 |
if(r!=KErrNone) |
|
744 |
return r; |
|
745 |
||
746 |
// Access pageable data whilst thread is in specified realttime state. |
|
747 |
User::SetRealtimeState((User::TRealtimeState)(TInt)aType); |
|
748 |
READ(SmallBuffer); |
|
749 |
return KErrNone; |
|
750 |
} |
|
751 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
752 |
TInt RunTestThread(User::TRealtimeState aType, TThreadOutcome aOutcome) |
0 | 753 |
{ |
754 |
RThread thread; |
|
755 |
TInt r=thread.Create(KNullDesC, &TestThreadFunction, 0x1000, NULL, (TAny*)aType); |
|
756 |
if(r!=KErrNone) |
|
757 |
return r; |
|
758 |
TRequestStatus s; |
|
759 |
thread.Logon(s); |
|
760 |
if(s.Int()!=KRequestPending) |
|
761 |
return s.Int(); |
|
762 |
thread.Resume(); |
|
763 |
User::WaitForRequest(s); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
764 |
TestThreadOutcome(thread, aOutcome); |
0 | 765 |
CLOSE_AND_WAIT(thread); |
766 |
return KErrNone; |
|
767 |
} |
|
768 |
||
769 |
void TestRealtimeState() |
|
770 |
{ |
|
771 |
// make sure live list is big enough |
|
772 |
test(KErrNone==DPTest::SetCacheSize(256*PageSize,256*PageSize)); |
|
773 |
||
774 |
test.Start(_L("Enable KREALTIME tracing")); |
|
775 |
Ldd.SetRealtimeTrace(ETrue); |
|
776 |
||
777 |
test.Next(_L("Test ERealtimeStateOff")); |
|
778 |
RunTestThread(User::ERealtimeStateOff, ENoError); |
|
779 |
||
780 |
test.Next(_L("Test ERealtimeStateOn")); |
|
781 |
RunTestThread(User::ERealtimeStateOn, ERealtimePanic); |
|
782 |
||
783 |
test.Next(_L("Test ERealtimeStateWarn")); |
|
784 |
RunTestThread(User::ERealtimeStateWarn, ENoError); |
|
785 |
||
786 |
test.Next(_L("Test combinations of IPC with realtime state")); |
|
787 |
||
788 |
// ipc dir: client paged: server paged: client state: server state: client outcome: server outcome: |
|
789 |
TestPagedIpc(EServerRead, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
790 |
TestPagedIpc(EServerRead, EDesHeaderPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
791 |
TestPagedIpc(EServerRead, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
792 |
TestPagedIpc(EServerWrite, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
793 |
TestPagedIpc(EServerWrite, ENothingPaged, EDesHeaderPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
794 |
TestPagedIpc(EServerWrite, ENothingPaged, EDesContentPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
795 |
||
796 |
if (DataPagingSupported) |
|
797 |
{ |
|
798 |
TestPagedIpc(EServerRead, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
799 |
TestPagedIpc(EServerRead, ENothingPaged, EDesHeaderPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
800 |
TestPagedIpc(EServerRead, ENothingPaged, EDesContentPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
801 |
TestPagedIpc(EServerWrite, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
802 |
TestPagedIpc(EServerWrite, EDesHeaderPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
803 |
TestPagedIpc(EServerWrite, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, ENoError, ENoError); |
|
804 |
} |
|
805 |
||
806 |
TestPagedIpc(EServerRead, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
807 |
TestPagedIpc(EServerRead, EDesHeaderPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
808 |
TestPagedIpc(EServerRead, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
809 |
TestPagedIpc(EServerWrite, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
810 |
TestPagedIpc(EServerWrite, ENothingPaged, EDesHeaderPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
811 |
TestPagedIpc(EServerWrite, ENothingPaged, EDesContentPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
812 |
||
813 |
if (DataPagingSupported) |
|
814 |
{ |
|
815 |
TestPagedIpc(EServerRead, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
816 |
TestPagedIpc(EServerRead, ENothingPaged, EDesHeaderPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
817 |
TestPagedIpc(EServerRead, ENothingPaged, EDesContentPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
818 |
TestPagedIpc(EServerWrite, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
819 |
TestPagedIpc(EServerWrite, EDesHeaderPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
820 |
TestPagedIpc(EServerWrite, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateWarn, ENoError, ENoError); |
|
821 |
} |
|
822 |
||
823 |
TestPagedIpc(EServerRead, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ENoError, ENoError); |
|
824 |
TestPagedIpc(EServerRead, EDesHeaderPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ENoError, ENoError); |
|
825 |
TestPagedIpc(EServerRead, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ERealtimePanic, EBadDescriptor); |
|
826 |
TestPagedIpc(EServerWrite, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ENoError, ENoError); |
|
827 |
TestPagedIpc(EServerWrite, ENothingPaged, EDesHeaderPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, EServerTerminated, ERealtimePanic); |
|
828 |
TestPagedIpc(EServerWrite, ENothingPaged, EDesContentPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, EServerTerminated, ERealtimePanic); |
|
829 |
||
830 |
if (DataPagingSupported) |
|
831 |
{ |
|
832 |
TestPagedIpc(EServerRead, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ENoError, ENoError); |
|
833 |
TestPagedIpc(EServerRead, ENothingPaged, EDesHeaderPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, EServerTerminated, ERealtimePanic); |
|
834 |
TestPagedIpc(EServerRead, ENothingPaged, EDesContentPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, EServerTerminated, ERealtimePanic); |
|
835 |
TestPagedIpc(EServerWrite, ENothingPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ENoError, ENoError); |
|
836 |
TestPagedIpc(EServerWrite, EDesHeaderPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ENoError, ENoError); |
|
837 |
TestPagedIpc(EServerWrite, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOn, ERealtimePanic, EBadDescriptor); |
|
838 |
} |
|
839 |
||
840 |
test.End(); |
|
841 |
||
842 |
// retore size of live list |
|
843 |
test(KErrNone==DPTest::SetCacheSize(0,0)); |
|
844 |
} |
|
845 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
846 |
enum TPageFaultType |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
847 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
848 |
EPageFaultRomRead, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
849 |
EPageFaultCodeRead, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
850 |
EPageFaultDataRead, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
851 |
EPageFaultDataWrite, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
852 |
}; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
853 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
854 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
855 |
TInt TestPagingErrorThreadFunction(TAny* aArg) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
856 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
857 |
TUint8* ptr = (TUint8*)((TUint)aArg & ~1); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
858 |
TBool write = ((TUint)aArg & 1) != 0; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
859 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
860 |
if (write) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
861 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
862 |
WRITE(ptr); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
863 |
return DPTest::FlushCache(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
864 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
865 |
else |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
866 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
867 |
READ(ptr); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
868 |
return KErrNone; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
869 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
870 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
871 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
872 |
void TestPagingError(TPageFaultType aPageFaultType, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
873 |
TPagingErrorContext aSimulatedError, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
874 |
TExitType aExpectedExitType, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
875 |
const TDesC& aExpectedExitCategory, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
876 |
TInt aExpectedExitReason) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
877 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
878 |
test.Printf(_L("TestPagingError %d %d %d \"%S\" %d\n"), aPageFaultType, aSimulatedError, |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
879 |
aExpectedExitType, &aExpectedExitCategory, aExpectedExitReason); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
880 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
881 |
TUint8* ptr; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
882 |
TBool write; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
883 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
884 |
switch(aPageFaultType) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
885 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
886 |
case EPageFaultRomRead: ptr = RomPagedBuffer; write = EFalse; break; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
887 |
case EPageFaultCodeRead: ptr = CodePagedBuffer; write = EFalse; break; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
888 |
case EPageFaultDataRead: ptr = DataPagedBuffer; write = EFalse; break; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
889 |
case EPageFaultDataWrite: ptr = DataPagedBuffer; write = ETrue; break; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
890 |
default: test(EFalse); return; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
891 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
892 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
893 |
if (ptr == NULL) return; // specified type of paging is not enabled |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
894 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
895 |
if (write) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
896 |
READ(ptr); // ensure data to be written is paged in |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
897 |
else |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
898 |
test_KErrNone(DPTest::FlushCache()); // ensure data to be read is paged out |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
899 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
900 |
// set up simulated failure |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
901 |
test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalDebugSetFail, (TAny*)aSimulatedError, 0)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
902 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
903 |
RThread thread; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
904 |
TAny* arg = (TAny*)((TUint)ptr | (write ? 1 : 0)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
905 |
test_KErrNone(thread.Create(KNullDesC, &TestPagingErrorThreadFunction, 0x1000, NULL, arg)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
906 |
TRequestStatus s; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
907 |
thread.Logon(s); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
908 |
test_Equal(KRequestPending, s.Int()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
909 |
thread.Resume(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
910 |
User::WaitForRequest(s); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
911 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
912 |
// cancel any simulated failure |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
913 |
test_KErrNone(UserSvr::HalFunction(EHalGroupVM, EVMHalDebugSetFail, (TAny*)EPagingErrorContextNone, 0)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
914 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
915 |
TExitCategoryName exitCategory = thread.ExitCategory(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
916 |
test.Printf(_L(" thread exit type is %d \"%S\" %d\n"), |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
917 |
thread.ExitType(), &exitCategory, thread.ExitReason()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
918 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
919 |
test_Equal(aExpectedExitType, thread.ExitType()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
920 |
if (aExpectedExitType == EExitPanic) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
921 |
test_Equal(0, aExpectedExitCategory.Compare(exitCategory)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
922 |
test_Equal(aExpectedExitReason, thread.ExitReason()); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
923 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
924 |
CLOSE_AND_WAIT(thread); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
925 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
926 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
927 |
void CreateDataPagedChunk() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
928 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
929 |
TChunkCreateInfo createInfo; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
930 |
createInfo.SetNormal(KMinBufferSize, KMinBufferSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
931 |
createInfo.SetPaging(TChunkCreateInfo::EPaged); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
932 |
createInfo.SetOwner(EOwnerProcess); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
933 |
createInfo.SetGlobal(KChunkName); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
934 |
test_KErrNone(DataPagedChunk.Create(createInfo)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
935 |
test(DataPagedChunk.IsPaged()); // this is only ever called if data paging is supported |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
936 |
DataPagedBuffer = (TUint8*)DataPagedChunk.Base(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
937 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
938 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
939 |
void TestPagingErrors() |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
940 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
941 |
// test what happens when the paging system encounters errors such as failure when accessing |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
942 |
// media or decompressing paged data |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
943 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
944 |
// page fault type: simulated error: exit type: exit category: exit reason: |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
945 |
TestPagingError(EPageFaultRomRead, EPagingErrorContextNone, EExitKill, KNullDesC, KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
946 |
TestPagingError(EPageFaultRomRead, EPagingErrorContextRomRead, EExitPanic, _L("PAGED-ROM-READ"), KErrAbort); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
947 |
TestPagingError(EPageFaultRomRead, EPagingErrorContextRomDecompress, EExitPanic, _L("PAGED-ROM-COMP"), KErrAbort); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
948 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
949 |
TestPagingError(EPageFaultCodeRead, EPagingErrorContextNone, EExitKill, KNullDesC, KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
950 |
TestPagingError(EPageFaultCodeRead, EPagingErrorContextCodeRead, EExitPanic, _L("PAGED-CODE-READ"), KErrAbort); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
951 |
TestPagingError(EPageFaultCodeRead, EPagingErrorContextCodeDecompress, EExitPanic, _L("PAGED-CODE-COMP"), KErrAbort); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
952 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
953 |
if (DataPagedBuffer) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
954 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
955 |
// Note WDP write faults are only reported on the next read |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
956 |
WRITE(DataPagedBuffer); // ensure page is not blank and will be read from swap |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
957 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
958 |
// page fault type: simulated error: exit type: exit category: exit reason: |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
959 |
TestPagingError(EPageFaultDataRead, EPagingErrorContextNone, EExitKill, KNullDesC, KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
960 |
TestPagingError(EPageFaultDataRead, EPagingErrorContextDataRead, EExitPanic, _L("PAGED-DATA-READ"), KErrAbort); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
961 |
TestPagingError(EPageFaultDataWrite, EPagingErrorContextDataWrite, EExitKill, KNullDesC, KErrNone); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
962 |
TestPagingError(EPageFaultDataRead, EPagingErrorContextNone, EExitPanic, _L("PAGED-DATA-WRITE"), KErrAbort); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
963 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
964 |
// this will now always panic when we try to access the first page so destroy and re-create it |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
965 |
DataPagedChunk.Close(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
966 |
CreateDataPagedChunk(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
967 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
968 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
969 |
// test attribution of errors during IPC |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
970 |
TPagingErrorContext error; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
971 |
if (RomPagedBuffer) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
972 |
error = EPagingErrorContextRomRead; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
973 |
else if (CodePagedBuffer) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
974 |
error = EPagingErrorContextCodeRead; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
975 |
else |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
976 |
error = EPagingErrorContextDataRead; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
977 |
// ipc dir: client paged: server paged: client state: server state: client outcome: server outcome: |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
978 |
TestPagedIpc(EServerRead, EDesContentPaged, ENothingPaged, User::ERealtimeStateOff, User::ERealtimeStateOff, EAbortPanic, EBadDescriptor, error); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
979 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
980 |
|
0 | 981 |
void TestLock() |
982 |
{ |
|
983 |
// make sure live list is big enough |
|
984 |
test(KErrNone==DPTest::SetCacheSize(128 * PageSize, 256 * PageSize)); |
|
985 |
||
986 |
TInt r = Ldd.LockTest(SmallBuffer,SmallBufferSize); |
|
987 |
if(r==KErrNone) |
|
988 |
{ |
|
989 |
test.Next(_L("Lock Test again")); |
|
990 |
r = Ldd.LockTest(SmallBuffer,SmallBufferSize); |
|
991 |
} |
|
992 |
if(r) |
|
993 |
{ |
|
994 |
test.Printf(_L("failed at D_DEMANPAGING.CPP line %d\n"),r); |
|
995 |
test(0); |
|
996 |
} |
|
997 |
||
998 |
// restore live list to default size... |
|
999 |
test(KErrNone==DPTest::SetCacheSize(0,0)); |
|
1000 |
} |
|
1001 |
||
1002 |
const TInt KSmallPropertySize = 512; |
|
1003 |
const TInt KLargePropertySize = 16384; |
|
1004 |
||
1005 |
struct SSetPropertyInfo |
|
1006 |
{ |
|
1007 |
TUid iCategory; |
|
1008 |
TInt iKey; |
|
1009 |
TUint8* iData; |
|
1010 |
TInt iLength; |
|
1011 |
}; |
|
1012 |
||
1013 |
TInt SetPropertyThreadFunction(TAny* aArg) |
|
1014 |
{ |
|
1015 |
SSetPropertyInfo* info = (SSetPropertyInfo*)aArg; |
|
1016 |
TInt r; |
|
1017 |
r = DPTest::FlushCache(); |
|
1018 |
if (r != KErrNone) |
|
1019 |
return r; |
|
1020 |
TPtrC8 data(info->iData, info->iLength); |
|
1021 |
r = RProperty::Set(info->iCategory, info->iKey, data); |
|
1022 |
if (r != KErrNone) |
|
1023 |
return r; |
|
1024 |
RBuf8 buffer; |
|
1025 |
r = buffer.Create(KLargePropertySize); |
|
1026 |
if (r != KErrNone) |
|
1027 |
return r; |
|
1028 |
r = RProperty::Get(info->iCategory, info->iKey, buffer); |
|
1029 |
if (r == KErrNone && buffer != data) |
|
1030 |
r = KErrGeneral; |
|
1031 |
buffer.Close(); |
|
1032 |
return r; |
|
1033 |
} |
|
1034 |
||
1035 |
void TestPublishAndSubscribe() |
|
1036 |
{ |
|
1037 |
RProcess thisProcess; |
|
1038 |
TUid category = thisProcess.SecureId(); |
|
1039 |
||
1040 |
TSecurityPolicy alwaysPass(TSecurityPolicy::EAlwaysPass); |
|
1041 |
test(RProperty::Define(category, 0, RProperty::EByteArray, alwaysPass, alwaysPass) == KErrNone); |
|
1042 |
test(RProperty::Define(category, 1, RProperty::ELargeByteArray, alwaysPass, alwaysPass) == KErrNone); |
|
1043 |
||
1044 |
TPtrC8 smallData(SmallBuffer, KSmallPropertySize); |
|
1045 |
TPtrC8 largeData(SmallBuffer, KLargePropertySize); |
|
1046 |
||
1047 |
RBuf8 buffer; |
|
1048 |
test(buffer.Create(KLargePropertySize) == KErrNone); |
|
1049 |
||
1050 |
// Set small property from paged data, method 1 |
|
1051 |
test(DPTest::FlushCache() == KErrNone); |
|
1052 |
test(RProperty::Set(category, 0, smallData) == KErrNone); |
|
1053 |
test(RProperty::Get(category, 0, buffer) == KErrNone); |
|
1054 |
test(buffer == smallData); |
|
1055 |
||
1056 |
// Set small property from paged data, method 2 |
|
1057 |
RProperty smallProp; |
|
1058 |
test(smallProp.Attach(category, 0) == KErrNone); |
|
1059 |
test(DPTest::FlushCache() == KErrNone); |
|
1060 |
test(smallProp.Set(smallData) == KErrNone); |
|
1061 |
test(smallProp.Get(buffer) == KErrNone); |
|
1062 |
test(buffer == smallData); |
|
1063 |
||
1064 |
// Set large property from paged data, method 1 |
|
1065 |
test(DPTest::FlushCache() == KErrNone); |
|
1066 |
test(RProperty::Set(category, 1, largeData) == KErrNone); |
|
1067 |
test(RProperty::Get(category, 1, buffer) == KErrNone); |
|
1068 |
test(buffer == largeData); |
|
1069 |
||
1070 |
// Set large property from paged data, method 2 |
|
1071 |
RProperty largeProp; |
|
1072 |
test(largeProp.Attach(category, 1) == KErrNone); |
|
1073 |
test(DPTest::FlushCache() == KErrNone); |
|
1074 |
test(largeProp.Set(largeData) == KErrNone); |
|
1075 |
test(largeProp.Get(buffer) == KErrNone); |
|
1076 |
test(buffer == largeData); |
|
1077 |
||
1078 |
// Set small property from unmapped address |
|
1079 |
RThread thread; |
|
1080 |
#if !defined( __VC32__) |
|
1081 |
SSetPropertyInfo info = { category, 0, 0, KSmallPropertySize }; |
|
1082 |
#else |
|
1083 |
SSetPropertyInfo info = { category.iUid, 0, 0, KSmallPropertySize }; |
|
1084 |
#endif |
|
1085 |
test(thread.Create(_L("SetPropertyThread"), SetPropertyThreadFunction, 4096, NULL, &info) == KErrNone); |
|
1086 |
thread.Resume(); |
|
1087 |
TRequestStatus status; |
|
1088 |
thread.Logon(status); |
|
1089 |
User::WaitForRequest(status); |
|
1090 |
test(thread.ExitType()==EExitPanic); |
|
1091 |
test(thread.ExitCategory()==_L("KERN-EXEC")); |
|
1092 |
test(thread.ExitReason()==ECausedException); |
|
1093 |
thread.Close(); |
|
1094 |
||
1095 |
// Set large property from unmapped address |
|
1096 |
info.iKey = 1; |
|
1097 |
info.iLength = KLargePropertySize; |
|
1098 |
test(thread.Create(_L("SetPropertyThread"), SetPropertyThreadFunction, 4096, NULL, &info) == KErrNone); |
|
1099 |
thread.Resume(); |
|
1100 |
thread.Logon(status); |
|
1101 |
User::WaitForRequest(status); |
|
1102 |
test(thread.ExitType()==EExitPanic); |
|
1103 |
test(thread.ExitCategory()==_L("KERN-EXEC")); |
|
1104 |
test(thread.ExitReason()==ECausedException); |
|
1105 |
thread.Close(); |
|
1106 |
||
1107 |
test(RProperty::Delete(category, 0) == KErrNone); |
|
1108 |
test(RProperty::Delete(category, 1) == KErrNone); |
|
1109 |
} |
|
1110 |
||
1111 |
void TestWriteToPagedArea() |
|
1112 |
{ |
|
1113 |
RMemoryTestLdd memoryTest; |
|
1114 |
test(KErrNone==memoryTest.Open()); |
|
1115 |
||
1116 |
TModuleMemoryInfo exeInfo; |
|
1117 |
test(KErrNone==RProcess().GetMemoryInfo(exeInfo)); |
|
1118 |
test.Printf(_L("test program code is %x+%x"),exeInfo.iCodeBase,exeInfo.iCodeSize); |
|
1119 |
||
1120 |
TUint8* ptr = const_cast<TUint8*>(LargeBuffer); |
|
1121 |
TUint8* end = ptr + LargeBufferSize; |
|
1122 |
while(ptr<end) |
|
1123 |
{ |
|
1124 |
if(ptr>=(TUint8*)_ALIGN_DOWN(exeInfo.iCodeBase,PageSize) && ptr<(TUint8*)_ALIGN_UP(exeInfo.iCodeBase+exeInfo.iCodeSize,PageSize)) |
|
1125 |
{ |
|
1126 |
// avoid testing the ROM which contains this test program |
|
1127 |
ptr += PageSize; |
|
1128 |
continue; |
|
1129 |
} |
|
1130 |
||
1131 |
DPTest::FlushCache(); |
|
1132 |
||
1133 |
TInt stateBits = UserSvr::HalFunction(EHalGroupVM, EVMPageState, ptr, 0); |
|
1134 |
test(stateBits>=0); |
|
1135 |
// write to paged out memory should cause exception... |
|
1136 |
test(KErrBadDescriptor==memoryTest.WriteMemory(ptr,0)); |
|
1137 |
// page state should be unchanged... |
|
1138 |
TInt newStateBits = UserSvr::HalFunction(EHalGroupVM, EVMPageState, ptr, 0); |
|
1139 |
if(stateBits!=newStateBits) |
|
1140 |
{ |
|
1141 |
test.Printf(_L("ptr=%x stateBits=%x newStateBits=%x"),ptr,stateBits,newStateBits); |
|
1142 |
test(0); |
|
1143 |
} |
|
1144 |
// page-in in memory... |
|
1145 |
TUint32 value = *(TUint32*)ptr; |
|
1146 |
// write to paged out memory should still cause exception... |
|
1147 |
test(KErrBadDescriptor==memoryTest.WriteMemory(ptr,~value)); |
|
1148 |
// memory should be unchanged... |
|
1149 |
test(value==*(TUint32*)ptr); |
|
1150 |
ptr += PageSize; |
|
1151 |
} |
|
1152 |
||
1153 |
memoryTest.Close(); |
|
1154 |
} |
|
1155 |
||
1156 |
void TestContiguousRamAlloc() |
|
1157 |
{ |
|
1158 |
test.Start(_L("Start...")); |
|
1159 |
||
1160 |
const TInt KCacheSize = 1024*1024; |
|
1161 |
||
1162 |
DPTest::SetCacheSize(0, KCacheSize); // make sure paging cache is a reasonable size |
|
1163 |
||
1164 |
TInt testData[][2] = /* array of page size (in units of 'half pages') and align values */ |
|
1165 |
{ |
|
1166 |
{64,5}, |
|
1167 |
{64,0}, |
|
1168 |
{32,4}, |
|
1169 |
{32,3}, |
|
1170 |
{32,2}, |
|
1171 |
{32,1}, |
|
1172 |
{32,0}, |
|
1173 |
{4,2}, |
|
1174 |
{4,1}, |
|
1175 |
{4,0}, |
|
1176 |
{2,2}, |
|
1177 |
{2,1}, |
|
1178 |
{2,0}, |
|
1179 |
{1,0}, |
|
1180 |
{0,0} |
|
1181 |
}; |
|
1182 |
TInt pageShift = 1; |
|
1183 |
while((1<<pageShift)<PageSize) |
|
1184 |
++pageShift; |
|
1185 |
||
1186 |
TInt* params = (TInt*)&testData; |
|
1187 |
while(*params) |
|
1188 |
{ |
|
1189 |
TInt size = *params++<<(pageShift-1); //Size is units of half pages, so one less shift to get required memory size |
|
1190 |
TInt align = *params++; |
|
1191 |
if(align) |
|
1192 |
align += pageShift - 1; |
|
1193 |
TBuf<256> title; |
|
1194 |
title.AppendFormat(_L("Contiguous RAM test: alloc size = %dK align = %d"),size>>10, align); |
|
1195 |
test.Next(title); |
|
1196 |
FragmentPagingCache(KCacheSize); |
|
1197 |
TInt r = Ldd.DoConsumeContiguousRamTest(align, size); |
|
1198 |
if(r) |
|
1199 |
{ |
|
1200 |
test.Printf(_L("failed at D_DEMANPAGING.CPP line %d\n"),r); |
|
1201 |
test(0); |
|
1202 |
} |
|
1203 |
} |
|
1204 |
||
1205 |
DPTest::SetCacheSize(0,0); // back to defaults |
|
1206 |
test.End(); |
|
1207 |
} |
|
1208 |
||
1209 |
void TestReadHoldingMutex() |
|
1210 |
{ |
|
1211 |
TUint8 localBuf[16]; |
|
1212 |
TUint8* localPtr = localBuf; |
|
1213 |
if(DPTest::Attributes() & DPTest::EDataPaging) // if data paging supported... |
|
1214 |
localPtr = 0; // use zero to make driver use kernel memory as data destination |
|
1215 |
test(Ldd.ReadHoldingMutexTest(localPtr) == KErrNone); |
|
1216 |
} |
|
1217 |
||
1218 |
#if 0 // rom dump code... |
|
1219 |
#include <f32file.h> |
|
1220 |
RFs fs; |
|
1221 |
RFile file; |
|
1222 |
test(KErrNone==fs.Connect()); |
|
1223 |
test(KErrNone==file.Replace(fs, _L("d:\\ROMDUMP"),EFileWrite)); |
|
1224 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
|
1225 |
TPtrC8 rom((TUint8*)romHeader,romHeader->iRomSize); |
|
1226 |
test(KErrNone==file.Write(rom)); |
|
1227 |
file.Close(); |
|
1228 |
fs.Close(); |
|
1229 |
return 0; |
|
1230 |
#endif |
|
1231 |
||
1232 |
||
1233 |
class RMySession : public RSessionBase |
|
1234 |
{ |
|
1235 |
public: |
|
1236 |
TInt Connect(RServer2 aSrv,TRequestStatus& aStat) |
|
1237 |
{ |
|
1238 |
TInt r=CreateSession(aSrv,TVersion(),-1,EIpcSession_Sharable,NULL,&aStat); |
|
1239 |
if(!r) ShareAuto(); return r; |
|
1240 |
} |
|
1241 |
TInt Send(TInt function,const TIpcArgs& args) |
|
1242 |
{return SendReceive(function,args);} |
|
1243 |
}; |
|
1244 |
||
1245 |
||
1246 |
TUint8* TestBuffer = 0; |
|
1247 |
RMySession MySession; |
|
1248 |
||
1249 |
LOCAL_C TInt TestServerThread(TAny* aSize) |
|
1250 |
{ |
|
1251 |
TInt r = TestServer.CreateGlobal(KNullDesC, EIpcSession_GlobalSharable); |
|
1252 |
if(r==KErrNone) |
|
1253 |
{ |
|
1254 |
TestBuffer = (TUint8*)User::Alloc(KMaxIPCSize); |
|
1255 |
if(!TestBuffer) |
|
1256 |
r = KErrNoMemory; |
|
1257 |
} |
|
1258 |
TPtr8 buffer(TestBuffer,KMaxIPCSize); |
|
1259 |
RThread::Rendezvous(r); |
|
1260 |
if (r != KErrNone) |
|
1261 |
return r; |
|
1262 |
||
1263 |
RMessage2 m; |
|
1264 |
TestServer.Receive(m); |
|
1265 |
m.Complete(KErrNone); // connect message |
|
1266 |
||
1267 |
TBool running = ETrue; |
|
1268 |
while (running) |
|
1269 |
{ |
|
1270 |
TestServer.Receive(m); |
|
1271 |
RDebug::Printf("Server received: %d", m.Function()); |
|
1272 |
||
1273 |
TInt r = KErrNone; |
|
1274 |
switch(m.Function()) |
|
1275 |
{ |
|
1276 |
case 0: |
|
1277 |
// Kill server |
|
1278 |
running = EFalse; |
|
1279 |
break; |
|
1280 |
||
1281 |
case 2: |
|
1282 |
buffer.Set(SharedBuffer,KMaxIPCSize,KMaxIPCSize); |
|
1283 |
// fall through... |
|
1284 |
case 1: |
|
1285 |
// Perform CRC of data passed |
|
1286 |
{ |
|
1287 |
DPTest::FlushCache(); |
|
1288 |
r=m.Read(0,buffer); |
|
1289 |
if (r!=KErrNone) |
|
1290 |
break; |
|
1291 |
TUint32 crc=0; |
|
1292 |
Mem::Crc32(crc,buffer.Ptr(),buffer.Size()); |
|
1293 |
r = crc; |
|
1294 |
} |
|
1295 |
break; |
|
1296 |
||
1297 |
case 4: |
|
1298 |
buffer.Set(SharedBuffer,KMaxIPCSize,KMaxIPCSize); |
|
1299 |
// fall through... |
|
1300 |
case 3: |
|
1301 |
// Write data to client descriptor |
|
1302 |
{ |
|
1303 |
DPTest::FlushCache(); |
|
1304 |
RDebug::Printf("Server writing %08x+%x", m.Int1(), m.Int2()); |
|
1305 |
TPtrC8 ptr((TUint8*)m.Int1(),m.Int2()); |
|
1306 |
r=m.Write(0,ptr); |
|
1307 |
} |
|
1308 |
break; |
|
1309 |
||
1310 |
default: |
|
1311 |
// Just complete anything else |
|
1312 |
break; |
|
1313 |
} |
|
1314 |
m.Complete(r); |
|
1315 |
} |
|
1316 |
||
1317 |
RDebug::Printf("Server exiting"); |
|
1318 |
User::Free(TestBuffer); |
|
1319 |
TestBuffer = NULL; |
|
1320 |
TestServer.Close(); |
|
1321 |
return KErrNone; |
|
1322 |
} |
|
1323 |
||
1324 |
void TestIPC() |
|
1325 |
{ |
|
1326 |
__KHEAP_MARK; |
|
1327 |
||
1328 |
const TUint8* start = LargeBuffer + 0x3df; // make range not page aligned |
|
1329 |
const TUint8* end = start + Min(LargeBufferSize, KMaxIPCSize * 10) - 0x130; // make range not page aligned |
|
1330 |
const TUint8* pos; |
|
1331 |
||
1332 |
test.Start(_L("Create server")); |
|
1333 |
RThread t; |
|
1334 |
TInt r=t.Create(KNullDesC,TestServerThread,0x1000,KMaxIPCSize+0x1000,KMaxIPCSize+0x1000,(void*)0); |
|
1335 |
test(r==KErrNone); |
|
1336 |
t.SetPriority(EPriorityMore); |
|
1337 |
TRequestStatus s; |
|
1338 |
t.Rendezvous(s); |
|
1339 |
t.Resume(); |
|
1340 |
User::WaitForRequest(s); |
|
1341 |
test(TestServer.Handle() != KNullHandle); |
|
1342 |
||
1343 |
test(MySession.Connect(TestServer,s) == KErrNone); |
|
1344 |
User::WaitForRequest(s); // connected |
|
1345 |
||
1346 |
TInt bufferType; // 0=server uses heap, 1=server uses SharedBuffer |
|
1347 |
for(bufferType=0; bufferType<=1; ++bufferType) |
|
1348 |
{ |
|
1349 |
test.Next(_L("IPC read from ROM")); |
|
1350 |
pos = start; |
|
1351 |
while(pos<end) |
|
1352 |
{ |
|
1353 |
TInt size = end-pos; |
|
1354 |
if(size>KMaxIPCSize) |
|
1355 |
size = KMaxIPCSize; |
|
1356 |
RDebug::Printf("read %x+%x",pos,size); |
|
1357 |
TPtrC8 ptr(pos,size); |
|
1358 |
TInt r = MySession.Send(1+bufferType,TIpcArgs(&ptr)); |
|
1359 |
DPTest::FlushCache(); |
|
1360 |
TUint32 crc=0; |
|
1361 |
Mem::Crc32(crc,pos,size); |
|
1362 |
RDebug::Printf("crc %08x %08x",r,crc); |
|
1363 |
if((TUint32)r!=crc) |
|
1364 |
{ |
|
1365 |
RDebug::Printf("FAIL"); |
|
1366 |
DPTest::FlushCache(); |
|
1367 |
TInt count = 0; |
|
1368 |
for(TInt i=0; i<size; i+=4) |
|
1369 |
{ |
|
1370 |
TUint32 a = pos[i]; |
|
1371 |
TUint32 b = TestBuffer[i]; |
|
1372 |
if(a!=b) |
|
1373 |
RDebug::Printf("%08x %02x!=%02x",pos+i,a,b); |
|
1374 |
if (++count > 100) |
|
1375 |
break; |
|
1376 |
} |
|
1377 |
} |
|
1378 |
test((TUint32)r==crc); |
|
1379 |
pos+=size; |
|
1380 |
} |
|
1381 |
||
1382 |
test.Next(_L("IPC write from ROM")); |
|
1383 |
pos = start; |
|
1384 |
while(pos<end) |
|
1385 |
{ |
|
1386 |
TInt size = end-pos; |
|
1387 |
if(size>KMaxIPCSize) |
|
1388 |
size = KMaxIPCSize; |
|
1389 |
RDebug::Printf("write %x+%x",pos,size); |
|
1390 |
memclr(TestBuffer, KMaxIPCSize); |
|
1391 |
TPtr8 ptr(TestBuffer,KMaxIPCSize); // reuse the server's buffer |
|
1392 |
TInt r = MySession.Send(3+bufferType,TIpcArgs(&ptr,pos,size)); |
|
1393 |
test_KErrNone(r); |
|
1394 |
DPTest::FlushCache(); |
|
1395 |
TUint32 crc=0; |
|
1396 |
Mem::Crc32(crc,pos,size); |
|
1397 |
TUint32 crc2=0; |
|
1398 |
Mem::Crc32(crc2,TestBuffer,size); |
|
1399 |
RDebug::Printf("crc %08x %08x",crc,crc2); |
|
1400 |
if((TUint32)crc!=crc2) |
|
1401 |
{ |
|
1402 |
RDebug::Printf("FAIL"); |
|
1403 |
DPTest::FlushCache(); |
|
1404 |
TInt count = 0; |
|
1405 |
for(TInt i=0; i<size; i+=4) |
|
1406 |
{ |
|
1407 |
TUint32 a = pos[i]; |
|
1408 |
TUint32 b = TestBuffer[i]; |
|
1409 |
if(a!=b) |
|
1410 |
RDebug::Printf("%08x %02x!=%02x",pos+i,a,b); |
|
1411 |
if (++count > 100) |
|
1412 |
break; |
|
1413 |
} |
|
1414 |
} |
|
1415 |
test((TUint32)crc==crc2); |
|
1416 |
pos+=size; |
|
1417 |
} |
|
1418 |
} |
|
1419 |
||
1420 |
if (DPTest::Attributes() & DPTest::ERomPaging) |
|
1421 |
{ |
|
1422 |
test.Next(_L("Test passing descriptor headers in paged-out memory")); |
|
1423 |
__KHEAP_MARK; |
|
1424 |
||
1425 |
DPTest::FlushCache(); |
|
1426 |
TInt r = MySession.Send(5,TIpcArgs(PagedHeaderDes)); |
|
1427 |
test_Equal(KErrNone, r); |
|
1428 |
||
1429 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
1430 |
__KHEAP_MARKEND; |
|
1431 |
} |
|
1432 |
||
1433 |
test.Next(_L("Stop server")); |
|
1434 |
MySession.Send(0,TIpcArgs(0)); |
|
1435 |
MySession.Close(); |
|
1436 |
t.Logon(s); |
|
1437 |
User::WaitForRequest(s); |
|
1438 |
test_Equal(EExitKill, t.ExitType()); |
|
1439 |
test_Equal(KErrNone, t.ExitReason()); |
|
1440 |
CLOSE_AND_WAIT(t); |
|
1441 |
test.End(); |
|
1442 |
||
1443 |
UserSvr::HalFunction(EHalGroupKernel, EKernelHalSupervisorBarrier, 0, 0); |
|
1444 |
__KHEAP_MARKEND; |
|
1445 |
} |
|
1446 |
||
1447 |
||
1448 |
TInt E32Main() |
|
1449 |
{ |
|
1450 |
test.Title(); |
|
1451 |
||
1452 |
test_KErrNone(UserSvr::HalFunction(EHalGroupKernel,EKernelHalPageSizeInBytes,&PageSize,0)); |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1453 |
|
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1454 |
test.Start(_L("Initialisation")); |
0 | 1455 |
|
1456 |
if (DPTest::Attributes() & DPTest::ERomPaging) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1457 |
{ |
0 | 1458 |
test.Printf(_L("Rom paging supported\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1459 |
TRomHeader* romHeader = (TRomHeader*)UserSvr::RomHeaderAddress(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1460 |
test(romHeader->iPageableRomStart); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1461 |
// todo: for some reason the first part of page of paged rom doesn't seem to get paged out |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1462 |
// when we flush the paging cache, hence RomPagedBuffer starts some way into this |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1463 |
RomPagedBuffer = (TUint8*)romHeader + romHeader->iPageableRomStart + 64 * PageSize; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1464 |
RomPagedBufferSize = romHeader->iPageableRomSize - 64 * PageSize; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1465 |
test(RomPagedBufferSize > 0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1466 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1467 |
|
0 | 1468 |
if (DPTest::Attributes() & DPTest::ECodePaging) |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1469 |
{ |
0 | 1470 |
test.Printf(_L("Code paging supported\n")); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1471 |
test_KErrNone(PagedLibrary.Load(KTCodePagingDll4)); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1472 |
TGetAddressOfDataFunction func = (TGetAddressOfDataFunction)PagedLibrary.Lookup(KGetAddressOfDataFunctionOrdinal); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1473 |
CodePagedBuffer = (TUint8*)func(CodePagedBufferSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1474 |
test_NotNull(CodePagedBuffer); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1475 |
test(CodePagedBufferSize > KMinBufferSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1476 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1477 |
|
0 | 1478 |
if (DPTest::Attributes() & DPTest::EDataPaging) |
1479 |
{ |
|
1480 |
test.Printf(_L("Data paging supported\n")); |
|
1481 |
DataPagingSupported = ETrue; |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1482 |
CreateDataPagedChunk(); |
0 | 1483 |
} |
1484 |
||
1485 |
if (DPTest::Attributes() & DPTest::ERomPaging) |
|
1486 |
{ |
|
1487 |
// Use paged part of rom for testing |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1488 |
LargeBuffer = RomPagedBuffer; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1489 |
LargeBufferSize = RomPagedBufferSize; |
0 | 1490 |
} |
1491 |
else if (DPTest::Attributes() & DPTest::ECodePaging) |
|
1492 |
{ |
|
1493 |
// Use code paged DLL for testing |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1494 |
LargeBuffer = CodePagedBuffer; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1495 |
LargeBufferSize = CodePagedBufferSize; |
0 | 1496 |
} |
1497 |
else if (DPTest::Attributes() & DPTest::EDataPaging) |
|
1498 |
{ |
|
1499 |
// Use data paged chunk for testing |
|
1500 |
LargeBuffer = DataPagedBuffer; |
|
1501 |
LargeBufferSize = KMinBufferSize; |
|
1502 |
} |
|
1503 |
else |
|
1504 |
{ |
|
1505 |
test.Printf(_L("Demand Paging not supported\n")); |
|
1506 |
test.End(); |
|
1507 |
return 0; |
|
1508 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1509 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1510 |
// Find a paged zero word to set PagedHeaderDes to |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1511 |
TUint* ptr = (TUint*)LargeBuffer; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1512 |
TUint* end = (TUint*)(LargeBuffer + LargeBufferSize); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1513 |
while (*ptr && ptr < end) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1514 |
++ptr; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1515 |
test(*ptr == 0); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1516 |
test.Printf(_L("Found zero word at %08x\n"), ptr); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1517 |
PagedHeaderDes = (TDesC8*)ptr; |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1518 |
|
28
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1519 |
test.Next(_L("Test HAL interface")); |
5b5d147c7838
Revision: 201021
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
1520 |
TestHAL(); |
0 | 1521 |
|
1522 |
test(LargeBufferSize >= KMinBufferSize); |
|
1523 |
SmallBuffer = LargeBuffer; |
|
1524 |
SmallBufferSize = KMinBufferSize; |
|
1525 |
||
1526 |
test.Next(_L("Loading test drivers")); |
|
1527 |
TInt r = User::LoadLogicalDevice(KDemandPagingTestLddName); |
|
1528 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
1529 |
test(Ldd.Open()==KErrNone); |
|
1530 |
||
1531 |
test_KErrNone(Ldd.CreatePlatHwChunk(SharedBufferSize, SharedBufferAddr)); |
|
1532 |
SharedBuffer = (TUint8*)SharedBufferAddr; |
|
1533 |
||
1534 |
RDebug::Printf("SmallBuffer=%x, LargeBuffer=%x, SharedBuffer=%x\n", |
|
1535 |
SmallBuffer, LargeBuffer, SharedBuffer); |
|
1536 |
||
1537 |
test.Next(_L("Gobble RAM")); |
|
1538 |
r = User::LoadLogicalDevice(KGobblerLddFileName); |
|
1539 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
1540 |
RGobbler gobbler; |
|
1541 |
r = gobbler.Open(); |
|
1542 |
test(r==KErrNone); |
|
1543 |
TUint32 taken = gobbler.GobbleRAM(64*1024*1024); // leave 64MB of free RAM |
|
1544 |
test.Printf(_L("Gobbled: %dK\n"), taken/1024); |
|
1545 |
test.Printf(_L("Free RAM 0x%08X bytes\n"),FreeRam()); |
|
1546 |
||
1547 |
test.Next(_L("Test contiguous RAM allocation reclaims paged memory")); |
|
1548 |
TestContiguousRamAlloc(); |
|
1549 |
||
1550 |
test.Next(_L("Test thread realtime state")); |
|
1551 |
TestRealtimeState(); |
|
1552 |
||
1553 |
test.Next(_L("Lock Test")); |
|
1554 |
TestLock(); |
|
1555 |
||
1556 |
test.Next(_L("Test writing to paged area")); |
|
1557 |
TestWriteToPagedArea(); |
|
1558 |
||
1559 |
test.Next(_L("Test IPC read from paged memory")); |
|
1560 |
TestIPC(); |
|
1561 |
||
1562 |
test.Next(_L("Test no kernel faults when copying data from unpaged rom with mutex held")); |
|
1563 |
TestReadHoldingMutex(); |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1564 |
|
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1565 |
#ifdef _DEBUG |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1566 |
// test hook in kernel not present in release mode |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1567 |
if ((MemModelAttributes() & EMemModelTypeMask) == EMemModelTypeFlexible) |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1568 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1569 |
test.Next(_L("Test unrecoverable errors while paging")); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1570 |
TestPagingErrors(); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1571 |
} |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1572 |
#endif |
0 | 1573 |
|
1574 |
test.Next(_L("Close test driver")); |
|
1575 |
Ldd.DestroyPlatHwChunk(); |
|
1576 |
Ldd.Close(); |
|
1577 |
||
1578 |
test.Next(_L("Test setting publish and subscribe properties from paged area")); |
|
1579 |
TestPublishAndSubscribe(); |
|
1580 |
||
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1581 |
#ifndef _DEBUG |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1582 |
// no point benchmarking in debug mode |
0 | 1583 |
if (DPTest::Attributes() & DPTest::ERomPaging) |
1584 |
{ |
|
1585 |
test.Next(_L("Rom Paging Benchmark")); |
|
1586 |
RomPagingBenchmark(); |
|
1587 |
} |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
28
diff
changeset
|
1588 |
#endif |
0 | 1589 |
|
1590 |
PagedLibrary.Close(); |
|
1591 |
gobbler.Close(); |
|
1592 |
test.End(); |
|
1593 |
||
1594 |
return 0; |
|
1595 |
} |