author | Jon Chatten |
Thu, 26 Aug 2010 13:41:01 +0100 | |
changeset 630 | 31ef8a13d4f4 |
parent 625 | a1925fb7753a |
child 674 | 37ee82a83d43 |
permissions | -rw-r--r-- |
591 | 1 |
# |
2 |
# Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
# All rights reserved. |
|
4 |
# This component and the accompanying materials are made available |
|
5 |
# under the terms of the License "Eclipse Public License v1.0" |
|
6 |
# which accompanies this distribution, and is available |
|
7 |
# at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 |
# |
|
9 |
# Initial Contributors: |
|
10 |
# Nokia Corporation - initial contribution. |
|
11 |
# |
|
12 |
# Contributors: |
|
13 |
# |
|
14 |
# Description: |
|
15 |
# raptor_meta_unit module |
|
16 |
# This module tests the classes forming the Raptor bld.inf and .mmp parsing support |
|
17 |
# |
|
18 |
||
19 |
import raptor |
|
20 |
import raptor_meta |
|
21 |
import raptor_utilities |
|
22 |
import raptor_data |
|
23 |
import mmpparser |
|
24 |
import unittest |
|
25 |
import generic_path |
|
26 |
import os |
|
27 |
import sys |
|
28 |
import re |
|
29 |
||
30 |
class TestRaptorMeta(unittest.TestCase): |
|
31 |
||
32 |
def setUp(self): |
|
33 |
self.raptor = raptor.Raptor() |
|
34 |
self.__testRoot = generic_path.Path(os.environ[raptor.env], "test").Absolute() |
|
35 |
self.__makefilePathTestRoot = self.__testRoot |
|
36 |
self.__epocroot = self.__testRoot |
|
37 |
self.__variant_cfg_root = self.__testRoot.Append('metadata/config') |
|
38 |
self.__variant_cfg = self.__variant_cfg_root.Append('test_cfg.cfg') |
|
39 |
self.__platmacros_armv5 = "ARMCC EPOC32 MARM EABI ARMCC_2 ARMCC_2_2 GENERIC_MARM MARM_ARMV5" |
|
40 |
self.__platmacros_armv6 = "ARMCC EPOC32 MARM EABI ARMCC_2 ARMCC_2_2 GENERIC_MARM MARM_ARMV5 ARMV6" |
|
41 |
self.__platmacros_armv7 = "ARMCC EPOC32 MARM EABI ARMCC_2 ARMCC_2_2 GENERIC_MARM MARM_ARMV5 ARMV7" |
|
42 |
self.__platmacros_winscw = "CW32 WINS WINSCW" |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
43 |
self.__platmacros_x86gcc = "X86GCC EPOC32" |
591 | 44 |
|
45 |
self.variant_hrh = self.__testRoot.Append('metadata/include/test_hrh.hrh') |
|
46 |
||
47 |
self.__OSRoot = "" |
|
48 |
if raptor_utilities.getOSFileSystem() == "cygwin": |
|
49 |
self.__OSRoot = str(self.__makefilePathTestRoot)[:2] |
|
50 |
||
51 |
# we need some sort of generic platform for preprocessing |
|
52 |
self.defaultPlatform = { 'PLATFORM': 'generic', |
|
53 |
'EPOCROOT': self.__epocroot, |
|
54 |
'VARIANT_HRH': self.variant_hrh, |
|
55 |
'SYSTEMINCLUDE' : '', |
|
56 |
'id': 0, |
|
57 |
'key': '0000000000000000', |
|
58 |
'key_md5': '0000000000000000', |
|
59 |
'ISFEATUREVARIANT' : False, |
|
60 |
'PLATMACROS' : self.__platmacros_armv5, |
|
61 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
62 |
'METADEPS' : [] |
|
63 |
} |
|
64 |
# For testing purposes, the ARMV5 platform is flagged here as feature variant. |
|
65 |
# In metadata processing terms, this means that the location of the HRH file |
|
66 |
# is not automatically added to the SYSTEMINCLUDE path, and so is specified |
|
67 |
# directly. |
|
68 |
self.ARMV5 = { 'PLATFORM': 'ARMV5', |
|
69 |
'EPOCROOT': self.__epocroot, |
|
70 |
'VARIANT_HRH': self.variant_hrh, |
|
71 |
'SYSTEMINCLUDE' : str(self.variant_hrh.Dir()), |
|
72 |
'id': 1, |
|
73 |
'key': '1111111111111111', |
|
74 |
'key_md5': '1111111111111111', |
|
75 |
'ISFEATUREVARIANT' : True, |
|
76 |
'PLATMACROS' : self.__platmacros_armv5, |
|
77 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
78 |
'METADEPS' : [] |
|
79 |
} |
|
80 |
self.ARMV5SMP = { 'PLATFORM': 'ARMV5SMP', |
|
81 |
'EPOCROOT': self.__epocroot, |
|
82 |
'VARIANT_HRH': self.variant_hrh, |
|
83 |
'SYSTEMINCLUDE' : str(self.variant_hrh.Dir()), |
|
84 |
'id': 1, |
|
85 |
'key': '1111111111111111', |
|
86 |
'key_md5': '1111111111111111', |
|
87 |
'ISFEATUREVARIANT' : False, |
|
88 |
'PLATMACROS' : self.__platmacros_armv5, |
|
89 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
90 |
'METADEPS' : [] |
|
91 |
} |
|
92 |
self.ARMV6 = { 'PLATFORM': 'ARMV6', |
|
93 |
'EPOCROOT': self.__epocroot, |
|
94 |
'VARIANT_HRH': self.variant_hrh, |
|
95 |
'SYSTEMINCLUDE' : str(self.variant_hrh.Dir()), |
|
96 |
'id': 1, |
|
97 |
'key': '1111111111111111', |
|
98 |
'key_md5': '1111111111111111', |
|
99 |
'ISFEATUREVARIANT' : False, |
|
100 |
'PLATMACROS' : self.__platmacros_armv6, |
|
101 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
102 |
'METADEPS' : [] |
|
103 |
} |
|
104 |
self.ARMV7 = { 'PLATFORM': 'ARMV7', |
|
105 |
'EPOCROOT': self.__epocroot, |
|
106 |
'VARIANT_HRH': self.variant_hrh, |
|
107 |
'SYSTEMINCLUDE' : str(self.variant_hrh.Dir()), |
|
108 |
'id': 1, |
|
109 |
'key': '1111111111111111', |
|
110 |
'key_md5': '1111111111111111', |
|
111 |
'ISFEATUREVARIANT' : False, |
|
112 |
'PLATMACROS' : self.__platmacros_armv7, |
|
113 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
114 |
'METADEPS' : [] |
|
115 |
} |
|
116 |
self.ARMV7SMP = { 'PLATFORM': 'ARMV7SMP', |
|
117 |
'EPOCROOT': self.__epocroot, |
|
118 |
'VARIANT_HRH': self.variant_hrh, |
|
119 |
'SYSTEMINCLUDE' : str(self.variant_hrh.Dir()), |
|
120 |
'id': 1, |
|
121 |
'key': '1111111111111111', |
|
122 |
'key_md5': '1111111111111111', |
|
123 |
'ISFEATUREVARIANT' : False, |
|
124 |
'PLATMACROS' : self.__platmacros_armv7, |
|
125 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
126 |
'METADEPS' : [] |
|
127 |
} |
|
128 |
self.WINSCW = { 'PLATFORM': 'WINSCW', |
|
129 |
'EPOCROOT': self.__epocroot, |
|
130 |
'VARIANT_HRH': self.variant_hrh, |
|
131 |
'SYSTEMINCLUDE' : '', |
|
132 |
'id': 2, |
|
133 |
'key': '2222222222222222', |
|
134 |
'key_md5': '2222222222222222', |
|
135 |
'ISFEATUREVARIANT' : False, |
|
136 |
'PLATMACROS' : self.__platmacros_winscw, |
|
137 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
|
138 |
'METADEPS' : [] |
|
139 |
} |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
140 |
|
630 | 141 |
self.X86GCC = { 'PLATFORM': 'X86', |
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
142 |
'EPOCROOT': self.__epocroot, |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
143 |
'VARIANT_HRH': self.variant_hrh, |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
144 |
'SYSTEMINCLUDE' : '', |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
145 |
'id': 2, |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
146 |
'key': '2222222222222222', |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
147 |
'key_md5': '2222222222222222', |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
148 |
'ISFEATUREVARIANT' : False, |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
149 |
'PLATMACROS' : self.__platmacros_x86gcc, |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
150 |
'SBS_BUILD_DIR' : str(self.__epocroot) + "/epoc32/build", |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
151 |
'METADEPS' : [] |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
152 |
} |
591 | 153 |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
154 |
self.testPlats = [self.ARMV5, self.ARMV5SMP, self.ARMV6, self.ARMV7, self.ARMV7SMP, self.WINSCW, self.X86GCC] |
591 | 155 |
|
156 |
# Get the version of CPP that we are using and hope it's correct |
|
157 |
# since there is no tool check. |
|
158 |
if os.environ.has_key('SBS_GNUCPP'): |
|
159 |
self.__gnucpp = os.environ['SBS_GNUCPP'] |
|
160 |
else: |
|
161 |
self.__gnucpp = "cpp" |
|
162 |
||
163 |
def testPreProcessor(self): |
|
164 |
# Just test for correct behaviour on failure, other tests excercise correct behaviour on success |
|
165 |
preProcessor = raptor_meta.PreProcessor('cpp_that_does_not_exist', |
|
166 |
'-undef -nostdinc', |
|
167 |
'-I', '-D', '-include', |
|
168 |
self.raptor) |
|
169 |
||
170 |
try: |
|
171 |
preProcessor.preprocess() |
|
172 |
except Exception, e: |
|
173 |
self.assertTrue(isinstance(e, raptor_meta.MetaDataError)) |
|
174 |
self.assertTrue(re.match('^Preprocessor exception', e.Text)) |
|
175 |
||
176 |
def testConfigParsing(self): |
|
177 |
# .cfg file specified, but does not exist |
|
178 |
try: |
|
179 |
configDetails = raptor_meta.getVariantCfgDetail(self.__epocroot, |
|
180 |
self.__variant_cfg_root.Append("missing")) |
|
181 |
except Exception, e: |
|
182 |
self.assertTrue(isinstance(e, raptor_meta.MetaDataError)) |
|
183 |
self.assertTrue(re.match('^Could not read variant configuration file.*$', e.Text)) |
|
184 |
||
185 |
# No .hrh file specified |
|
186 |
try: |
|
187 |
configDetails = raptor_meta.getVariantCfgDetail(self.__epocroot, |
|
188 |
self.__variant_cfg_root.Append("empty_cfg.cfg")) |
|
189 |
except Exception, e: |
|
190 |
self.assertTrue(isinstance(e, raptor_meta.MetaDataError)) |
|
191 |
self.assertTrue(re.match('No variant file specified in .*', e.Text)) |
|
192 |
||
193 |
# .hrh file does not exist |
|
194 |
try: |
|
195 |
configDetails = raptor_meta.getVariantCfgDetail(self.__epocroot, |
|
196 |
self.__variant_cfg_root.Append("invalid_cfg.cfg")) |
|
197 |
except Exception, e: |
|
198 |
self.assertTrue(isinstance(e, raptor_meta.MetaDataError)) |
|
199 |
self.assertTrue(re.match('Variant file .* does not exist', e.Text)) |
|
200 |
||
201 |
# Valid .cfg file |
|
202 |
configDetails = raptor_meta.getVariantCfgDetail(self.__epocroot, |
|
203 |
self.__variant_cfg) |
|
204 |
self.failUnless(configDetails) |
|
205 |
||
206 |
found_variant_hrh = str(configDetails.get('VARIANT_HRH')) |
|
207 |
expected_variant_hrh = str(self.variant_hrh) |
|
208 |
||
209 |
self.assertEqual(found_variant_hrh, expected_variant_hrh) |
|
210 |
||
211 |
||
212 |
def __testBuildPlatforms(self, aRootBldInfLocation, aBldInfFile, |
|
213 |
aExpectedBldInfPlatforms, aExpectedBuildablePlatforms): |
|
214 |
bldInfFile = aRootBldInfLocation.Append(aBldInfFile) |
|
215 |
self.failUnless(bldInfFile) |
|
216 |
||
217 |
depfiles=[] |
|
218 |
bldInfObject = raptor_meta.BldInfFile(bldInfFile, self.__gnucpp, depfiles=depfiles, log=self.raptor) |
|
219 |
||
220 |
bp = bldInfObject.getBuildPlatforms(self.defaultPlatform) |
|
221 |
self.assertEquals(bp, aExpectedBldInfPlatforms) |
|
222 |
||
223 |
buildableBldInfBuildPlatforms = raptor_meta.getBuildableBldInfBuildPlatforms(bp, |
|
630 | 224 |
'ARMV5 ARMV7 WINSCW X86', |
225 |
'ARMV5 ARMV5SMP ARMV7 WINSCW X86', |
|
226 |
'ARMV5 ARMV7 WINSCW X86') |
|
591 | 227 |
|
228 |
for expectedBuildablePlatform in aExpectedBuildablePlatforms: |
|
229 |
self.assertTrue(expectedBuildablePlatform in buildableBldInfBuildPlatforms) |
|
230 |
||
231 |
self.assertEqual(len(aExpectedBuildablePlatforms), |
|
232 |
len(buildableBldInfBuildPlatforms)) |
|
233 |
return |
|
234 |
||
235 |
def testBldInfPlatformDeduction(self): |
|
236 |
bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs') |
|
237 |
||
238 |
self.__testBuildPlatforms(bldInfTestRoot, 'no_prj_platforms.inf', |
|
630 | 239 |
[], ['ARMV7', 'ARMV5', 'WINSCW', 'GCCXML', 'X86']) |
591 | 240 |
self.__testBuildPlatforms(bldInfTestRoot, 'no_plats.inf', |
630 | 241 |
[], ['ARMV7', 'ARMV5', 'WINSCW', 'GCCXML', 'X86']) |
591 | 242 |
self.__testBuildPlatforms(bldInfTestRoot, 'default_plats.inf', |
630 | 243 |
['DEFAULT'], ['ARMV7', 'ARMV5', 'WINSCW', 'GCCXML', 'X86']) |
591 | 244 |
self.__testBuildPlatforms(bldInfTestRoot, 'default_plats_minus_plat.inf', |
630 | 245 |
['DEFAULT', '-WINSCW'], ['ARMV7', 'ARMV5', 'GCCXML', 'X86']) |
591 | 246 |
self.__testBuildPlatforms(bldInfTestRoot, 'single_plat.inf', |
630 | 247 |
['ARMV5'], ['ARMV5', 'GCCXML']) |
591 | 248 |
self.__testBuildPlatforms(bldInfTestRoot, 'multiple_plats.inf', |
630 | 249 |
['ARMV5', 'WINSCW', 'TOOLS', 'X86'], ['ARMV5', 'WINSCW', 'TOOLS', 'GCCXML', 'X86']) |
591 | 250 |
return |
251 |
||
252 |
def __testBldInfTestCode(self, aTestRoot, aBldInf, aActual, aExpected): |
|
253 |
loop_number = 0 |
|
254 |
for actual in aActual: |
|
255 |
self.assertEquals(actual, aExpected[loop_number]) |
|
256 |
loop_number += 1 |
|
257 |
||
258 |
def testBldInfTestType(self): |
|
259 |
bldInfTestRoot = self.__testRoot.Append('metadata/project/mmps/test_mmps') |
|
260 |
||
261 |
bldInfFile = bldInfTestRoot.Append('test_mmps.inf') |
|
262 |
depfiles = [] |
|
263 |
bldInfObject = raptor_meta.BldInfFile(bldInfFile, self.__gnucpp, depfiles=depfiles, log=self.raptor) |
|
264 |
testArmv5Platform = self.ARMV5 |
|
265 |
testArmv5Platform["TESTCODE"] = True |
|
266 |
bldInfObject.getRomTestType(testArmv5Platform) |
|
267 |
||
268 |
self.__testBldInfTestCode(bldInfTestRoot, 'test_mmps.inf', |
|
269 |
[bldInfObject.testManual, bldInfObject.testAuto], [1, 1]) |
|
270 |
||
271 |
def __testExport(self, aExportObject, aSource, aDestination, aAction): |
|
272 |
self.assertEquals(aExportObject.getSource(), aSource) |
|
273 |
self.assertEqualsOrContainsPath(aExportObject.getDestination(), aDestination) |
|
274 |
self.assertEquals(aExportObject.getAction(), aAction) |
|
275 |
||
276 |
def assertEqualsOrContainsPath(self, aRequirement, aCandidate): |
|
277 |
# If aRequirement is a list, which it might well be, we should |
|
278 |
# assert that aPathString is contained in it |
|
279 |
# If aRequirement not a list, it will be a string, and |
|
280 |
# we should assert equality of the strings |
|
281 |
# On windows we shouldn't care about the case of the drive letter. |
|
282 |
||
283 |
if isinstance(aRequirement, list): |
|
284 |
pathsequal = False |
|
285 |
for r in aRequirement: |
|
286 |
pathsequal = path_compare_notdrivelettercase(r,aCandidate) or pathsequal |
|
287 |
self.assertTrue(pathsequal) |
|
288 |
else: |
|
289 |
self.assertTrue(path_compare_notdrivelettercase(aRequirement,aCandidate)) |
|
290 |
||
291 |
def testBldInfExports(self): |
|
292 |
bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs') |
|
293 |
bldInfMakefilePathTestRoot = str(self.__makefilePathTestRoot) + '/metadata/project/' |
|
294 |
||
295 |
depfiles = [] |
|
296 |
bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('exports.inf'), |
|
297 |
self.__gnucpp, depfiles=depfiles, log=self.raptor) |
|
298 |
||
299 |
exports = bldInfObject.getExports(self.defaultPlatform) |
|
300 |
||
301 |
# export1.h |
|
302 |
self.__testExport(exports[0], |
|
303 |
bldInfMakefilePathTestRoot+'bld.infs/export1.h', |
|
304 |
'$(EPOCROOT)/epoc32/include/export1.h', |
|
305 |
'copy') |
|
306 |
||
307 |
# export2.h export_test\export2.h |
|
308 |
self.__testExport(exports[1], |
|
309 |
bldInfMakefilePathTestRoot+'bld.infs/export2.h', |
|
310 |
'$(EPOCROOT)/epoc32/include/export_test/export2.h', |
|
311 |
'copy') |
|
312 |
||
313 |
# export3.h ..\export_test\export3.h |
|
314 |
self.__testExport(exports[2], |
|
315 |
bldInfMakefilePathTestRoot+'bld.infs/export3.h', |
|
316 |
'$(EPOCROOT)/epoc32/export_test/export3.h', |
|
317 |
'copy') |
|
318 |
||
319 |
# export4.h \export_test_abs\export4.h |
|
320 |
self.__testExport(exports[3], |
|
321 |
bldInfMakefilePathTestRoot+'bld.infs/export4.h', |
|
322 |
self.__OSRoot+'/export_test_abs/export4.h', |
|
323 |
'copy') |
|
324 |
||
325 |
# export5.h \epoc32\export_test_abs\export5.h |
|
326 |
self.__testExport(exports[4], |
|
327 |
bldInfMakefilePathTestRoot+'bld.infs/export5.h', |
|
328 |
'$(EPOCROOT)/epoc32/export_test_abs/export5.h', |
|
329 |
'copy') |
|
330 |
||
331 |
# export6.h |..\export_test_rel\export6.h |
|
332 |
self.__testExport(exports[5], |
|
333 |
bldInfMakefilePathTestRoot+'bld.infs/export6.h', |
|
334 |
bldInfMakefilePathTestRoot+'export_test_rel/export6.h', |
|
335 |
'copy') |
|
336 |
||
337 |
# export6.h |\export_test_rel\export7.h |
|
338 |
self.__testExport(exports[6], |
|
339 |
bldInfMakefilePathTestRoot+'bld.infs/export7.h', |
|
340 |
bldInfMakefilePathTestRoot+'bld.infs/export_test_rel/export7.h', |
|
341 |
'copy') |
|
342 |
||
343 |
# export7.h |export_test_rel\export8.h |
|
344 |
self.__testExport(exports[7], |
|
345 |
bldInfMakefilePathTestRoot+'bld.infs/export8.h', |
|
346 |
bldInfMakefilePathTestRoot+'bld.infs/export_test_rel/export8.h', |
|
347 |
'copy') |
|
348 |
||
349 |
# :zip export9.zip |
|
350 |
self.__testExport(exports[8], |
|
351 |
bldInfMakefilePathTestRoot+'bld.infs/export9.zip', |
|
352 |
'$(EPOCROOT)', |
|
353 |
'unzip') |
|
354 |
||
355 |
# :zip export10.zip export_test |
|
356 |
self.__testExport(exports[9], |
|
357 |
bldInfMakefilePathTestRoot+'bld.infs/export10.zip', |
|
358 |
'$(EPOCROOT)/export_test', |
|
359 |
'unzip') |
|
360 |
||
361 |
# :zip export11.zip /export_test |
|
362 |
self.__testExport(exports[10], |
|
363 |
bldInfMakefilePathTestRoot+'bld.infs/export11.zip', |
|
364 |
self.__OSRoot+'/export_test', |
|
365 |
'unzip') |
|
366 |
||
367 |
# :zip export12.zip /epoc32/export_test |
|
368 |
self.__testExport(exports[11], |
|
369 |
bldInfMakefilePathTestRoot+'bld.infs/export12.zip', |
|
370 |
'$(EPOCROOT)/epoc32/export_test', |
|
371 |
'unzip') |
|
372 |
||
373 |
# export13.rsc z:/resource/app/export13.rsc |
|
374 |
# Once for each of the three locations for emulated drives |
|
375 |
# epoc32/data/z/resource/app/export13.rsc *and* in |
|
376 |
# epoc32/release/winscw/udeb/z/resource/app/export13.rsc *and* in |
|
377 |
# epoc32/release/winscw/urel/z/resource/app/export13.rsc |
|
378 |
self.__testExport(exports[12], |
|
379 |
bldInfMakefilePathTestRoot+'bld.infs/export13.rsc', |
|
380 |
'$(EPOCROOT)/epoc32/data/z/resource/app/export13.rsc', |
|
381 |
'copy') |
|
382 |
||
383 |
self.__testExport(exports[12], |
|
384 |
bldInfMakefilePathTestRoot+'bld.infs/export13.rsc', |
|
385 |
'$(EPOCROOT)/epoc32/release/winscw/udeb/z/resource/app/export13.rsc', |
|
386 |
'copy') |
|
387 |
||
388 |
self.__testExport(exports[12], |
|
389 |
bldInfMakefilePathTestRoot+'bld.infs/export13.rsc', |
|
390 |
'$(EPOCROOT)/epoc32/release/winscw/urel/z/resource/app/export13.rsc', |
|
391 |
'copy') |
|
392 |
||
393 |
||
394 |
testExports = bldInfObject.getTestExports(self.defaultPlatform) |
|
395 |
||
396 |
# testexport1.h |
|
397 |
self.__testExport(testExports[0], |
|
398 |
bldInfMakefilePathTestRoot+'bld.infs/testexport1.h', |
|
399 |
bldInfMakefilePathTestRoot+'bld.infs/testexport1.h', |
|
400 |
'copy') |
|
401 |
||
402 |
# testexport2.h export_test_rel\testexport2.h |
|
403 |
self.__testExport(testExports[1], |
|
404 |
bldInfMakefilePathTestRoot+'bld.infs/testexport2.h', |
|
405 |
bldInfMakefilePathTestRoot+'bld.infs/export_test_rel/testexport2.h', |
|
406 |
'copy') |
|
407 |
||
408 |
# testexport3.h ..\export_test_rel\testexport3.h |
|
409 |
self.__testExport(testExports[2], |
|
410 |
bldInfMakefilePathTestRoot+'bld.infs/testexport3.h', |
|
411 |
bldInfMakefilePathTestRoot+'export_test_rel/testexport3.h', |
|
412 |
'copy') |
|
413 |
||
414 |
# testexport4.h \export_test_abs\testexport4.h |
|
415 |
self.__testExport(testExports[3], |
|
416 |
bldInfMakefilePathTestRoot+'bld.infs/testexport4.h', |
|
417 |
self.__OSRoot+'/export_test_abs/testexport4.h', |
|
418 |
'copy') |
|
419 |
||
420 |
# testexport5.h \epoc32\export_test_abs\testexport5.h |
|
421 |
self.__testExport(testExports[4], |
|
422 |
bldInfMakefilePathTestRoot+'bld.infs/testexport5.h', |
|
423 |
'$(EPOCROOT)/epoc32/export_test_abs/testexport5.h', |
|
424 |
'copy') |
|
425 |
||
426 |
# testexport6.h |..\export_test_rel\testexport6.h |
|
427 |
self.__testExport(testExports[5], |
|
428 |
bldInfMakefilePathTestRoot+'bld.infs/testexport6.h', |
|
429 |
bldInfMakefilePathTestRoot+'export_test_rel/testexport6.h', |
|
430 |
'copy') |
|
431 |
||
432 |
# testexport7.h |\export_test_rel\testexport7.h |
|
433 |
self.__testExport(testExports[6], |
|
434 |
bldInfMakefilePathTestRoot+'bld.infs/testexport7.h', |
|
435 |
bldInfMakefilePathTestRoot+'bld.infs/export_test_rel/testexport7.h', |
|
436 |
'copy') |
|
437 |
||
438 |
# testexport8.h |export_test_rel\testexport8.h |
|
439 |
self.__testExport(testExports[7], |
|
440 |
bldInfMakefilePathTestRoot+'bld.infs/testexport8.h', |
|
441 |
bldInfMakefilePathTestRoot+'bld.infs/export_test_rel/testexport8.h', |
|
442 |
'copy') |
|
443 |
||
444 |
# :zip testexport9.zip |
|
445 |
self.__testExport(testExports[8], |
|
446 |
bldInfMakefilePathTestRoot+'bld.infs/testexport9.zip', |
|
447 |
'$(EPOCROOT)', |
|
448 |
'unzip') |
|
449 |
||
450 |
# :zip testexport10.zip export_test |
|
451 |
self.__testExport(testExports[9], |
|
452 |
bldInfMakefilePathTestRoot+'bld.infs/testexport10.zip', |
|
453 |
'$(EPOCROOT)/export_test', |
|
454 |
'unzip') |
|
455 |
||
456 |
# :zip testexport11.zip /export_test |
|
457 |
self.__testExport(testExports[10], |
|
458 |
bldInfMakefilePathTestRoot+'bld.infs/testexport11.zip', |
|
459 |
self.__OSRoot+'/export_test', |
|
460 |
'unzip') |
|
461 |
||
462 |
# :zip testexport12.zip /epoc32/export_test |
|
463 |
self.__testExport(testExports[11], |
|
464 |
bldInfMakefilePathTestRoot+'bld.infs/testexport12.zip', |
|
465 |
'$(EPOCROOT)/epoc32/export_test', |
|
466 |
'unzip') |
|
467 |
||
468 |
# testexport13.rsc z:/resource/app/testexport13.rsc |
|
469 |
# Once for each of the three locations for emulated drives |
|
470 |
# epoc32/data/z/resource/app/testexport13.rsc *and* in |
|
471 |
# epoc32/release/winscw/udeb/z/resource/app/testexport13.rsc *and* in |
|
472 |
# epoc32/release/winscw/urel/z/resource/app/testexport13.rsc |
|
473 |
self.__testExport(testExports[12], |
|
474 |
bldInfMakefilePathTestRoot+'bld.infs/testexport13.rsc', |
|
475 |
'$(EPOCROOT)/epoc32/data/z/resource/app/testexport13.rsc', |
|
476 |
'copy') |
|
477 |
||
478 |
self.__testExport(testExports[12], |
|
479 |
bldInfMakefilePathTestRoot+'bld.infs/testexport13.rsc', |
|
480 |
'$(EPOCROOT)/epoc32/release/winscw/udeb/z/resource/app/testexport13.rsc', |
|
481 |
'copy') |
|
482 |
||
483 |
self.__testExport(testExports[12], |
|
484 |
bldInfMakefilePathTestRoot+'bld.infs/testexport13.rsc', |
|
485 |
'$(EPOCROOT)/epoc32/release/winscw/urel/z/resource/app/testexport13.rsc', |
|
486 |
'copy') |
|
487 |
||
488 |
||
489 |
def __testExtension(self, aExtensionObject, aMakefile, aTestParameters): |
|
490 |
||
491 |
templateExtensionRoot = "" |
|
492 |
||
493 |
if not aMakefile.startswith("$("): |
|
494 |
templateExtensionRoot = '$(MAKEFILE_TEMPLATES)/' |
|
495 |
||
496 |
self.assertEquals(aExtensionObject.getMakefile(), templateExtensionRoot+aMakefile) |
|
497 |
||
498 |
testOptions = aExtensionObject.getOptions() |
|
499 |
testVariables = aExtensionObject.getStandardVariables() |
|
500 |
||
501 |
for testParameter in aTestParameters.keys(): |
|
502 |
if (testParameter.startswith("STDVAR_")): |
|
503 |
stdvar = testParameter.replace("STDVAR_", "") |
|
504 |
stdvalue = aTestParameters.get(testParameter) |
|
505 |
self.assertTrue(testVariables.has_key(stdvar)) |
|
506 |
self.assertEquals(testVariables.get(stdvar), aTestParameters.get(testParameter)) |
|
507 |
else: |
|
508 |
self.assertTrue(testOptions.has_key(testParameter)) |
|
509 |
self.assertEquals(testOptions.get(testParameter), aTestParameters.get(testParameter)) |
|
510 |
||
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
511 |
|
591 | 512 |
def testBldInfExtensions(self): |
513 |
bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs') |
|
514 |
bldInfMakefilePathTestRoot = str(self.__makefilePathTestRoot)+'/metadata/project/bld.infs' |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
515 |
if 'SRCROOT' in os.environ: |
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
516 |
srcroot = os.environ['SRCROOT'] |
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
517 |
else: |
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
518 |
srcroot = os.environ['SRCROOT'] = "x:/somesrcroot" |
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
519 |
|
591 | 520 |
depfiles = [] |
521 |
bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('extensions.inf'), |
|
522 |
self.__gnucpp, depfiles=depfiles, log=self.raptor) |
|
523 |
||
524 |
extensions = bldInfObject.getExtensions(self.ARMV5) |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
525 |
|
591 | 526 |
self.__testExtension(extensions[0], |
527 |
'test/dummyextension1.mk', |
|
528 |
{'TARGET':'dummyoutput1.exe', |
|
529 |
'SOURCES':'dummysource11.cpp dummysource12.cpp dummysource13.cpp', |
|
530 |
'DEPENDENCIES':'dummylib11.lib dummylib12.lib', |
|
531 |
'TOOL':'dummytool1.exe', |
|
532 |
'OPTION11':'option11value', |
|
533 |
'OPTION12':'$(MAKE_VAR)', |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
534 |
'STDVAR_TO_ROOT':srcroot, |
591 | 535 |
'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot, |
536 |
'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot} |
|
537 |
) |
|
538 |
||
539 |
self.__testExtension(extensions[1], |
|
540 |
'test/dummyextension2.mk', |
|
541 |
{'TARGET':'dummyoutput2.exe', |
|
542 |
'SOURCES':'dummysource21.cpp dummysource22.cpp dummysource23.cpp', |
|
543 |
'DEPENDENCIES':'dummylib21.lib dummylib22.lib', |
|
544 |
'TOOL':'dummytool2.exe', |
|
545 |
'OPTION21':'option21value', |
|
546 |
'OPTION22':'$(MAKE_VAR)', |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
547 |
'STDVAR_TO_ROOT':srcroot, |
591 | 548 |
'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot, |
549 |
'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot} |
|
550 |
) |
|
551 |
||
552 |
self.__testExtension(extensions[2], |
|
553 |
'$(' + raptor.env + ')/test/dummyextension3.mk', |
|
554 |
{'TARGET':'dummyoutput3.exe', |
|
555 |
'SOURCES':'dummysource31.cpp dummysource32.cpp dummysource33.cpp', |
|
556 |
'DEPENDENCIES':'dummylib31.lib dummylib32.lib', |
|
557 |
'TOOL':'dummytool3.exe', |
|
558 |
'OPTION31':'option31value', |
|
559 |
'OPTION32':'$(MAKE_VAR)', |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
560 |
'STDVAR_TO_ROOT':srcroot, |
591 | 561 |
'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot, |
562 |
'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot} |
|
563 |
) |
|
564 |
||
565 |
testExtensions = bldInfObject.getTestExtensions(self.ARMV5) |
|
566 |
||
567 |
self.__testExtension(testExtensions[0], |
|
568 |
'test/dummytestextension1.mk', |
|
569 |
{'TARGET':'dummytestoutput1.exe', |
|
570 |
'SOURCES':'dummytestsource11.cpp dummytestsource12.cpp dummytestsource13.cpp', |
|
571 |
'DEPENDENCIES':'dummytestlib11.lib dummytestlib12.lib', |
|
572 |
'TOOL':'dummytesttool1.exe', |
|
573 |
'OPTIONTEST11':'optiontest11value', |
|
574 |
'OPTIONTEST12':'$(MAKE_VAR)', |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
575 |
'STDVAR_TO_ROOT':srcroot, |
591 | 576 |
'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot, |
577 |
'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot} |
|
578 |
) |
|
579 |
||
580 |
self.__testExtension(testExtensions[1], |
|
581 |
'test/dummytestextension2.mk', |
|
582 |
{'TARGET':'dummytestoutput2.exe', |
|
583 |
'SOURCES':'dummytestsource21.cpp dummytestsource22.cpp dummytestsource23.cpp', |
|
584 |
'DEPENDENCIES':'dummytestlib21.lib dummytestlib22.lib', |
|
585 |
'TOOL':'dummytesttool2.exe', |
|
586 |
'OPTIONTEST21':'optiontest21value', |
|
587 |
'OPTIONTEST22':'$(MAKE_VAR)', |
|
616
24e4ef208cca
sbs version 2.14.2
Richard Taylor <richard.i.taylor@nokia.com>
parents:
591
diff
changeset
|
588 |
'STDVAR_TO_ROOT':srcroot, |
591 | 589 |
'STDVAR_TO_BLDINF':bldInfMakefilePathTestRoot, |
590 |
'STDVAR_EXTENSION_ROOT':bldInfMakefilePathTestRoot} |
|
591 |
) |
|
592 |
||
593 |
def testBadBldInfs(self): |
|
594 |
bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs') |
|
595 |
depfiles=[] |
|
596 |
||
597 |
class BadBldInfLogger(object): |
|
598 |
"mock logger to capture Error messages from the parser." |
|
599 |
||
600 |
def __init__(self): |
|
601 |
self.errors = [] |
|
602 |
self.debugOutput = False |
|
603 |
||
604 |
def Error(self, format, *extras, **attributes): |
|
605 |
self.errors.append( ((format % extras), attributes) ) |
|
606 |
||
607 |
def Debug(self, format, *extras, **attributes): |
|
608 |
pass |
|
609 |
||
610 |
logger = BadBldInfLogger() |
|
611 |
||
612 |
# this bld.inf has END lines with no matching START |
|
613 |
bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('bad_lone_end.inf'), |
|
614 |
self.__gnucpp, depfiles=depfiles, |
|
615 |
log=logger) |
|
616 |
||
617 |
# the PRJ_EXTENSIONS section is bad for ARMV5 |
|
618 |
extensions = bldInfObject.getExtensions(self.ARMV5) |
|
619 |
# |
|
620 |
self.assertEquals(len(logger.errors), 1) |
|
621 |
err = logger.errors[0] |
|
622 |
self.assertEquals(err[0], "unmatched END statement in PRJ_EXTENSIONS section") |
|
623 |
self.assertTrue("bldinf" in err[1]) |
|
624 |
self.assertTrue(err[1]["bldinf"].endswith("bad_lone_end.inf")) |
|
625 |
||
626 |
# the PRJ_TESTEXTENSIONS section is bad for WINSCW |
|
627 |
testextensions = bldInfObject.getTestExtensions(self.WINSCW) |
|
628 |
# |
|
629 |
self.assertEquals(len(logger.errors), 2) |
|
630 |
err = logger.errors[1] |
|
631 |
self.assertEquals(err[0], "unmatched END statement in PRJ_TESTEXTENSIONS section") |
|
632 |
self.assertTrue("bldinf" in err[1]) |
|
633 |
self.assertTrue(err[1]["bldinf"].endswith("bad_lone_end.inf")) |
|
634 |
||
635 |
def testBldInfIncludes(self): |
|
636 |
bldInfTestRoot = self.__testRoot.Append('metadata/project/bld.infs/includes') |
|
637 |
depfiles=[] |
|
638 |
bldInfObject = raptor_meta.BldInfFile(bldInfTestRoot.Append('top_level.inf'), |
|
639 |
self.__gnucpp, depfiles=depfiles, log=self.raptor) |
|
640 |
Root = str(bldInfTestRoot) |
|
641 |
||
642 |
mmpFiles = bldInfObject.getMMPList(self.ARMV5) |
|
643 |
self.assertEquals(len(mmpFiles['mmpFileList']), 3) |
|
644 |
self.assertEquals(str(mmpFiles['mmpFileList'][0].filename), Root + "/dir3/down_dir.mmp") |
|
645 |
self.assertEquals(str(mmpFiles['mmpFileList'][1].filename), Root + "/dir1/dir2/up_dir.mmp") |
|
646 |
self.assertEquals(str(mmpFiles['mmpFileList'][2].filename), Root + "/top_level.mmp") |
|
647 |
||
648 |
exports = bldInfObject.getExports(self.ARMV5) |
|
649 |
self.assertEquals(exports[0].getSource(), Root + "/dir3/down_dir_export_source.h") |
|
650 |
self.assertEquals(exports[1].getSource(), Root + "/dir1/dir2/up_dir_export_source.h") |
|
651 |
self.assertEquals(exports[2].getSource(), Root + "/top_level_export_source.h") |
|
652 |
||
653 |
def testMmpIncludes(self): |
|
654 |
mmpTestRoot = self.__testRoot.Append('metadata/project/mmps/includes') |
|
655 |
mmpMakefilePathTestRoot = str(self.__makefilePathTestRoot)+'/metadata/project/mmps/includes' |
|
656 |
||
657 |
depfiles=[] |
|
658 |
bldInfObject = raptor_meta.BldInfFile(mmpTestRoot.Append('top_level.inf'), |
|
659 |
self.__gnucpp, depfiles=depfiles, log=self.raptor) |
|
660 |
||
661 |
mmpFiles = bldInfObject.getMMPList(self.ARMV5) |
|
662 |
mmpdeps = [] |
|
663 |
mmpFile = raptor_meta.MMPFile(mmpFiles['mmpFileList'][0].filename, |
|
664 |
self.__gnucpp, |
|
665 |
bldInfObject, |
|
666 |
depfiles=mmpdeps, |
|
667 |
log=self.raptor) |
|
668 |
||
669 |
self.assertEquals(str(mmpFile.filename), |
|
670 |
str(mmpTestRoot.Append("top_level.mmp"))) |
|
671 |
||
672 |
||
673 |
mmpContent = mmpFile.getContent(self.ARMV5) |
|
674 |
mmpBackend = raptor_meta.MMPRaptorBackend(None, str(mmpFile.filename), str(bldInfObject.filename)) |
|
675 |
mmpParser = mmpparser.MMPParser(mmpBackend) |
|
676 |
parseresult = None |
|
677 |
try: |
|
678 |
parseresult = mmpParser.mmp.parseString(mmpContent) |
|
679 |
except Exception,e: |
|
680 |
pass |
|
681 |
||
682 |
self.assertTrue(parseresult) |
|
683 |
self.assertEquals(parseresult[0],'MMP') |
|
684 |
||
685 |
mmpBackend.finalise(self.ARMV5) |
|
686 |
||
687 |
var = mmpBackend.BuildVariant |
|
688 |
||
689 |
sources = [] |
|
690 |
for i in var.ops: |
|
691 |
if i.name == "SOURCE": |
|
692 |
sources.extend(i.value.split(" ")) |
|
693 |
||
694 |
self.assertTrue((mmpMakefilePathTestRoot+'/top_level.cpp') in sources) |
|
695 |
self.assertTrue((mmpMakefilePathTestRoot+'/dir1/dir2/up_dir.cpp') in sources) |
|
696 |
self.assertTrue((mmpMakefilePathTestRoot+'/dir3/down_dir.cpp') in sources) |
|
697 |
||
698 |
||
699 |
def testDefFileResolution(self): |
|
700 |
||
701 |
class DefFileTest(object): |
|
702 |
""" Test resolveDefFile for a particular set of mmp options """ |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
703 |
def __init__(self, primarydeffile, secondarydeffile, mmpfilename, deffilekeyword, target, nostrictdef, platform): |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
704 |
self.primarydeffile = primarydeffile |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
705 |
self.secondarydeffile = secondarydeffile |
591 | 706 |
self.mmpfilename=mmpfilename |
707 |
self.deffilekeyword=deffilekeyword |
|
708 |
self.target=target |
|
709 |
self.nostrictdef = nostrictdef |
|
710 |
self.platform = platform |
|
711 |
||
712 |
def test(self, raptor): |
|
713 |
m = raptor_meta.MMPRaptorBackend(raptor, self.mmpfilename, "") |
|
714 |
m.deffile = self.deffilekeyword |
|
715 |
m.nostrictdef = self.nostrictdef |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
716 |
(resolvedDefFile, isSecondaryDefFile) = m.resolveDefFile(self.target, self.platform) |
591 | 717 |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
718 |
expectedDefFile = self.primarydeffile |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
719 |
if isSecondaryDefFile: |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
720 |
expectedDefFile = self.secondarydeffile |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
721 |
|
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
722 |
return path_compare_notdrivelettercase(expectedDefFile, resolvedDefFile) |
591 | 723 |
|
724 |
defFileTests = [] |
|
725 |
||
726 |
for testPlat in self.testPlats: |
|
727 |
epocroot = str(testPlat['EPOCROOT']) |
|
728 |
releaseDir = testPlat['PLATFORM'].lower() |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
729 |
|
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
730 |
# Some configurations support both a primary location and a secondary location for .def files |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
731 |
# In these cases, if the primary location .def file doesn't exist the secondary is used. |
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
732 |
primaryDefFileDir = "eabi" |
630 | 733 |
secondaryDefFileDir = "" |
591 | 734 |
if testPlat['PLATFORM'] == "WINSCW": |
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
735 |
primaryDefFileDir = "bwins" |
630 | 736 |
elif testPlat['PLATFORM'] == "X86": |
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
737 |
primaryDefFileDir = "bx86gcc" |
630 | 738 |
secondaryDefFileDir = "eabi" |
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
739 |
|
591 | 740 |
defFileTests.extend([ |
741 |
DefFileTest( |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
742 |
self.__OSRoot+'/test/'+primaryDefFileDir+'/targetu.def', |
630 | 743 |
self.__OSRoot+'/test/'+secondaryDefFileDir+'/targetu.def', |
591 | 744 |
'/test/component/mmpfile.mmp', |
745 |
'', |
|
746 |
'target.exe', |
|
747 |
False, |
|
748 |
testPlat), |
|
749 |
DefFileTest( |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
750 |
self.__OSRoot+'/test/'+primaryDefFileDir+'/target.def', |
630 | 751 |
self.__OSRoot+'/test/'+secondaryDefFileDir+'/target.def', |
591 | 752 |
'/test/component/mmpfile.mmp', |
753 |
'', |
|
754 |
'target.exe', |
|
755 |
True, |
|
756 |
testPlat), |
|
757 |
DefFileTest( |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
758 |
self.__OSRoot+'/test/'+primaryDefFileDir+'/targetu.DEF', |
630 | 759 |
self.__OSRoot+'/test/'+secondaryDefFileDir+'/targetu.DEF', |
591 | 760 |
'/test/component/mmpfile.mmp', |
761 |
'target.DEF', |
|
762 |
'target.exe', |
|
763 |
False, |
|
764 |
testPlat), |
|
765 |
DefFileTest( |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
766 |
self.__OSRoot+'/test/'+primaryDefFileDir+'/target2.DEF', |
630 | 767 |
self.__OSRoot+'/test/'+secondaryDefFileDir+'/target2.DEF', |
591 | 768 |
'/test/component/mmpfile.mmp', |
769 |
'target2.DEF', |
|
770 |
'target.exe', |
|
771 |
True, |
|
772 |
testPlat), |
|
773 |
DefFileTest( |
|
774 |
self.__OSRoot+'/test/component/target2u.DEF', |
|
630 | 775 |
self.__OSRoot+'/test/'+secondaryDefFileDir+'/target2u.DEF', |
591 | 776 |
'/test/component/mmpfile.mmp', |
777 |
'./target2.DEF', |
|
778 |
'target.exe', |
|
779 |
False, |
|
780 |
testPlat), |
|
781 |
DefFileTest( |
|
782 |
self.__OSRoot+'/test/component/target2.DEF', |
|
630 | 783 |
self.__OSRoot+'/test/'+secondaryDefFileDir+'/target2.DEF', |
591 | 784 |
'/test/component/mmpfile.mmp', |
785 |
'./target2.DEF', |
|
786 |
'target.exe', |
|
787 |
True, |
|
788 |
testPlat), |
|
789 |
DefFileTest( |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
790 |
self.__OSRoot+'/test/component/'+primaryDefFileDir+'/target3u.DEF', |
630 | 791 |
self.__OSRoot+'/test/component/'+secondaryDefFileDir+'/target3u.DEF', |
591 | 792 |
'/test/component/mmpfile.mmp', |
793 |
'./~/target3.DEF', |
|
794 |
'target.exe', |
|
795 |
False, |
|
796 |
testPlat), |
|
797 |
DefFileTest( |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
798 |
epocroot+'/epoc32/include/def/'+primaryDefFileDir+'/targetu.def', |
630 | 799 |
epocroot+'/epoc32/include/def/'+secondaryDefFileDir+'/targetu.def', |
591 | 800 |
'/test/component/mmpfile.mmp', |
801 |
'/epoc32/include/def/~/target.def', |
|
802 |
'target.exe', |
|
803 |
False, |
|
804 |
testPlat), |
|
805 |
DefFileTest( |
|
806 |
epocroot+'/epoc32/release/'+releaseDir+'/target.def', |
|
630 | 807 |
epocroot+'/epoc32/release/'+secondaryDefFileDir+'/target.def', |
591 | 808 |
'/test/component/mmpfile.mmp', |
809 |
'/epoc32/release/'+releaseDir+'/target.def', |
|
810 |
'target.exe', |
|
811 |
True, |
|
812 |
testPlat), |
|
813 |
DefFileTest( |
|
814 |
self.__OSRoot+'/deffiles/targetu.def', |
|
630 | 815 |
self.__OSRoot+'/'+secondaryDefFileDir+'/targetu.def', |
591 | 816 |
'/test/component/mmpfile.mmp', |
817 |
'/deffiles/target.def', |
|
818 |
'target.exe', |
|
819 |
False, |
|
820 |
testPlat) |
|
821 |
]) |
|
822 |
||
823 |
for t in defFileTests: |
|
625
a1925fb7753a
sbs version 2.15.0
Richard Taylor <richard.i.taylor@nokia.com>
parents:
616
diff
changeset
|
824 |
result = t.test(self.raptor) |
591 | 825 |
self.assertEquals(result, True) |
826 |
||
827 |
def dummyMetaReader(self): |
|
828 |
"make raptor_meta.MetaReader.__init__ into a none operation" |
|
829 |
self.savedInit = raptor_meta.MetaReader.__init__ |
|
830 |
||
831 |
def DummyMetaReaderInit(self, aRaptor): |
|
832 |
self._MetaReader__Raptor = aRaptor |
|
833 |
||
834 |
raptor_meta.MetaReader.__init__ = DummyMetaReaderInit |
|
835 |
||
836 |
def restoreMetaReader(self): |
|
837 |
"make raptor_meta.MetaReader.__init__ operational again" |
|
838 |
raptor_meta.MetaReader.__init__ = self.savedInit |
|
839 |
||
840 |
def testApplyOsVariant(self): |
|
841 |
self.dummyMetaReader() |
|
842 |
||
843 |
# Mock output class |
|
844 |
class OutputMock(object): |
|
845 |
def write(self, text): |
|
846 |
pass |
|
847 |
||
848 |
bu = raptor_data.BuildUnit("os_variant", []) |
|
849 |
||
850 |
self.raptor.keepGoing = False |
|
851 |
||
852 |
metaReader = raptor_meta.MetaReader(self.raptor) |
|
853 |
metaReader.ApplyOSVariant(bu, ".") |
|
854 |
||
855 |
self.raptor.keepGoing = True |
|
856 |
self.raptor.out = OutputMock() |
|
857 |
metaReader = raptor_meta.MetaReader(self.raptor) |
|
858 |
metaReader.ApplyOSVariant(bu, ".") |
|
859 |
||
860 |
self.restoreMetaReader() |
|
861 |
||
862 |
def __assertEqualStringList(self, aListOne, aListTwo): |
|
863 |
self.assertEquals(len(aListOne), len(aListTwo)) |
|
864 |
||
865 |
i = 0 |
|
866 |
while i < len(aListOne) : |
|
867 |
self.assertEquals(aListOne[i], aListTwo[i]) |
|
868 |
i = i + 1 |
|
869 |
||
870 |
def testOptionReplace(self): |
|
871 |
# Test how we resolve known permutations of values given to the .mmp file OPTION_REPLACE keyword |
|
872 |
mockBackend = raptor_meta.MMPRaptorBackend(self.raptor, "somefile.mmp", "") |
|
873 |
||
874 |
results = mockBackend.resolveOptionReplace('--argA') |
|
875 |
self.__assertEqualStringList(results, ['--argA<->']) |
|
876 |
||
877 |
results = mockBackend.resolveOptionReplace('--argB value') |
|
878 |
self.__assertEqualStringList(results, ['--argB%20<->@@', '@@%<->--argB%20value']) |
|
879 |
||
880 |
results = mockBackend.resolveOptionReplace('--argD value1 --argE') |
|
881 |
self.__assertEqualStringList(results, ['--argD%20<->@@', '@@%<->--argD%20value1', '--argE<->']) |
|
882 |
||
883 |
results = mockBackend.resolveOptionReplace('--argF --argG') |
|
884 |
self.__assertEqualStringList(results, ['--argF<->--argG']) |
|
885 |
||
886 |
results = mockBackend.resolveOptionReplace('--argH --argI value') |
|
887 |
self.__assertEqualStringList(results, ['--argH<->--argI%20value']) |
|
888 |
||
889 |
results = mockBackend.resolveOptionReplace('--argJ value1 --argK value2') |
|
890 |
self.__assertEqualStringList(results, ['--argJ%20<->@@', '@@%<->--argJ%20value1', '--argK%20<->@@', '@@%<->--argK%20value2']) |
|
891 |
||
892 |
results = mockBackend.resolveOptionReplace('--argL value1 --argM value2 --argN --argO') |
|
893 |
self.__assertEqualStringList(results, ['--argL%20<->@@', '@@%<->--argL%20value1', '--argM%20<->@@', '@@%<->--argM%20value2', '--argN<->--argO']) |
|
894 |
||
895 |
results = mockBackend.resolveOptionReplace('--argP value1 value2 --argQ value3 value4') |
|
896 |
self.__assertEqualStringList(results, ['--argP%20<->@@', '@@%<->--argP%20value1', '--argQ%20<->@@', '@@%<->--argQ%20value3']) |
|
897 |
||
898 |
results = mockBackend.resolveOptionReplace('value1 value2') |
|
899 |
self.__assertEqualStringList(results, []) |
|
900 |
||
901 |
results = mockBackend.resolveOptionReplace('value1 --argR') |
|
902 |
self.__assertEqualStringList(results, ['--argR<->']) |
|
903 |
||
904 |
results = mockBackend.resolveOptionReplace('-singleHyphenargS value1 -singleHyphenargT value2') |
|
905 |
self.__assertEqualStringList(results, ['-singleHyphenargS%20<->@@', '@@%<->-singleHyphenargS%20value1', '-singleHyphenargT%20<->@@', '@@%<->-singleHyphenargT%20value2']) |
|
906 |
||
907 |
results = mockBackend.resolveOptionReplace('--assignmentArgU=value1 --assignmentArgV=value2') |
|
908 |
self.__assertEqualStringList(results, ['--assignmentArgU=value1<->--assignmentArgV=value2']) |
|
909 |
||
910 |
def testModuleName(self): |
|
911 |
self.dummyMetaReader() |
|
912 |
||
913 |
# Test how we resolve known permutations of values given to the .mmp file OPTION_REPLACE keyword |
|
914 |
mockBackend = raptor_meta.MetaReader(self.raptor) |
|
915 |
||
916 |
resultsDictList = [ {"bldinf":"Z:/src/romfile/group/tb92/GROUP/bld.inf", "result":"romfile"}, |
|
917 |
{"bldinf":"/src/romfile/group/tb92/GROUP/bld.inf", "result":"romfile"}, |
|
918 |
{"bldinf":"Z:/src/romFile/group/tb92/GROUP/another.inf", "result":"romFile"}, |
|
919 |
{"bldinf":"X:/src/RoMfile/group/bld.inf", "result":"RoMfile"}, |
|
920 |
{"bldinf":"w:/contacts/group/ONgoing/group/bld.inf", "result":"contacts"}, |
|
921 |
{"bldinf":"p:/group/bld.inf", "result":"module"}, |
|
922 |
{"bldinf":"/group/bld.inf", "result":"module"}, |
|
923 |
{"bldinf":"p:/ONGOING/bld.inf", "result":"module"}, |
|
924 |
{"bldinf":"/ONGOING/bld.inf", "result":"module"} |
|
925 |
] |
|
926 |
||
927 |
for result in resultsDictList: |
|
928 |
moduleName = mockBackend.ModuleName(result["bldinf"]) |
|
929 |
self.assertEquals(moduleName, result["result"]) |
|
930 |
||
931 |
self.restoreMetaReader() |
|
932 |
||
933 |
||
934 |
def path_compare_notdrivelettercase(aRequirement, aCandidate): |
|
935 |
if sys.platform.startswith("win"): |
|
936 |
if aRequirement[1] == ":": |
|
937 |
aRequirement = aRequirement[0].lower() + aRequirement[1:] |
|
938 |
aCandidate = aCandidate[0].lower() + aCandidate[1:] |
|
939 |
||
940 |
return aRequirement == aCandidate |
|
941 |
||
942 |
||
943 |
# run all the tests |
|
944 |
||
945 |
from raptor_tests import SmokeTest |
|
946 |
||
947 |
def run(): |
|
948 |
t = SmokeTest() |
|
949 |
t.id = "999" |
|
950 |
t.name = "raptor_meta_unit" |
|
951 |
||
952 |
tests = unittest.makeSuite(TestRaptorMeta) |
|
953 |
result = unittest.TextTestRunner(verbosity=2).run(tests) |
|
954 |
||
955 |
if result.wasSuccessful(): |
|
956 |
t.result = SmokeTest.PASS |
|
957 |
else: |
|
958 |
t.result = SmokeTest.FAIL |
|
959 |
||
960 |
return t |