Update contrib.
1 // Copyright (c) 2006-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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
14 // @SYMTestCaseID KBASE-DP_FUNC_ATTRIBUTES-0303
15 // @SYMTestCaseDesc Symbian OS Toolchain's Paging Override and the
16 // Paging Policy settings
19 // @SYMTestPriority High
21 // 1. Load executables with the RProcess API and run them. Each executable has a
22 // different set of attributes:
23 // " Paging attribute: paged, unpaged or no paging attribute in MMP and/or
25 // " Compression mode: specified or not
26 // " Executable built in ROM as 'data' or 'file'
27 // " Solid binaries or aliases
28 // Retrieve and analyse the demand paging activity trace caused by the preceding
29 // action, in order to determine whether this binary is paged on demand or not.
30 // 2. Repeat the preceding action by loading DLLs with the RLibrary API and
31 // making calls to them.
32 // @SYMTestExpectedResults
33 // 1. Process complete without error. If, according to the trace data gathered,
34 // the main thread newly created process causes the executable to be paged in,
35 // then it is a proof that the executable is paged. Depending on the Paging
36 // Override setting and the Loader Paging Policy specified at the time the ROM was
37 // built, the Loader makes a decision as to whether page the binary or not,
38 // according to the rules listed in the Design Sketch. This is how we determine
39 // this, in this order:
40 // a. If ROM paging is disabled: not paged
41 // b. If executable was built in ROM as 'data': not paged
42 // c. If the a file compression scheme was specified at ROM build time: not paged
43 // d. If the Loader Paging policy is 'NOT PAGED': not paged
44 // e. If the Loader Paging policy is 'ALWAYS PAGE': paged
45 // f. If the Paging Override is 'NOT PAGED': not paged
46 // g. If the Paging Override is 'ALWAYS PAGE': paged
47 // h. If the OBY paging keyword for this executable is 'PAGED': paged
48 // i. If the OBY paging keyword for this executable is 'NOT PAGED': unpaged
49 // j. If the MMP paging keyword for this executable is 'PAGED': paged
50 // k. If the MMP paging keyword for this executable is 'NOT PAGED': not paged
51 // l. If the Paging Override is 'DEFAULT UNPAGED': not paged
52 // m. If the Paging Override is 'DEFAULT PAGED': paged
53 // n. If the Paging Policy is 'DEFAULT UNPAGED': not paged
54 // o. The executable must be paged
55 // 2. DLL is loaded. Functions are called and complete without errors. The rules
56 // to determine whether the binary should be paged or not are the same as in the
63 #include <d32btrace.h>
68 #define TEST_EQ(a,b) { if (a != b) { test.Printf(_L("%d != %d\n"), a, b); test(EFalse); } }
69 #define TEST_CONDITION(a) { if (!a) { test.Printf(_L("TEST FAILED at line %d\n"), __LINE__); pass = EFalse; } }
70 #define LE4(a) ((TUint) (*((a) + 3) << 24) + (*((a) + 2) << 16) + (*((a) + 1) << 8) + *(a))
72 RTest test(_L("T_DPATTR"));
76 // ROM paging settings
77 TBool gIsRomDemangPagingEnabled;
82 TUint32 gNThreadId = 0;
84 // Test executables attributes flags
88 EMMPPaged = 1 << 0, // "PAGED" keyword in MMP file
89 EMMPUnpaged = 1 << 1, // "UNPAGED" keyword in MMP file
90 EMMPCompressTarget = 1 << 2, // "COMPRESSTARGET" keyword in MMP file
91 EMMPNoCompressTarget = 1 << 3, // "UNCOMPRESSTARGET" keyword in MMP file
92 EIBYData = 1 << 4, // File included as "data" in IBY file
93 EIBYFile = 1 << 5, // File included as "file" in IBY file
94 EIBYFileCompress = 1 << 6, // File included as "file_x_" in IBY file (_x_=compression scheme)
95 EIBYPaged = 1 << 7, // File declared "paged" in IBY file
96 EIBYUnpaged = 1 << 8, // File declared "unpaged in IBY file
97 EIBYAlias = 1 << 9, // File name is an alias
98 EDLLWritableStaticData = 1 << 10 // DLL contains writable static data
101 // Test executables attributes
102 const TUint testExeAttr[] =
104 /* 000 - does not exist */ ENone,
106 /* 002 */ EMMPPaged | EIBYFile,
107 /* 003 */ EMMPUnpaged | EIBYFile,
108 /* 004 */ EIBYFileCompress,
109 /* 005 */ EMMPPaged | EIBYFileCompress,
110 /* 006 */ EMMPUnpaged | EIBYFileCompress,
111 /* 007 */ EIBYFileCompress,
112 /* 008 */ EMMPPaged | EIBYFileCompress,
113 /* 009 */ EMMPUnpaged | EIBYFileCompress,
114 /* 010 */ EIBYFileCompress,
115 /* 011 */ EMMPPaged | EIBYFileCompress,
116 /* 012 */ EMMPUnpaged | EIBYFileCompress,
117 /* 013 */ EIBYFile | EMMPCompressTarget,
118 /* 014 */ EMMPPaged | EIBYFile | EMMPNoCompressTarget,
119 /* 015 */ EMMPUnpaged | EIBYFile | EIBYFileCompress | EIBYPaged,
121 /* 017 */ EMMPPaged | EIBYData,
122 /* 018 */ EMMPUnpaged | EIBYData,
123 /* 019 */ EIBYFile | EIBYPaged,
124 /* 020 */ EMMPPaged | EIBYFile | EIBYPaged,
125 /* 021 */ EMMPUnpaged | EIBYFile | EIBYPaged,
126 /* 022 */ EIBYFile | EIBYUnpaged,
127 /* 023 */ EMMPPaged | EIBYFile | EIBYUnpaged,
128 /* 024 */ EMMPUnpaged | EIBYFile | EIBYUnpaged,
129 /* 025 */ EIBYData | EIBYPaged,
130 /* 026 */ EMMPPaged | EIBYData | EIBYPaged,
131 /* 027 */ EMMPUnpaged | EIBYData | EIBYPaged,
132 /* 028 */ EIBYData | EIBYUnpaged,
133 /* 029 */ EMMPPaged | EIBYData | EIBYUnpaged,
134 /* 030 */ EMMPUnpaged | EIBYData | EIBYUnpaged,
135 /* 031 */ EIBYAlias | EIBYFile,
136 /* 032 */ EIBYAlias | EMMPPaged | EIBYFile,
137 /* 033 */ EIBYAlias | EMMPUnpaged | EIBYFile,
138 /* 034 */ EIBYAlias | EIBYFileCompress,
139 /* 035 */ EIBYAlias | EMMPPaged | EIBYFileCompress,
140 /* 036 */ EIBYAlias | EMMPUnpaged | EIBYFileCompress,
141 /* 037 */ EIBYAlias | EIBYFileCompress,
142 /* 038 */ EIBYAlias | EMMPPaged | EIBYFileCompress,
143 /* 039 */ EIBYAlias | EMMPUnpaged | EIBYFileCompress,
144 /* 040 */ EIBYAlias | EIBYFileCompress,
145 /* 041 */ EIBYAlias | EMMPPaged | EIBYFileCompress,
146 /* 042 */ EIBYAlias | EMMPUnpaged | EIBYFileCompress,
147 /* 043 */ EIBYAlias | EIBYFile | EMMPCompressTarget,
148 /* 044 */ EIBYAlias | EMMPPaged | EIBYFile | EMMPNoCompressTarget,
149 /* 045 */ EIBYAlias | EMMPUnpaged | EIBYFile | EIBYFileCompress | EIBYPaged,
150 /* 046 */ EIBYAlias | EIBYData,
151 /* 047 */ EIBYAlias | EMMPPaged | EIBYData,
152 /* 048 */ EIBYAlias | EMMPUnpaged | EIBYData,
153 /* 049 */ EIBYAlias | EIBYFile | EIBYPaged,
154 /* 050 */ EIBYAlias | EMMPPaged | EIBYFile | EIBYPaged,
155 /* 051 */ EIBYAlias | EMMPUnpaged | EIBYFile | EIBYPaged,
156 /* 052 */ EIBYAlias | EIBYFile | EIBYUnpaged,
157 /* 053 */ EIBYAlias | EMMPPaged | EIBYFile | EIBYUnpaged,
158 /* 054 */ EIBYAlias | EMMPUnpaged | EIBYFile | EIBYUnpaged,
159 /* 055 */ EIBYAlias | EIBYData | EIBYPaged,
160 /* 056 */ EIBYAlias | EMMPPaged | EIBYData | EIBYPaged,
161 /* 057 */ EIBYAlias | EMMPUnpaged | EIBYData | EIBYPaged,
162 /* 058 */ EIBYAlias | EIBYData | EIBYUnpaged,
163 /* 059 */ EIBYAlias | EMMPPaged | EIBYData | EIBYUnpaged,
164 /* 060 */ EIBYAlias | EMMPUnpaged | EIBYData | EIBYUnpaged
166 const TUint testDllAttr[] =
168 /* 000 - does not exist */ ENone,
170 /* 002 */ EMMPPaged | EIBYFile,
171 /* 003 */ EMMPUnpaged | EIBYFile,
172 /* 004 */ EIBYFileCompress,
173 /* 005 */ EMMPPaged | EIBYFileCompress,
174 /* 006 */ EMMPUnpaged | EIBYFileCompress,
175 /* 007 */ EDLLWritableStaticData,
176 /* 008 */ EMMPPaged | EDLLWritableStaticData,
177 /* 009 */ EMMPUnpaged | EDLLWritableStaticData,
178 /* 010 */ EIBYFileCompress,
179 /* 011 */ EMMPPaged | EIBYFileCompress,
180 /* 012 */ EMMPUnpaged | EIBYFileCompress,
181 /* 013 */ EIBYFile | EMMPCompressTarget,
182 /* 014 */ EMMPPaged | EIBYFile | EMMPNoCompressTarget,
183 /* 015 */ EMMPUnpaged | EIBYFile | EIBYFileCompress | EIBYPaged,
185 /* 017 */ EMMPPaged | EIBYData,
186 /* 018 */ EMMPUnpaged | EIBYData,
187 /* 019 */ EIBYFile | EIBYPaged,
188 /* 020 */ EMMPPaged | EIBYFile | EIBYPaged,
189 /* 021 */ EMMPUnpaged | EIBYFile | EIBYPaged,
190 /* 022 */ EIBYFile | EIBYUnpaged,
191 /* 023 */ EMMPPaged | EIBYFile | EIBYUnpaged,
192 /* 024 */ EMMPUnpaged | EIBYFile | EIBYUnpaged,
193 /* 025 */ EIBYData | EIBYPaged,
194 /* 026 */ EMMPPaged | EIBYData | EIBYPaged,
195 /* 027 */ EMMPUnpaged | EIBYData | EIBYPaged,
196 /* 028 */ EIBYData | EIBYUnpaged,
197 /* 029 */ EMMPPaged | EIBYData | EIBYUnpaged,
198 /* 030 */ EMMPUnpaged | EIBYData | EIBYUnpaged,
199 /* 031 */ EIBYAlias | EIBYFile,
200 /* 032 */ EIBYAlias | EMMPPaged | EIBYFile,
201 /* 033 */ EIBYAlias | EMMPUnpaged | EIBYFile,
202 /* 034 */ EIBYAlias | EIBYFileCompress,
203 /* 035 */ EIBYAlias | EMMPPaged | EIBYFileCompress,
204 /* 036 */ EIBYAlias | EMMPUnpaged | EIBYFileCompress,
205 /* 037 */ EIBYAlias | EDLLWritableStaticData,
206 /* 038 */ EIBYAlias | EMMPPaged | EDLLWritableStaticData,
207 /* 039 */ EIBYAlias | EMMPUnpaged | EDLLWritableStaticData,
208 /* 040 */ EIBYAlias | EIBYFileCompress,
209 /* 041 */ EIBYAlias | EMMPPaged | EIBYFileCompress,
210 /* 042 */ EIBYAlias | EMMPUnpaged | EIBYFileCompress,
211 /* 043 */ EIBYAlias | EIBYFile | EMMPCompressTarget,
212 /* 044 */ EIBYAlias | EMMPPaged | EIBYFile | EMMPNoCompressTarget,
213 /* 045 */ EIBYAlias | EMMPUnpaged | EIBYFile | EIBYFileCompress | EIBYPaged,
214 /* 046 */ EIBYAlias | EIBYData,
215 /* 047 */ EIBYAlias | EMMPPaged | EIBYData,
216 /* 048 */ EIBYAlias | EMMPUnpaged | EIBYData,
217 /* 049 */ EIBYAlias | EIBYFile | EIBYPaged,
218 /* 050 */ EIBYAlias | EMMPPaged | EIBYFile | EIBYPaged,
219 /* 051 */ EIBYAlias | EMMPUnpaged | EIBYFile | EIBYPaged,
220 /* 052 */ EIBYAlias | EIBYFile | EIBYUnpaged,
221 /* 053 */ EIBYAlias | EMMPPaged | EIBYFile | EIBYUnpaged,
222 /* 054 */ EIBYAlias | EMMPUnpaged | EIBYFile | EIBYUnpaged,
223 /* 055 */ EIBYAlias | EIBYData | EIBYPaged,
224 /* 056 */ EIBYAlias | EMMPPaged | EIBYData | EIBYPaged,
225 /* 057 */ EIBYAlias | EMMPUnpaged | EIBYData | EIBYPaged,
226 /* 058 */ EIBYAlias | EIBYData | EIBYUnpaged,
227 /* 059 */ EIBYAlias | EMMPPaged | EIBYData | EIBYUnpaged,
228 /* 060 */ EIBYAlias | EMMPUnpaged | EIBYData | EIBYUnpaged
233 _LIT(KThreadName, "ARandomThreadName");
234 btrace.SetFilter(BTrace::EThreadIdentification, ETrue);
236 btrace.SetMode(RBTrace::EEnable);
237 // rename the current thread to force a ThreadID trace
238 User::RenameThread(KThreadName);
242 TUint8* pCurrentRecord;
243 // extract the nano-kernel thread ID from the trace
244 while ((size = btrace.GetData(pDataStart)) != 0)
246 pCurrentRecord = pDataStart;
247 while (pCurrentRecord - pDataStart < size)
249 TInt extensionCount = 4 * (
250 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EHeader2Present ? 1 : 0) +
251 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::ETimestampPresent ? 1 : 0) +
252 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::ETimestamp2Present ? 1 : 0) +
253 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EContextIdPresent ? 1 : 0) +
254 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EPcPresent ? 1 : 0) +
255 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EExtraPresent ? 1 : 0));
257 if ((pCurrentRecord[BTrace::ECategoryIndex] == BTrace::EThreadIdentification) && (pCurrentRecord[BTrace::ESubCategoryIndex] == BTrace::EThreadName))
259 TBuf<255> threadName;
260 threadName.Format(_L(""));
261 for (TUint8* j = pCurrentRecord + 12 + extensionCount; j < pCurrentRecord + *pCurrentRecord; j++)
263 threadName.AppendFormat(_L("%c"), *j);
265 if (threadName == KThreadName)
267 test.Printf(_L("This thread's NThread ID: %08x\n"), LE4(pCurrentRecord + 4 + extensionCount));
268 gNThreadId = LE4(pCurrentRecord + 4 + extensionCount);
271 pCurrentRecord = BTrace::NextRecord(pCurrentRecord);
281 r = btrace.ResizeBuffer(32768); // 32k should be large enough
282 TEST_EQ(r, KErrNone);
283 btrace.SetFilter(BTrace::EPaging, ETrue);
284 btrace.SetFilter(BTrace::EThreadIdentification, ETrue);
287 for (TInt i = 1; i <= 60; i++)
290 filename.Format(_L("Z:\\SYS\\BIN\\DPEXE%03d.EXE"), i);
292 test.Printf(_L("Loading %S... "), &filename);
294 TBool paged = EFalse;
295 TBool inRom = EFalse;
297 TUint32 nthreadAddr = 0;
298 TBuf<255> processName;
300 if (fs.IsFileInRom(filename) != NULL)
309 // Ensure that the paging live list is empty
310 r = DPTest::FlushCache();
311 if (gIsRomDemangPagingEnabled)
313 TEST_EQ(r, KErrNone);
317 TEST_EQ(r, KErrNotSupported);
320 btrace.Empty(); // empty the BTrace buffer
321 btrace.SetMode(RBTrace::EEnable);
323 r = proc.Create(filename, _L(""));
325 if ((testExeAttr[i] & EIBYAlias) && (testExeAttr[i] & EIBYData) && (gIsRomDemangPagingEnabled))
326 // There cannot be aliases mapping to "data" files since they are moved to ROFS if the ROM is paged
328 TEST_EQ(r, KErrNotFound);
333 TEST_EQ(r, KErrNone);
336 // Resume the process and wait until it completes
341 User::WaitForRequest(ps);
348 TUint8* pCurrentRecord;
350 // We have a while loop here, in the unlikely case that our trace is fragmented
351 while ((size = btrace.GetData(pDataStart)) != 0)
353 pCurrentRecord = pDataStart;
354 while (pCurrentRecord - pDataStart < size)
356 // Number of bytes used by the BTrace extensions
357 TInt extensionCount = 4 * (
358 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EHeader2Present ? 1 : 0) +
359 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::ETimestampPresent ? 1 : 0) +
360 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::ETimestamp2Present ? 1 : 0) +
361 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EContextIdPresent ? 1 : 0) +
362 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EPcPresent ? 1 : 0) +
363 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EExtraPresent ? 1 : 0));
365 if ((pCurrentRecord[BTrace::ECategoryIndex] == BTrace::EThreadIdentification) && (pCurrentRecord[BTrace::ESubCategoryIndex] == BTrace::EProcessName))
368 processName.Format(_L(""));
369 for (TUint8* j = pCurrentRecord + 12 + extensionCount; j < pCurrentRecord + *pCurrentRecord; j++)
371 processName.AppendFormat(_L("%c"), *j);
374 expected.Format(_L("dpexe%03d.exe[%08x]%04x"), i, 0, 1);
376 if (processName == expected)
378 nthreadAddr = LE4(pCurrentRecord + 4 + extensionCount);
381 if ((pCurrentRecord[BTrace::ECategoryIndex] == BTrace::EPaging) && (LE4(pCurrentRecord + 8) == nthreadAddr))
382 /* The main thread of the test process tries to page in the test executable */
386 pCurrentRecord = BTrace::NextRecord(pCurrentRecord); // move on to the next record
392 test.Printf(_L("paged!\n"));
394 test.Printf(_L("not paged!\n"));
396 if (!gIsRomDemangPagingEnabled)
397 // ROM paging disabled. All files are in ROM and unpaged
399 test.Printf(_L("ROM Paging disabled: shouldn't be paged\n"));
400 TEST_CONDITION(inRom);
401 TEST_CONDITION(!paged);
403 else if (testExeAttr[i] & EIBYData)
404 // data - if ROM paged, then these executables will be moved to ROFS
405 // these are always expected to be RAM loaded
407 test.Printf(_L("EXE is DATA in ROFS\n"));
408 TEST_CONDITION(!inRom);
410 else if (testExeAttr[i] & EIBYFileCompress)
411 // Compression format specified in the IBY file
412 // These are expected to be stay in ROM, but will be RAM-loaded
414 test.Printf(_L("EXE has own compression method: shouldn't be paged\n"));
415 TEST_CONDITION(inRom);
416 TEST_CONDITION(!paged);
418 // from this point onwards, all executables can potentially be paged - paging policy takes precedence
419 else if (gPagingPolicy == EKernelConfigCodePagingPolicyNoPaging)
421 test.Printf(_L("Paging policy is No Paging: shouldn't be paged\n"));
422 TEST_CONDITION(inRom);
423 TEST_CONDITION(!paged);
425 else if (gPagingPolicy == EKernelConfigCodePagingPolicyAlwaysPage)
427 test.Printf(_L("Paging policy is No Paging: shouldn't be paged\n"));
428 TEST_CONDITION(inRom);
429 TEST_CONDITION(paged);
431 // from this point onwards, paging policy is either Default Paged or Default Unpaged - paging override takes precedence
432 else if (gPagingOverride == EKernelConfigCodePagingPolicyNoPaging)
434 test.Printf(_L("Paging override is No Paging: shouldn't be paged\n"));
435 TEST_CONDITION(inRom);
436 TEST_CONDITION(!paged);
438 else if (gPagingOverride == EKernelConfigCodePagingPolicyAlwaysPage)
440 test.Printf(_L("Paging override is Always Page: should be paged\n"));
441 TEST_CONDITION(inRom);
442 TEST_CONDITION(paged);
444 // from this point onwards, paging policy and override are either Default Paged or Default Unpaged - IBY setting takes precedence
445 else if (testExeAttr[i] & EIBYPaged)
447 test.Printf(_L("Paged keyword in OBY: should be paged\n"));
448 TEST_CONDITION(inRom);
449 TEST_CONDITION(paged);
451 else if (testExeAttr[i] & EIBYUnpaged)
453 test.Printf(_L("Unpaged keyword in OBY: shouldn't be paged\n"));
454 TEST_CONDITION(inRom);
455 TEST_CONDITION(!paged);
457 // Next, MMP setting takes precedence
458 else if (testExeAttr[i] & EMMPPaged)
460 test.Printf(_L("Paged keyword in MMP: should be paged\n"));
461 TEST_CONDITION(inRom);
462 TEST_CONDITION(paged);
464 else if (testExeAttr[i] & EMMPUnpaged)
466 test.Printf(_L("Unpaged keyword in MMP: shouldn't be paged\n"));
467 TEST_CONDITION(inRom);
468 TEST_CONDITION(!paged);
470 // The test exe has no attribute. Paging overright default paging mode takes precedence
471 else if (gPagingOverride == EKernelConfigCodePagingPolicyDefaultUnpaged)
473 test.Printf(_L("Paging override is Default Unpaged: shouldn't be paged\n"));
474 TEST_CONDITION(inRom);
475 TEST_CONDITION(!paged);
477 else if (gPagingOverride == EKernelConfigCodePagingPolicyDefaultPaged)
479 test.Printf(_L("Paging override is Default Paged: should be paged\n"));
480 TEST_CONDITION(inRom);
481 TEST_CONDITION(paged);
483 // Paging policy default paging mode takes precedence
484 else if (gPagingPolicy == EKernelConfigCodePagingPolicyDefaultUnpaged)
486 test.Printf(_L("Paging policy is Default Unpaged: shouldn't be paged\n"));
487 TEST_CONDITION(inRom);
488 TEST_CONDITION(!paged);
490 else if (gPagingPolicy == EKernelConfigCodePagingPolicyDefaultPaged)
492 test.Printf(_L("Paging policy is Default paged: should be paged\n"));
493 TEST_CONDITION(inRom);
494 TEST_CONDITION(paged);
496 // ROM Paging enabled without a default paging policy - this should not happen (default policy is No Paging)
499 test.Printf(_L("No paging policy!\n"));
511 r = btrace.ResizeBuffer(32768); // 32k should be large enough
512 TEST_EQ(r, KErrNone);
513 btrace.SetFilter(BTrace::EPaging, ETrue);
514 btrace.SetFilter(BTrace::EThreadIdentification, ETrue);
517 for (TInt i = 1; i <= 60; i++)
520 filename.Format(_L("Z:\\SYS\\BIN\\DPDLL%03d.DLL"), i);
522 test.Printf(_L("Loading %S... "), &filename);
524 TBool paged = EFalse;
525 TBool inRom = EFalse;
531 if ((addr = fs.IsFileInRom(filename)) != NULL)
541 r = file.Open(fs, filename, EFileRead);
542 if ((testDllAttr[i] & EIBYAlias) && (testDllAttr[i] & EIBYData) && (gIsRomDemangPagingEnabled))
543 // There cannot be aliases mapping to "data" files since they are moved to ROFS if the ROM is paged
545 TEST_EQ(r, KErrNotFound);
550 TEST_EQ(r, KErrNone);
552 r = file.Size(filesize);
553 TEST_EQ(r, KErrNone);
556 // Ensure that the paging live list is empty
557 r = DPTest::FlushCache();
558 if (gIsRomDemangPagingEnabled)
560 TEST_EQ(r, KErrNone);
564 TEST_EQ(r, KErrNotSupported);
567 btrace.Empty(); // empty the BTrace buffer
568 btrace.SetMode(RBTrace::EEnable);
570 r = lib.Load(filename);
571 libLoadEnd = User::FastCounter();
573 TEST_EQ(r, KErrNone);
575 TLibraryFunction function1;
576 TLibraryFunction function2;
577 TLibraryFunction function3;
578 TLibraryFunction function4;
580 function1 = lib.Lookup(1);
581 function2 = lib.Lookup(2);
582 function3 = lib.Lookup(3);
583 function4 = lib.Lookup(4);
585 test(function1 != NULL);
586 test(function2 != NULL);
587 test(function3 != NULL);
588 test(function4 == NULL);
590 // Resume the process and wait until it completes
598 //processResumeStart = User::FastCounter();
599 //processResumeEnd = User::FastCounter();
606 TUint8* pCurrentRecord;
608 // We have a while loop here, in the unlikely case that our trace is fragmented
609 while ((size = btrace.GetData(pDataStart)) != 0)
611 pCurrentRecord = pDataStart;
612 while (pCurrentRecord - pDataStart < size)
614 // Number of bytes used by the BTrace extensions
615 TInt extensionCount = 4 * (
616 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EHeader2Present ? 1 : 0) +
617 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::ETimestampPresent ? 1 : 0) +
618 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::ETimestamp2Present ? 1 : 0) +
619 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EContextIdPresent ? 1 : 0) +
620 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EPcPresent ? 1 : 0) +
621 (pCurrentRecord[BTrace::EFlagsIndex] & BTrace::EExtraPresent ? 1 : 0));
623 if ((pCurrentRecord[BTrace::ECategoryIndex] == BTrace::EPaging)
624 && (pCurrentRecord[BTrace::ESubCategoryIndex] == BTrace::EPagingPageInBegin)
625 && (LE4(pCurrentRecord + 4) > libLoadEnd)
626 && (LE4(pCurrentRecord + extensionCount) == gNThreadId)
627 && (LE4(pCurrentRecord + 4 + extensionCount) >= (TUint32) addr)
628 && (LE4(pCurrentRecord + 4 + extensionCount) < ((TUint32) addr) + filesize))
629 // If the DLL is paged in under this thread after it's been RLibrary::Load'ed, then we assume the DLL is paged
633 pCurrentRecord = BTrace::NextRecord(pCurrentRecord); // move on to the next record
639 test.Printf(_L("paged!\n"));
641 test.Printf(_L("not paged!\n"));
643 if (!gIsRomDemangPagingEnabled)
644 // ROM paging disabled. All files are in ROM and unpaged
646 test.Printf(_L("ROM Paging disabled: shouldn't be paged\n"));
648 TEST_CONDITION(!paged);
650 else if (testDllAttr[i] & EIBYData)
651 // data - if ROM paged, then these executables will be moved to ROFS
652 // these are always expected to be RAM loaded
654 test.Printf(_L("DLL is DATA in ROFS: shouldn't be paged\n"));
655 TEST_CONDITION(!inRom);
656 TEST_CONDITION(!paged);
658 else if (testDllAttr[i] & EIBYFileCompress)
659 // Compression format specified in the IBY file
660 // These are expected to be stay in ROM, but will be RAM-loaded
662 test.Printf(_L("DLL has own compression method: shouldn't be paged\n"));
663 TEST_CONDITION(inRom);
664 TEST_CONDITION(!paged);
666 // from this point onwards, all executables can potentially be paged - paging policy takes precedence
667 else if (gPagingPolicy == EKernelConfigCodePagingPolicyNoPaging)
669 test.Printf(_L("Paging policy is No Paging: shouldn't be paged\n"));
670 TEST_CONDITION(inRom);
671 TEST_CONDITION(!paged);
673 else if (gPagingPolicy == EKernelConfigCodePagingPolicyAlwaysPage)
675 test.Printf(_L("Paging policy is Always Page: should be paged\n"));
676 TEST_CONDITION(inRom);
677 TEST_CONDITION(paged);
679 // from this point onwards, paging policy is either Default Paged or Default Unpaged - paging override takes precedence
680 else if (gPagingOverride == EKernelConfigCodePagingPolicyNoPaging)
682 test.Printf(_L("Paging override is No Paging: shouldn't be paged\n"));
683 TEST_CONDITION(inRom);
684 TEST_CONDITION(!paged);
686 else if (gPagingOverride == EKernelConfigCodePagingPolicyAlwaysPage)
688 test.Printf(_L("Paging override is Always Page: should be paged\n"));
689 TEST_CONDITION(inRom);
690 TEST_CONDITION(paged);
692 // from this point onwards, paging policy and override are either Default Paged or Default Unpaged - IBY setting takes precedence
693 else if (testDllAttr[i] & EIBYPaged)
695 test.Printf(_L("Paged keyword in OBY: should be paged\n"));
696 TEST_CONDITION(inRom);
697 TEST_CONDITION(paged);
699 else if (testDllAttr[i] & EIBYUnpaged)
701 test.Printf(_L("Unpaged keyword in OBY: shouldn't be paged\n"));
702 TEST_CONDITION(inRom);
703 TEST_CONDITION(!paged);
705 // Next, MMP setting takes precedence
706 else if (testDllAttr[i] & EMMPPaged)
708 test.Printf(_L("Paged keyword in MMP: should be paged\n"));
709 TEST_CONDITION(inRom);
710 TEST_CONDITION(paged);
712 else if (testDllAttr[i] & EMMPUnpaged)
714 test.Printf(_L("Unpaged keyword in MMP: shouldn't be paged\n"));
715 TEST_CONDITION(inRom);
716 TEST_CONDITION(!paged);
718 // The test exe has no attribute. Paging overright default paging mode takes precedence
719 else if (gPagingOverride == EKernelConfigCodePagingPolicyDefaultUnpaged)
721 test.Printf(_L("Paging override is Default Unpaged: shouldn't be paged\n"));
722 TEST_CONDITION(inRom);
723 TEST_CONDITION(!paged);
725 else if (gPagingOverride == EKernelConfigCodePagingPolicyDefaultPaged)
727 test.Printf(_L("Paging override is Default Paged: should be paged\n"));
728 TEST_CONDITION(inRom);
729 TEST_CONDITION(paged);
731 // Paging policy default paging mode takes precedence
732 else if (gPagingPolicy == EKernelConfigCodePagingPolicyDefaultUnpaged)
734 test.Printf(_L("Paging policy is Default Unpaged: shouldn't be paged\n"));
735 TEST_CONDITION(inRom);
736 TEST_CONDITION(!paged);
738 else if (gPagingPolicy == EKernelConfigCodePagingPolicyDefaultPaged)
740 test.Printf(_L("Paging policy is Default paged: should be paged\n"));
741 TEST_CONDITION(inRom);
742 TEST_CONDITION(paged);
744 // ROM Paging enabled without a default paging policy - this should not happen (default policy is No Paging)
747 test.Printf(_L("No paging policy!\n"));
754 GLDEF_C TInt E32Main()
758 test.Start(_L("Check environment"));
760 // Open the BTrace handler
762 TEST_EQ(r, KErrNone);
764 // capture the NThread ID of the main thread of the current process
766 test(gNThreadId != 0);
768 gPagingPolicy = E32Loader::PagingPolicy();
769 gPagingOverride = -1;
772 TEST_EQ(r, KErrNone);
774 if (fs.IsFileInRom(_L("\\ovr_nopaging")) != NULL)
776 gPagingOverride = EKernelConfigCodePagingPolicyNoPaging;
778 if (fs.IsFileInRom(_L("\\ovr_alwayspage")) != NULL)
780 gPagingOverride = EKernelConfigCodePagingPolicyAlwaysPage;
782 if (fs.IsFileInRom(_L("\\ovr_defaultunpaged")) != NULL)
784 gPagingOverride = EKernelConfigCodePagingPolicyDefaultUnpaged;
786 if (fs.IsFileInRom(_L("\\ovr_defaultpaged")) != NULL)
788 gPagingOverride = EKernelConfigCodePagingPolicyDefaultPaged;
790 if (fs.IsFileInRom(_L("\\pcy_nopaging")) != NULL)
792 gPagingPolicy = EKernelConfigCodePagingPolicyNoPaging;
794 if (fs.IsFileInRom(_L("\\pcy_alwayspage")) != NULL)
796 gPagingPolicy = EKernelConfigCodePagingPolicyAlwaysPage;
798 if (fs.IsFileInRom(_L("\\pcy_defaultunpaged")) != NULL)
800 gPagingPolicy = EKernelConfigCodePagingPolicyDefaultUnpaged;
802 if (fs.IsFileInRom(_L("\\pcy_defaultpaged")) != NULL)
804 gPagingPolicy = EKernelConfigCodePagingPolicyDefaultPaged;
807 gIsRomDemangPagingEnabled = (fs.IsFileInRom(_L("Z:\\SYS\\BIN\\DPEXE046.EXE")) == NULL);
809 test.Printf(_L("Demand Paging Enabled? %d\n"), gIsRomDemangPagingEnabled);
810 test.Printf(_L("PagingOverride %d\n"), gPagingOverride);
811 test.Printf(_L("PagingPolicy %d\n"), gPagingPolicy);
813 test.Next(_L("Load ROM EXEs"));
815 test.Next(_L("Load ROM DLLs"));