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 0 | a41df078684a |
child 44 | 3e88ff8f41d5 |
permissions | -rw-r--r-- |
0 | 1 |
// Copyright (c) 2003-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\dll\t_xxver2.cpp |
|
15 |
// Overview: |
|
16 |
// Test matching algorithm for DLL versions. Test aspects of DLL and EXE files. |
|
17 |
// API Information: |
|
18 |
// RLibrary |
|
19 |
// Details: |
|
20 |
// - This test makes use of 4 versions of a single DLL, and 15 EXEs which link |
|
21 |
// against it. The EXEs all have different reqirements on which DLL versions |
|
22 |
// are acceptable |
|
23 |
// - Test that the correct version of linked libraries are used (Run for each |
|
24 |
// EXE and for the 16 combinations in which the 4 versions of the DLL can be |
|
25 |
// available. The test is performed with each EXE run in sequence, and again |
|
26 |
// with all of them run at the same time) |
|
27 |
// - Test that the correct version of dynamically loaded libraries are used and |
|
28 |
// the libary exports are as expected. (Run for each DLL version and for the |
|
29 |
// 16 combinations of DLL availability) |
|
30 |
// - Test that RLibrary::GetInfo and RLibrary::GetInfoFromHeader return the |
|
31 |
// expected data for all DLLs and EXEs |
|
32 |
// Platforms/Drives/Compatibility: |
|
33 |
// All. |
|
34 |
// Assumptions/Requirement/Pre-requisites: |
|
35 |
// Failures and causes: |
|
36 |
// Base Port information: |
|
37 |
// |
|
38 |
// |
|
39 |
||
40 |
#include <e32uid.h> |
|
41 |
#include <e32test.h> |
|
42 |
#include <f32file.h> |
|
43 |
#include <d_ldrtst.h> |
|
44 |
#include <f32image.h> |
|
45 |
||
46 |
RTest test(_L("T_XXVER2")); |
|
47 |
RFs gFs; |
|
48 |
CFileMan* gFileMan; |
|
49 |
RLdrTest LdrTest; |
|
50 |
||
51 |
TBuf<8> SourcePath = _S16("Z:\\img\\"); |
|
52 |
||
53 |
||
54 |
TFileName KDestPath() |
|
55 |
{ |
|
56 |
_LIT(KDestPath, "C:\\system\\bin\\ver"); |
|
57 |
_LIT(KDestPathSysBin, "C:\\sys\\bin\\ver"); |
|
58 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
59 |
return KDestPathSysBin(); |
|
60 |
else |
|
61 |
return KDestPath(); |
|
62 |
} |
|
63 |
||
64 |
_LIT(KDllName0, "t_ver2{00010000}.dll"); |
|
65 |
_LIT(KDllName1, "t_ver2{00010001}.dll"); |
|
66 |
_LIT(KDllName2, "t_ver2{00020000}.dll"); |
|
67 |
_LIT(KDllName3, "t_ver2.dll"); |
|
68 |
||
69 |
const TDesC* const DllArray[] = |
|
70 |
{ |
|
71 |
&KDllName0(), |
|
72 |
&KDllName1(), |
|
73 |
&KDllName2(), |
|
74 |
&KDllName3() |
|
75 |
}; |
|
76 |
||
77 |
const TInt KNumDlls = sizeof(DllArray)/sizeof(const TDesC* const); |
|
78 |
||
79 |
const TInt DllVersion[KNumDlls] = |
|
80 |
{ |
|
81 |
0x00010000, |
|
82 |
0x00010001, |
|
83 |
0x00020000, |
|
84 |
0x00030000 |
|
85 |
}; |
|
86 |
||
87 |
const TInt KNumTestVersions = 7; |
|
88 |
const TInt TestDllVersion[KNumTestVersions] = |
|
89 |
{ |
|
90 |
0x00000000, |
|
91 |
0x00010000, |
|
92 |
0x00010001, |
|
93 |
0x00010002, |
|
94 |
0x00020000, |
|
95 |
0x00030000, |
|
96 |
0x00040000 |
|
97 |
}; |
|
98 |
||
99 |
_LIT(KExeName0, "t_xver2a.exe"); // request 1.0 work with any |
|
100 |
_LIT(KExeName1, "t_xver2b.exe"); // request 1.0 work with 2.0 but not 3.0 |
|
101 |
_LIT(KExeName2, "t_xver2c.exe"); // request 1.0 don't work with 2.0 |
|
102 |
_LIT(KExeName3, "t_xver2d.exe"); // request 1.1 work with 1.0 but not 2.0 |
|
103 |
_LIT(KExeName4, "t_xver2e.exe"); // request 1.1 work with any |
|
104 |
_LIT(KExeName5, "t_xver2f.exe"); // request 1.1 work with 2.0, 3.0 but not with 1.0 |
|
105 |
_LIT(KExeName6, "t_xver2g.exe"); // request 1.1 don't work with 2.0, 3.0 or 1.0 |
|
106 |
_LIT(KExeName7, "t_xver2h.exe"); // request 1.1 work with 1.0 and 2.0 but not 3.0 |
|
107 |
_LIT(KExeName8, "t_xver2i.exe"); // request 1.1 work with 2.0 but not 3.0 or 1.0 |
|
108 |
_LIT(KExeName9, "t_xver2j.exe"); // request 2.0 only use 1.0 exports |
|
109 |
_LIT(KExeName10, "t_xver2k.exe"); // request 2.0 only use 1.0, 1.1 exports |
|
110 |
_LIT(KExeName11, "t_xver2l.exe"); // request 2.0 use 2.0 exports work on 3.0 |
|
111 |
_LIT(KExeName12, "t_xver2m.exe"); // request 2.0 use 2.0 exports, don't work on 3.0 |
|
112 |
_LIT(KExeName13, "t_xver2n.exe"); // request 3.0 use 1.0 exports only |
|
113 |
_LIT(KExeName14, "t_xver2o.exe"); // request 3.0 use all |
|
114 |
||
115 |
const TDesC* const ExeArray[] = |
|
116 |
{ |
|
117 |
&KExeName0(), |
|
118 |
&KExeName1(), |
|
119 |
&KExeName2(), |
|
120 |
&KExeName3(), |
|
121 |
&KExeName4(), |
|
122 |
&KExeName5(), |
|
123 |
&KExeName6(), |
|
124 |
&KExeName7(), |
|
125 |
&KExeName8(), |
|
126 |
&KExeName9(), |
|
127 |
&KExeName10(), |
|
128 |
&KExeName11(), |
|
129 |
&KExeName12(), |
|
130 |
&KExeName13(), |
|
131 |
&KExeName14() |
|
132 |
}; |
|
133 |
||
134 |
const TInt KNumExes = sizeof(ExeArray)/sizeof(const TDesC* const); |
|
135 |
||
136 |
const TInt ResultArray[KNumExes<<KNumDlls] = |
|
137 |
{ |
|
138 |
// DLLs Present A B C D E F G H I J K L M N O |
|
139 |
// None |
|
140 |
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, |
|
141 |
// 1.0 |
|
142 |
0, 0, 0, 0, 0, -1, -1, 0, -1, -1, -1, -1, -1, -1, -1, |
|
143 |
// 1.1 |
|
144 |
1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, |
|
145 |
// 1.0, 1.1 |
|
146 |
1, 1, 1, 1, 1, 1, 1, 1, 1, -1, -1, -1, -1, -1, -1, |
|
147 |
// 2.0 |
|
148 |
2, 2, -1, -1, 2, 2, -1, 2, 2, 2, 2, 2, 2, -1, -1, |
|
149 |
// 2.0, 1.0 |
|
150 |
0, 0, 0, 0, 2, 2, -1, 2, 2, 2, 2, 2, 2, -1, -1, |
|
151 |
// 2.0, 1.1 |
|
152 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, -1, -1, |
|
153 |
// 2.0, 1.1, 1.0 |
|
154 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, -1, -1, |
|
155 |
// 3.0 |
|
156 |
3, -1, -1, -1, 3, 3, -1, -1, -1, 3, 3, 3, -1, 3, 3, |
|
157 |
// 3.0, 1.0 |
|
158 |
0, 0, 0, 0, 3, 3, -1, 0, -1, 3, 3, 3, -1, 3, 3, |
|
159 |
// 3.0, 1.1 |
|
160 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, -1, 3, 3, |
|
161 |
// 3.0, 1.1, 1.0 |
|
162 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 3, 3, -1, 3, 3, |
|
163 |
// 3.0, 2.0 |
|
164 |
2, 2, -1, -1, 2, 2, -1, 2, 2, 2, 2, 2, 2, 3, 3, |
|
165 |
// 3.0, 2.0, 1.0 |
|
166 |
0, 0, 0, 0, 2, 2, -1, 2, 2, 2, 2, 2, 2, 3, 3, |
|
167 |
// 3.0, 2.0, 1.1 |
|
168 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, |
|
169 |
// 3.0, 2.0, 1.1, 1.0 |
|
170 |
1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3 |
|
171 |
// |
|
172 |
}; |
|
173 |
||
174 |
const TInt ResultArray2[KNumTestVersions<<KNumDlls] = |
|
175 |
{ |
|
176 |
// DLLs Present 0.0 1.0 1.1 1.2 2.0 3.0 4.0 |
|
177 |
// None |
|
178 |
-1, -1, -1, -1, -1, -1, -1, |
|
179 |
// 1.0 |
|
180 |
-1, 0, -1, -1, -1, -1, -1, |
|
181 |
// 1.1 |
|
182 |
-1, 1, 1, -1, -1, -1, -1, |
|
183 |
// 1.0, 1.1 |
|
184 |
-1, 1, 1, -1, -1, -1, -1, |
|
185 |
// 2.0 |
|
186 |
-1, -1, -1, -1, 2, -1, -1, |
|
187 |
// 2.0, 1.0 |
|
188 |
-1, 0, -1, -1, 2, -1, -1, |
|
189 |
// 2.0, 1.1 |
|
190 |
-1, 1, 1, -1, 2, -1, -1, |
|
191 |
// 2.0, 1.1, 1.0 |
|
192 |
-1, 1, 1, -1, 2, -1, -1, |
|
193 |
// 3.0 |
|
194 |
-1, -1, -1, -1, -1, 3, -1, |
|
195 |
// 3.0, 1.0 |
|
196 |
-1, 0, -1, -1, -1, 3, -1, |
|
197 |
// 3.0, 1.1 |
|
198 |
-1, 1, 1, -1, -1, 3, -1, |
|
199 |
// 3.0, 1.1, 1.0 |
|
200 |
-1, 1, 1, -1, -1, 3, -1, |
|
201 |
// 3.0, 2.0 |
|
202 |
-1, -1, -1, -1, 2, 3, -1, |
|
203 |
// 3.0, 2.0, 1.0 |
|
204 |
-1, 0, -1, -1, 2, 3, -1, |
|
205 |
// 3.0, 2.0, 1.1 |
|
206 |
-1, 1, 1, -1, 2, 3, -1, |
|
207 |
// 3.0, 2.0, 1.1, 1.0 |
|
208 |
-1, 1, 1, -1, 2, 3, -1 |
|
209 |
// |
|
210 |
}; |
|
211 |
||
212 |
struct SExportInfo |
|
213 |
{ |
|
214 |
TInt iTotal; |
|
215 |
TInt iHoles; |
|
216 |
TInt iHole[1]; |
|
217 |
}; |
|
218 |
||
219 |
const TInt Dll0ExportInfo[] = {19,0}; |
|
220 |
const TInt Dll1ExportInfo[] = {29,0}; |
|
221 |
const TInt Dll2ExportInfo[] = {39,4,2,3,23,24}; |
|
222 |
const TInt Dll3ExportInfo[] = {59,6,2,3,4,23,24,39}; |
|
223 |
||
224 |
const SExportInfo* const DllExportInfo[KNumDlls] = |
|
225 |
{ |
|
226 |
(const SExportInfo*)Dll0ExportInfo, |
|
227 |
(const SExportInfo*)Dll1ExportInfo, |
|
228 |
(const SExportInfo*)Dll2ExportInfo, |
|
229 |
(const SExportInfo*)Dll3ExportInfo |
|
230 |
}; |
|
231 |
||
232 |
void CheckExports(TInt aDllNum, RLibrary aLib) |
|
233 |
{ |
|
234 |
test.Printf(_L("Testing exports for DLL %d\n"), aDllNum); |
|
235 |
const TFileName& fn = aLib.FileName(); |
|
236 |
test.Printf(_L("Filename %S\n"), &fn); |
|
237 |
const SExportInfo* e = DllExportInfo[aDllNum]; |
|
238 |
TAny* libcs = LdrTest.LibraryCodeSeg(aLib.Handle()); |
|
239 |
test.Printf(_L("Code seg @%08x\n"), libcs); |
|
240 |
test(libcs != NULL); |
|
241 |
TInt n = e->iTotal; |
|
242 |
TInt nh = e->iHoles; |
|
243 |
TInt ord; |
|
244 |
for (ord=1; ord<=n+1; ++ord) |
|
245 |
{ |
|
246 |
TLibraryFunction f = aLib.Lookup(ord); |
|
247 |
test.Printf(_L("Ord %3d->%08x\n"), ord, f); |
|
248 |
if (ord>n) |
|
249 |
{ |
|
250 |
test(!f); |
|
251 |
continue; |
|
252 |
} |
|
253 |
TInt i; |
|
254 |
for (i=0; i<nh && e->iHole[i]!=ord; ++i) {} |
|
255 |
if (i<nh) |
|
256 |
test(!f); // hole |
|
257 |
else |
|
258 |
test(f!=NULL); |
|
259 |
TAny* cs = LdrTest.CodeSegFromAddr((TLinAddr)f); |
|
260 |
test(f ? (cs==libcs) : !cs); |
|
261 |
} |
|
262 |
} |
|
263 |
||
264 |
void CreateAndPopulateDir(TUint aMask) |
|
265 |
{ |
|
266 |
test.Printf(_L("CreateAndPopulateDir %d\n"), aMask); |
|
267 |
TFileName fn = KDestPath(); |
|
268 |
fn.AppendNumFixedWidth(aMask, EDecimal, 2); |
|
269 |
fn.Append('\\'); |
|
270 |
TInt r = gFs.MkDirAll(fn); |
|
271 |
test.Printf(_L("MkDir %S->%d\n"), &fn, r); |
|
272 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
273 |
TFileName fn2 = fn; |
|
274 |
fn2.Append(_L("*.*")); |
|
275 |
TTime now; |
|
276 |
now.HomeTime(); |
|
277 |
r = gFileMan->Attribs(fn2, 0, KEntryAttReadOnly|KEntryAttHidden|KEntryAttSystem|KEntryAttArchive, now); |
|
278 |
test.Printf(_L("Attribs %S->%d\n"), &fn2, r); |
|
279 |
r = gFileMan->Delete(fn2); |
|
280 |
test.Printf(_L("Delete %S->%d\n"), &fn2, r); |
|
281 |
TInt n = 0; |
|
282 |
for (; aMask; aMask>>=1, ++n) |
|
283 |
{ |
|
284 |
if (!(aMask & 1)) |
|
285 |
continue; |
|
286 |
fn2 = fn; |
|
287 |
fn2.Append(*DllArray[n]); |
|
288 |
TFileName src = SourcePath; |
|
289 |
src.Append(*DllArray[n]); |
|
290 |
r = gFileMan->Copy(src, fn2); |
|
291 |
test.Printf(_L("%S->%S (%d)\n"), &src, &fn2, r); |
|
292 |
test(r == KErrNone); |
|
293 |
} |
|
294 |
for (n=0; n<KNumExes; ++n) |
|
295 |
{ |
|
296 |
fn2 = fn; |
|
297 |
fn2.Append(*ExeArray[n]); |
|
298 |
TFileName src = SourcePath; |
|
299 |
src.Append(*ExeArray[n]); |
|
300 |
r = gFileMan->Copy(src, fn2); |
|
301 |
test.Printf(_L("%S->%S (%d)\n"), &src, &fn2, r); |
|
302 |
test(r == KErrNone); |
|
303 |
} |
|
304 |
} |
|
305 |
||
306 |
void RunExe(TUint aMask, TInt aExeNum) |
|
307 |
{ |
|
308 |
test.Printf(_L("RunExe mask %d exenum %d\n"), aMask, aExeNum); |
|
309 |
RProcess p; |
|
310 |
TRequestStatus s; |
|
311 |
TFileName fn = KDestPath(); |
|
312 |
fn.AppendNumFixedWidth(aMask, EDecimal, 2); |
|
313 |
fn.Append('\\'); |
|
314 |
fn.Append(*ExeArray[aExeNum]); |
|
315 |
TInt r = p.Create(fn, KNullDesC); |
|
316 |
test.Printf(_L("Create %S->%d\n"), &fn, r); |
|
317 |
TInt rix = aExeNum + KNumExes*TInt(aMask); |
|
318 |
TInt expected = ResultArray[rix]; |
|
319 |
test.Printf(_L("RunExe expected %d\n"), expected); |
|
320 |
if (expected<0) |
|
321 |
{ |
|
322 |
test(r<0); |
|
323 |
return; |
|
324 |
} |
|
325 |
p.Logon(s); |
|
326 |
p.Resume(); |
|
327 |
User::WaitForRequest(s); |
|
328 |
if (p.ExitType()!=EExitKill) |
|
329 |
{ |
|
330 |
TInt et = p.ExitType(); |
|
331 |
TInt er = p.ExitReason(); |
|
332 |
const TDesC& ec = p.ExitCategory(); |
|
333 |
test.Printf(_L("Exit %d,%d,%S\n"), et, er, &ec); |
|
334 |
test(0); |
|
335 |
} |
|
336 |
CLOSE_AND_WAIT(p); |
|
337 |
test.Printf(_L("Return code %08x\n"), s.Int()); |
|
338 |
test(s.Int() == DllVersion[expected]); |
|
339 |
} |
|
340 |
||
341 |
void RunExes(TUint aMask) |
|
342 |
{ |
|
343 |
test.Printf(_L("RunExes mask %d\n"), aMask); |
|
344 |
RProcess p[KNumExes]; |
|
345 |
TRequestStatus s[KNumExes]; |
|
346 |
TInt xn; |
|
347 |
for (xn=0; xn<KNumExes; ++xn) |
|
348 |
{ |
|
349 |
TFileName fn = KDestPath(); |
|
350 |
fn.AppendNumFixedWidth(aMask, EDecimal, 2); |
|
351 |
fn.Append('\\'); |
|
352 |
fn.Append(*ExeArray[xn]); |
|
353 |
TInt r = p[xn].Create(fn, KNullDesC); |
|
354 |
test.Printf(_L("Create %S->%d\n"), &fn, r); |
|
355 |
TInt rix = xn + KNumExes*TInt(aMask); |
|
356 |
TInt expected = ResultArray[rix]; |
|
357 |
test.Printf(_L("RunExe expected %d\n"), expected); |
|
358 |
if (expected<0) |
|
359 |
{ |
|
360 |
test(r<0); |
|
361 |
continue; |
|
362 |
} |
|
363 |
p[xn].Logon(s[xn]); |
|
364 |
} |
|
365 |
for (xn=0; xn<KNumExes; ++xn) |
|
366 |
{ |
|
367 |
TInt rix = xn + KNumExes*TInt(aMask); |
|
368 |
TInt expected = ResultArray[rix]; |
|
369 |
if (expected<0) |
|
370 |
continue; |
|
371 |
p[xn].Resume(); |
|
372 |
} |
|
373 |
for (xn=0; xn<KNumExes; ++xn) |
|
374 |
{ |
|
375 |
TInt rix = xn + KNumExes*TInt(aMask); |
|
376 |
TInt expected = ResultArray[rix]; |
|
377 |
if (expected<0) |
|
378 |
continue; |
|
379 |
User::WaitForRequest(s[xn]); |
|
380 |
if (p[xn].ExitType()!=EExitKill) |
|
381 |
{ |
|
382 |
TInt et = p[xn].ExitType(); |
|
383 |
TInt er = p[xn].ExitReason(); |
|
384 |
const TDesC& ec = p[xn].ExitCategory(); |
|
385 |
test.Printf(_L("Exit %d,%d,%S\n"), et, er, &ec); |
|
386 |
test(0); |
|
387 |
} |
|
388 |
CLOSE_AND_WAIT(p[xn]); |
|
389 |
test.Printf(_L("Return code %08x\n"), s[xn].Int()); |
|
390 |
test(s[xn].Int() == DllVersion[expected]); |
|
391 |
} |
|
392 |
} |
|
393 |
||
394 |
void TestDynamic(TUint aMask, TInt aTN) |
|
395 |
{ |
|
396 |
TUint32 ver = TestDllVersion[aTN]; |
|
397 |
TInt rix = aTN + KNumTestVersions*TInt(aMask); |
|
398 |
TInt expected = ResultArray2[rix]; |
|
399 |
test.Printf(_L("ReqVer %08x Expected %d\n"), ver, expected); |
|
400 |
TFileName path = KDestPath(); |
|
401 |
path.AppendNumFixedWidth(aMask, EDecimal, 2); |
|
402 |
TFileName fn = path; |
|
403 |
fn.Append(_L("\\T_VER2.DLL")); |
|
404 |
RLibrary l; |
|
405 |
TInt r = l.Load(fn, KNullDesC, TUidType(), ver); |
|
406 |
test.Printf(_L("Load %S returns %d\n"), &fn, r); |
|
407 |
if (expected<0) |
|
408 |
{ |
|
409 |
test(r<0); |
|
410 |
return; |
|
411 |
} |
|
412 |
TLibraryFunction f = l.Lookup(1); |
|
413 |
test(f != 0); |
|
414 |
TInt result = (*f)(); |
|
415 |
test.Printf(_L("Ord 1 returns %08x\n"), result); |
|
416 |
test(result == DllVersion[expected]); |
|
417 |
l.Close(); |
|
418 |
r = l.Load(_L("T_VER2.DLL"), path, TUidType(), ver); |
|
419 |
test.Printf(_L("Load T_VER2.DLL path %S returns %d\n"), &path, r); |
|
420 |
if (expected<0) |
|
421 |
{ |
|
422 |
test(r<0); |
|
423 |
return; |
|
424 |
} |
|
425 |
f = l.Lookup(1); |
|
426 |
test(f != 0); |
|
427 |
result = (*f)(); |
|
428 |
test.Printf(_L("Ord 1 returns %08x\n"), result); |
|
429 |
test(result == DllVersion[expected]); |
|
430 |
CheckExports(expected, l); |
|
431 |
l.Close(); |
|
432 |
} |
|
433 |
||
434 |
void TestLibraryInfo(TInt aN) |
|
435 |
{ |
|
436 |
TFileName fn; |
|
437 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
438 |
fn = _S16("C:\\sys\\bin\\ver15\\"); |
|
439 |
else |
|
440 |
fn = _S16("C:\\system\\bin\\ver15\\"); |
|
441 |
fn += *DllArray[aN]; |
|
442 |
test.Printf(_L("Getting info for %S\n"), &fn); |
|
443 |
TBool formHeader=EFalse; |
|
444 |
for(;;) |
|
445 |
{ |
|
446 |
RLibrary::TInfoV2 info; |
|
447 |
TPckg<RLibrary::TInfoV2> infoBuf(info); |
|
448 |
TInt r; |
|
449 |
if(formHeader) |
|
450 |
{ |
|
451 |
TUint8* buf; |
|
452 |
||
453 |
RFs fs; |
|
454 |
test(fs.Connect()==KErrNone); |
|
455 |
RFile file; |
|
456 |
test((r=file.Open(fs,fn,0))==KErrNone); |
|
457 |
TInt size; |
|
458 |
test((r=file.Size(size))==KErrNone); |
|
459 |
if(size>RLibrary::KRequiredImageHeaderSize) |
|
460 |
size=RLibrary::KRequiredImageHeaderSize; |
|
461 |
buf=new TUint8[size]; |
|
462 |
test(buf!=0); |
|
463 |
TPtr8 header(buf,size); |
|
464 |
test((r=file.Read(header))==KErrNone); |
|
465 |
file.Close(); |
|
466 |
fs.Close(); |
|
467 |
||
468 |
r = RLibrary::GetInfoFromHeader(header, infoBuf); |
|
469 |
test.Printf(_L("GetInfoFromHeader returns %d\n"), r); |
|
470 |
||
471 |
delete buf; |
|
472 |
} |
|
473 |
else |
|
474 |
{ |
|
475 |
r = RLibrary::GetInfo(fn, infoBuf); |
|
476 |
test.Printf(_L("GetInfo returns %d\n"), r); |
|
477 |
} |
|
478 |
||
479 |
test(r==KErrNone); |
|
480 |
const TUint32* uid = (const TUint32*)&info.iUids; |
|
481 |
test.Printf(_L("VER %08x\n"), info.iModuleVersion); |
|
482 |
test.Printf(_L("UID1 %08x\n"), uid[0]); |
|
483 |
test.Printf(_L("UID2 %08x\n"), uid[1]); |
|
484 |
test.Printf(_L("UID3 %08x\n"), uid[2]); |
|
485 |
test.Printf(_L("SID %08x\n"), (TUint32)info.iSecurityInfo.iSecureId); |
|
486 |
test.Printf(_L("VID %08x\n"), (TUint32)info.iSecurityInfo.iVendorId); |
|
487 |
test.Printf(_L("CAP0 %08x\n"), ((SSecurityInfo&)info.iSecurityInfo).iCaps[0]); |
|
488 |
test.Printf(_L("CAP1 %08x\n"), ((SSecurityInfo&)info.iSecurityInfo).iCaps[1]); |
|
489 |
TUint32 v = (TUint32)DllVersion[aN]; |
|
490 |
test(info.iModuleVersion == v); |
|
491 |
test(uid[0] == (TUint32)KDynamicLibraryUidValue); |
|
492 |
test(uid[2] == (TUint32)0x40abcdef); |
|
493 |
TUint32 xsid = ((v>>16)<<4)|(v&0x0f)|0x89abcd00u; |
|
494 |
test(info.iSecurityInfo.iSecureId == xsid); |
|
495 |
TUint32 xvid = 0x01234500+(xsid&0xff); |
|
496 |
test(info.iSecurityInfo.iVendorId == xvid); |
|
497 |
test(((SSecurityInfo&)info.iSecurityInfo).iCaps[0]==0x0002aaab); |
|
498 |
test(((SSecurityInfo&)info.iSecurityInfo).iCaps[1]==0); |
|
499 |
if(formHeader) |
|
500 |
#if defined(__ARMCC__) |
|
501 |
test(info.iHardwareFloatingPoint == EFpTypeVFPv2); |
|
502 |
#else |
|
503 |
test(info.iHardwareFloatingPoint == EFpTypeNone); |
|
504 |
#endif |
|
505 |
||
506 |
if(formHeader) |
|
507 |
break; |
|
508 |
formHeader = ETrue; |
|
509 |
} |
|
510 |
} |
|
511 |
||
512 |
void TestExeInfo(TInt aN) |
|
513 |
{ |
|
514 |
TFileName fn; |
|
515 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
516 |
fn = _S16("C:\\sys\\bin\\ver15\\"); |
|
517 |
else |
|
518 |
fn = _S16("C:\\system\\bin\\ver15\\"); |
|
519 |
fn += *ExeArray[aN]; |
|
520 |
test.Printf(_L("Getting info for %S\n"), &fn); |
|
521 |
TBool formHeader=EFalse; |
|
522 |
for(;;) |
|
523 |
{ |
|
524 |
RLibrary::TInfoV2 info; |
|
525 |
TPckg<RLibrary::TInfoV2> infoBuf(info); |
|
526 |
TInt r; |
|
527 |
if(formHeader) |
|
528 |
{ |
|
529 |
TUint8* buf; |
|
530 |
||
531 |
RFs fs; |
|
532 |
test(fs.Connect()==KErrNone); |
|
533 |
RFile file; |
|
534 |
test((r=file.Open(fs,fn,0))==KErrNone); |
|
535 |
TInt size; |
|
536 |
test((r=file.Size(size))==KErrNone); |
|
537 |
if(size>RLibrary::KRequiredImageHeaderSize) |
|
538 |
size=RLibrary::KRequiredImageHeaderSize; |
|
539 |
buf=new TUint8[size]; |
|
540 |
test(buf!=0); |
|
541 |
TPtr8 header(buf,size); |
|
542 |
test((r=file.Read(header))==KErrNone); |
|
543 |
file.Close(); |
|
544 |
fs.Close(); |
|
545 |
||
546 |
r = RLibrary::GetInfoFromHeader(header, infoBuf); |
|
547 |
test.Printf(_L("GetInfoFromHeader returns %d\n"), r); |
|
548 |
||
549 |
delete buf; |
|
550 |
} |
|
551 |
else |
|
552 |
{ |
|
553 |
r = RLibrary::GetInfo(fn, infoBuf); |
|
554 |
test.Printf(_L("GetInfo returns %d\n"), r); |
|
555 |
} |
|
556 |
||
557 |
test(r==KErrNone); |
|
558 |
const TUint32* uid = (const TUint32*)&info.iUids; |
|
559 |
test.Printf(_L("VER %08x\n"), info.iModuleVersion); |
|
560 |
test.Printf(_L("UID1 %08x\n"), uid[0]); |
|
561 |
test.Printf(_L("UID2 %08x\n"), uid[1]); |
|
562 |
test.Printf(_L("UID3 %08x\n"), uid[2]); |
|
563 |
test.Printf(_L("SID %08x\n"), (TUint32)info.iSecurityInfo.iSecureId); |
|
564 |
test.Printf(_L("VID %08x\n"), (TUint32)info.iSecurityInfo.iVendorId); |
|
565 |
test.Printf(_L("CAP0 %08x\n"), ((SSecurityInfo&)info.iSecurityInfo).iCaps[0]); |
|
566 |
test.Printf(_L("CAP1 %08x\n"), ((SSecurityInfo&)info.iSecurityInfo).iCaps[1]); |
|
567 |
#if defined(__EABI__) && !defined(__X86__) |
|
568 |
test(info.iModuleVersion == 0x000a0000); |
|
569 |
#else |
|
570 |
test(info.iModuleVersion == 0x00010000); |
|
571 |
#endif |
|
572 |
test(uid[0] == (TUint32)KExecutableImageUidValue); |
|
573 |
TUint32 xuid3 = 0x40abcd61u + aN; |
|
574 |
test(uid[2] == xuid3); |
|
575 |
test(info.iSecurityInfo.iSecureId == xuid3); |
|
576 |
TUint32 xvid = 0x01234500+(xuid3&0xff); |
|
577 |
test(info.iSecurityInfo.iVendorId == xvid); |
|
578 |
test(((SSecurityInfo&)info.iSecurityInfo).iCaps[0]==0x0002aaab); |
|
579 |
test(((SSecurityInfo&)info.iSecurityInfo).iCaps[1]==0); |
|
580 |
if(formHeader) |
|
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
581 |
{ |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
582 |
#if defined(__ARMCC__) && __ARMCC_VERSION >= 400000 |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
583 |
test(info.iHardwareFloatingPoint == EFpTypeVFPv2); |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
584 |
#else |
0 | 585 |
test(info.iHardwareFloatingPoint == EFpTypeNone); |
43
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
586 |
#endif |
c1f20ce4abcf
Revision: 201035
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
587 |
} |
0 | 588 |
if(formHeader) |
589 |
break; |
|
590 |
formHeader = ETrue; |
|
591 |
} |
|
592 |
} |
|
593 |
||
594 |
void TestCompression(void) |
|
595 |
{ |
|
596 |
||
597 |
// Check target directory |
|
598 |
TFileName fn; |
|
599 |
if(PlatSec::ConfigSetting(PlatSec::EPlatSecEnforceSysBin)) |
|
600 |
fn = _S16("c:\\sys\\bin\\"); |
|
601 |
else |
|
602 |
fn = _S16("c:\\system\\bin\\"); |
|
603 |
||
604 |
TInt r = gFs.MkDirAll(fn); |
|
605 |
test.Printf(_L("MkDir %S->%d\n"), &fn, r); |
|
606 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
607 |
||
608 |
// Make copy from t_xxver2.exe to t_xxvercomp.exe |
|
609 |
fn.Append(_L("t_xxvercomp.exe")); |
|
610 |
||
611 |
TFileName fn2 = fn; |
|
612 |
TTime now; |
|
613 |
now.HomeTime(); |
|
614 |
r = gFileMan->Attribs(fn2, 0, KEntryAttReadOnly|KEntryAttHidden|KEntryAttSystem|KEntryAttArchive, now); |
|
615 |
test.Printf(_L("Attribs %S->%d\n"), &fn2, r); |
|
616 |
r = gFileMan->Delete(fn2); |
|
617 |
test.Printf(_L("Delete %S->%d\n"), &fn2, r); |
|
618 |
||
619 |
fn2 = fn; |
|
620 |
TFileName src = SourcePath; |
|
621 |
src.Append(*ExeArray[0]); |
|
622 |
r = gFileMan->Copy(src, fn2); |
|
623 |
test.Printf(_L("%S->%S (%d)\n"), &src, &fn2, r); |
|
624 |
test(r == KErrNone); |
|
625 |
||
626 |
||
627 |
// Check RLibrary::GetInfoFromHeader on a correct executable |
|
628 |
test.Printf(_L("fn:%S\n"), &fn); |
|
629 |
||
630 |
RLibrary::TInfoV2 info; |
|
631 |
TPckg<RLibrary::TInfoV2> infoBuf(info); |
|
632 |
||
633 |
TUint8* buf; |
|
634 |
||
635 |
RFs fs; |
|
636 |
test(fs.Connect()==KErrNone); |
|
637 |
RFile file; |
|
638 |
r=file.Open(fs,fn,0); |
|
639 |
test.Printf(_L("file.Open returns %d\n"), r); |
|
640 |
test(r==KErrNone); |
|
641 |
TInt size; |
|
642 |
test((r=file.Size(size))==KErrNone); |
|
643 |
if(size>RLibrary::KRequiredImageHeaderSize) |
|
644 |
size=RLibrary::KRequiredImageHeaderSize; |
|
645 |
buf=new TUint8[size]; |
|
646 |
test(buf!=0); |
|
647 |
TPtr8 header(buf,size); |
|
648 |
test((r=file.Read(header))==KErrNone); |
|
649 |
file.Close(); |
|
650 |
||
651 |
||
652 |
r = RLibrary::GetInfoFromHeader(header, infoBuf); |
|
653 |
test.Printf(_L("GetInfoFromHeader returns %d\n"), r); |
|
654 |
test(r==KErrNone); |
|
655 |
||
656 |
||
657 |
test.Printf(_L("Write invalid compression info into the header.\n")); |
|
658 |
E32ImageHeader* e32Header = (E32ImageHeader*) buf; |
|
659 |
||
660 |
e32Header->iCompressionType = 0x00000001; |
|
661 |
test((r=file.Open(fs,fn,EFileWrite))==KErrNone); |
|
662 |
r=file.Write(header); |
|
663 |
test.Printf(_L("file.Write returns %d\n"), r); |
|
664 |
test(r==KErrNone); |
|
665 |
file.Close(); |
|
666 |
||
667 |
// Check RLibrary::GetInfoFromHeader on a wrong compression method. |
|
668 |
||
669 |
r = RLibrary::GetInfoFromHeader(header, infoBuf); |
|
670 |
test.Printf(_L("GetInfoFromHeader returns %d\n"), r); |
|
671 |
test(r==KErrCorrupt); |
|
672 |
||
673 |
||
674 |
fs.Close(); |
|
675 |
delete buf; |
|
676 |
||
677 |
||
678 |
||
679 |
} // End of TestCompression() |
|
680 |
||
681 |
TInt E32Main() |
|
682 |
{ |
|
683 |
test.Title(); |
|
684 |
||
685 |
// Turn off evil lazy dll unloading |
|
686 |
RLoader l; |
|
687 |
test(l.Connect()==KErrNone); |
|
688 |
test(l.CancelLazyDllUnload()==KErrNone); |
|
689 |
l.Close(); |
|
690 |
||
691 |
TBuf<256> cmdline; |
|
692 |
User::CommandLine(cmdline); |
|
693 |
TLex lex(cmdline); |
|
694 |
TInt options[8]; |
|
695 |
TInt i; |
|
696 |
memclr(options, sizeof(options)); |
|
697 |
for (i=0; i<8; ++i) |
|
698 |
{ |
|
699 |
lex.SkipSpace(); |
|
700 |
if (lex.Eos()) |
|
701 |
break; |
|
702 |
lex.Val(options[i]); |
|
703 |
} |
|
704 |
TUint tm = 0xffffffffu; |
|
705 |
if (options[0]) |
|
706 |
tm = (TUint)options[0]; |
|
707 |
||
708 |
test.Start(_L("Create cleanup stack")); |
|
709 |
CTrapCleanup* ct = CTrapCleanup::New(); |
|
710 |
test(ct!=0); |
|
711 |
test.Next(_L("Connect to file server")); |
|
712 |
TInt r = gFs.Connect(); |
|
713 |
test(r==KErrNone); |
|
714 |
test.Next(_L("Create CFileMan")); |
|
715 |
TRAP(r, gFileMan=CFileMan::NewL(gFs)); |
|
716 |
test(r==KErrNone); |
|
717 |
test.Next(_L("Connect to test driver")); |
|
718 |
r = User::LoadLogicalDevice(_L("d_ldrtst")); |
|
719 |
test(r==KErrNone || r==KErrAlreadyExists); |
|
720 |
r = LdrTest.Open(); |
|
721 |
test(r==KErrNone); |
|
722 |
TFileName fn(RProcess().FileName()); |
|
723 |
test.Printf(_L("Process file name = %S\n"), &fn); |
|
724 |
SourcePath[0] = fn[0]; // use same drive as this EXE |
|
725 |
||
726 |
TUint mask; |
|
727 |
TUint nmasks = 1u << KNumDlls; |
|
728 |
for (mask=0; mask<nmasks; ++mask) |
|
729 |
{ |
|
730 |
CreateAndPopulateDir(mask); |
|
731 |
if (!(tm&1)) |
|
732 |
continue; |
|
733 |
TInt n; |
|
734 |
for (n=0; n<KNumExes; ++n) |
|
735 |
{ |
|
736 |
RunExe(mask, n); |
|
737 |
} |
|
738 |
RunExes(mask); |
|
739 |
} |
|
740 |
||
741 |
if (tm & 2) |
|
742 |
{ |
|
743 |
test.Next(_L("Test dynamic loading by version")); |
|
744 |
for (mask=0; mask<nmasks; ++mask) |
|
745 |
{ |
|
746 |
TInt n; |
|
747 |
for (n=0; n<KNumTestVersions; ++n) |
|
748 |
{ |
|
749 |
TestDynamic(mask, n); |
|
750 |
} |
|
751 |
} |
|
752 |
} |
|
753 |
||
754 |
if (tm & 4) |
|
755 |
{ |
|
756 |
test.Next(_L("Test get library info")); |
|
757 |
TInt n; |
|
758 |
for (n=0; n<KNumDlls; ++n) |
|
759 |
{ |
|
760 |
TestLibraryInfo(n); |
|
761 |
} |
|
762 |
for (n=0; n<KNumExes; ++n) |
|
763 |
{ |
|
764 |
TestExeInfo(n); |
|
765 |
} |
|
766 |
} |
|
767 |
||
768 |
if( tm & 8) |
|
769 |
{ |
|
770 |
TestCompression(); |
|
771 |
} |
|
772 |
||
773 |
delete gFileMan; |
|
774 |
gFs.Close(); |
|
775 |
delete ct; |
|
776 |
LdrTest.Close(); |
|
777 |
test.End(); |
|
778 |
return KErrNone; |
|
779 |
} |
|
780 |