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