587
|
1 |
# -*- encoding: latin-1 -*-
|
|
2 |
|
|
3 |
#============================================================================
|
|
4 |
#Name : testconfigurator.py
|
|
5 |
#Part of : Helium
|
|
6 |
|
|
7 |
#Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
8 |
#All rights reserved.
|
|
9 |
#This component and the accompanying materials are made available
|
|
10 |
#under the terms of the License "Eclipse Public License v1.0"
|
|
11 |
#which accompanies this distribution, and is available
|
|
12 |
#at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
13 |
#
|
|
14 |
#Initial Contributors:
|
|
15 |
#Nokia Corporation - initial contribution.
|
|
16 |
#
|
|
17 |
#Contributors:
|
|
18 |
#
|
|
19 |
#Description:
|
|
20 |
#===============================================================================
|
|
21 |
|
|
22 |
"""Parse Symbian SW component for ATS3 testing related information"""
|
|
23 |
|
628
|
24 |
|
587
|
25 |
#R* remove during refactoring
|
|
26 |
|
|
27 |
from path import path # pylint: disable-msg=F0401
|
|
28 |
import ats3.parsers as parser
|
|
29 |
import logging
|
|
30 |
import os
|
|
31 |
import subprocess
|
|
32 |
import fileutils
|
|
33 |
|
|
34 |
_logger = logging.getLogger('ats')
|
|
35 |
|
|
36 |
class Ats3ComponentParser(object):
|
|
37 |
"""
|
|
38 |
Parse Symbian SW component for ATS3 testing related information.
|
|
39 |
|
|
40 |
Parses a component's source directories for testing related settings and
|
|
41 |
files, and generates a TestPlan out of the findings.
|
|
42 |
|
|
43 |
"""
|
|
44 |
|
|
45 |
def __init__(self, config):
|
|
46 |
|
|
47 |
self.target_platform = config.target_platform
|
|
48 |
self.bld_parser = parser.BldFileParser()
|
|
49 |
|
|
50 |
self.data_dirs = config.data_dir
|
|
51 |
self.flash_images = [path(p) for p in config.flash_images]
|
|
52 |
self.tsrc_dir = None
|
|
53 |
self.build_drive = config.build_drive
|
|
54 |
self.target_platform = config.target_platform
|
|
55 |
self.sis_files = config.sis_files
|
|
56 |
self.cfg_harness = config.harness
|
|
57 |
self.test_timeout = config.test_timeout
|
|
58 |
self.trace_enabled = config.trace_enabled
|
|
59 |
self.excludable_dlls = []
|
|
60 |
self.custom_dir = None
|
588
|
61 |
self.specific_pkg = config.specific_pkg
|
587
|
62 |
|
|
63 |
def insert_testset_stif(self, src_dst, pkg_paths):
|
|
64 |
"""Inserts test set data to test plan for stif"""
|
|
65 |
if not pkg_paths:
|
|
66 |
try:
|
|
67 |
|
|
68 |
tsrc_testdata_files = self.tsrc_data_files()
|
|
69 |
for data_file in tsrc_testdata_files:
|
|
70 |
if "\\mmc\\" in data_file.lower():
|
|
71 |
src_dst.append((data_file, path(r"e:\testing\data").joinpath(data_file.name), "data"))
|
|
72 |
elif "\\c\\" in data_file.lower():
|
|
73 |
src_dst.append((data_file, path(r"c:\testing\data").joinpath(data_file.name), "data"))
|
|
74 |
else:
|
|
75 |
src_dst.append((data_file, path(r"c:\testing\data").joinpath(data_file.name), "data"))
|
|
76 |
except OSError:
|
|
77 |
_logger.warning("No testdata folder" )
|
|
78 |
tsrc_testdata_files = None
|
|
79 |
|
|
80 |
else:
|
|
81 |
try:
|
|
82 |
src_dst = pkg_paths
|
|
83 |
except OSError:
|
|
84 |
_logger.warning("No pkg file found in the directory ( %s )" % self.tsrc_pkg_dir)
|
|
85 |
src_dst = []
|
|
86 |
except IndexError:
|
|
87 |
_logger.warning("No pkg file found in the directory ( %s )" % self.tsrc_pkg_dir)
|
|
88 |
src_dst = []
|
|
89 |
|
|
90 |
return src_dst
|
|
91 |
|
|
92 |
def insert_test_set(self, test_plan, tsrc_dir, _paths_dict_):
|
|
93 |
"""Parse tsrc directory, storing data into the test plan."""
|
|
94 |
self.tsrc_dir = path(tsrc_dir) # Store current test source dir.
|
|
95 |
tsrc_testdata_files = []
|
|
96 |
tsrc_config_files = []
|
|
97 |
self.custom_dir = None
|
|
98 |
engine_ini_file = None
|
|
99 |
test_harness = self.cfg_harness
|
|
100 |
src_dst = []
|
|
101 |
pmd_files = []
|
|
102 |
trace_activation_files = []
|
628
|
103 |
dll_files = {}
|
587
|
104 |
|
|
105 |
if not os.path.exists( self.tsrc_dir ):
|
|
106 |
_logger.error("Missing test source directory: %s", self.tsrc_dir)
|
|
107 |
else:
|
|
108 |
self.custom_dir = self.tsrc_dir.joinpath("custom")
|
|
109 |
_logger.debug("using customized testing from %s" % self.custom_dir)
|
|
110 |
if os.path.exists(self.tsrc_bld_dir.joinpath("group","bld.inf")):
|
588
|
111 |
bldinf = self.tsrc_bld_dir.joinpath("group","bld.inf")
|
587
|
112 |
else:
|
588
|
113 |
bldinf = self.tsrc_bld_dir.joinpath("bld.inf")
|
|
114 |
mmp_files = self.bld_parser.get_test_mmp_files(bldinf)
|
|
115 |
mmp_parser = parser.MmpFileParser(bldinf)
|
|
116 |
test_harness = mmp_parser.get_harness(mmp_files)
|
|
117 |
pkg_parser = parser.PkgFileParser(bldinf, self.target_platform.replace(" ", "_")+".pkg", self.specific_pkg)
|
|
118 |
pkg_paths = pkg_parser.get_data_files(self.tsrc_pkg_files(_paths_dict_), self.build_drive)
|
587
|
119 |
if self.trace_enabled == "True":
|
|
120 |
try:
|
|
121 |
pmd_files = self.tsrc_pmd_files()
|
|
122 |
except OSError:
|
|
123 |
_logger.warning("No pmd file in output-folder.")
|
|
124 |
try:
|
|
125 |
trace_activation_files = self.tsrc_trace_activation_files()
|
|
126 |
except OSError:
|
|
127 |
_logger.warning("No trace activation files in trace init folder")
|
|
128 |
if trace_activation_files and not pmd_files:
|
|
129 |
_logger.warning("Trace activation files available but NOT pmd file.")
|
|
130 |
elif pmd_files and not trace_activation_files:
|
|
131 |
_logger.warning("Pmd file available but NO trace activation files.")
|
|
132 |
|
|
133 |
if test_harness == "STIF" or test_harness == "STIFUNIT" or test_harness == "GENERIC":
|
|
134 |
src_dst = self.insert_testset_stif(src_dst, pkg_paths)
|
|
135 |
|
|
136 |
elif test_harness == "EUNIT":
|
|
137 |
try:
|
588
|
138 |
src_dst = pkg_parser.get_data_files(self.tsrc_pkg_files(_paths_dict_), self.build_drive)
|
628
|
139 |
#collecting dll files and their harness for the test component, it will be
|
|
140 |
# compared while writing 'execute' step in the test.xml generation
|
|
141 |
for sub_component in _paths_dict_[tsrc_dir]['content'].keys():
|
|
142 |
dll_files.update(_paths_dict_[tsrc_dir]['content'][sub_component]['dll_files'])
|
587
|
143 |
|
|
144 |
except OSError:
|
|
145 |
_logger.warning("No pkg file found in the directory ( %s )" % self.tsrc_pkg_dir)
|
|
146 |
src_dst = []
|
|
147 |
except IndexError:
|
|
148 |
_logger.warning("No pkg file found in the directory ( %s )" % self.tsrc_pkg_dir)
|
|
149 |
src_dst = []
|
|
150 |
try:
|
|
151 |
testmodule_files = self.tsrc_dll_files()
|
|
152 |
|
|
153 |
for dll_file in testmodule_files:
|
|
154 |
if not self.check_dll_duplication(dll_file.name, src_dst):
|
588
|
155 |
_dll_type_ = mmp_parser.get_dll_type(self.tsrc_bld_dir)
|
587
|
156 |
|
|
157 |
if dll_file.name in self.excludable_dlls:
|
|
158 |
src_dst.append((dll_file, path(r"c:\sys\bin").joinpath(dll_file.name), "data:%s" % _dll_type_))
|
|
159 |
else:
|
|
160 |
src_dst.append((dll_file, path(r"c:\sys\bin").joinpath(dll_file.name), "testmodule"))
|
|
161 |
|
|
162 |
except OSError:
|
|
163 |
_logger.warning("No dll files in dll folders" )
|
|
164 |
tsrc_testdata_files = None
|
|
165 |
|
|
166 |
if test_plan['multiset_enabled'] == 'True':
|
|
167 |
backup = []
|
|
168 |
temp_src_dst = {}
|
|
169 |
for x_temp in src_dst:
|
|
170 |
if len(x_temp) < 4:
|
|
171 |
backup.append(x_temp)
|
|
172 |
for x_temp in src_dst:
|
|
173 |
if len(x_temp) > 3:
|
|
174 |
if temp_src_dst.has_key(x_temp[3]):
|
|
175 |
temp_src_dst[x_temp[3]].append(x_temp)
|
|
176 |
else:
|
|
177 |
temp_src_dst[x_temp[3]] = [x_temp] + backup
|
|
178 |
|
|
179 |
for pkg in temp_src_dst.keys():
|
|
180 |
src_dst = temp_src_dst[pkg]
|
|
181 |
|
|
182 |
if self.trace_enabled == "True":
|
|
183 |
test_plan.insert_set(data_files=tsrc_testdata_files,
|
|
184 |
config_files=tsrc_config_files,
|
|
185 |
engine_ini_file=engine_ini_file,
|
|
186 |
image_files=self.flash_images,
|
|
187 |
sis_files=self.sis_files,
|
|
188 |
#testmodule_files=self.tsrc_dll_files(),
|
|
189 |
test_timeout=list(self.test_timeout),
|
|
190 |
test_harness=test_harness,
|
|
191 |
src_dst=src_dst,
|
|
192 |
pmd_files=pmd_files,
|
|
193 |
trace_activation_files=trace_activation_files,
|
|
194 |
custom_dir=self.custom_dir,
|
628
|
195 |
dll_files=dll_files,
|
587
|
196 |
component_path=tsrc_dir)
|
|
197 |
else:
|
|
198 |
test_plan.insert_set(image_files=self.flash_images,
|
|
199 |
sis_files=self.sis_files,
|
|
200 |
test_timeout=list(self.test_timeout),
|
|
201 |
test_harness=test_harness,
|
|
202 |
src_dst=src_dst,
|
|
203 |
custom_dir=self.custom_dir,
|
628
|
204 |
dll_files = dll_files,
|
587
|
205 |
component_path=tsrc_dir)
|
|
206 |
else:
|
|
207 |
if self.trace_enabled == "True":
|
|
208 |
test_plan.insert_set(data_files=tsrc_testdata_files,
|
|
209 |
config_files=tsrc_config_files,
|
|
210 |
engine_ini_file=engine_ini_file,
|
|
211 |
image_files=self.flash_images,
|
|
212 |
sis_files=self.sis_files,
|
|
213 |
#testmodule_files=self.tsrc_dll_files(),
|
|
214 |
test_timeout=list(self.test_timeout),
|
|
215 |
test_harness=test_harness,
|
|
216 |
src_dst=src_dst,
|
|
217 |
pmd_files=pmd_files,
|
|
218 |
trace_activation_files=trace_activation_files,
|
|
219 |
custom_dir=self.custom_dir,
|
628
|
220 |
dll_files = dll_files,
|
587
|
221 |
component_path=tsrc_dir)
|
|
222 |
else:
|
|
223 |
test_plan.insert_set(image_files=self.flash_images,
|
|
224 |
sis_files=self.sis_files,
|
|
225 |
test_timeout=list(self.test_timeout),
|
|
226 |
test_harness=test_harness,
|
|
227 |
src_dst=src_dst,
|
|
228 |
custom_dir=self.custom_dir,
|
628
|
229 |
dll_files = dll_files,
|
587
|
230 |
component_path=tsrc_dir)
|
|
231 |
|
|
232 |
def check_dll_duplication(self, _dll_file_, _src_dst_ ):
|
|
233 |
"""Checks if the dll is already in the dictionary, created by pkg file"""
|
|
234 |
for item in _src_dst_:
|
|
235 |
first = item[0]
|
628
|
236 |
if _dll_file_.lower() in first.lower():
|
|
237 |
return True
|
|
238 |
return False
|
587
|
239 |
|
|
240 |
@property
|
|
241 |
def tsrc_bld_dir(self):
|
|
242 |
"""Component's build directory."""
|
|
243 |
return self.tsrc_dir
|
|
244 |
|
|
245 |
@property
|
|
246 |
def tsrc_conf_dir(self):
|
|
247 |
"""Component's configuration file directory."""
|
|
248 |
return self.tsrc_dir.joinpath("conf")
|
|
249 |
|
|
250 |
@property
|
|
251 |
def tsrc_custom_dir(self):
|
|
252 |
"""Component's test customization directory."""
|
|
253 |
return self.tsrc_dir.joinpath("custom")
|
|
254 |
|
|
255 |
|
|
256 |
@property
|
|
257 |
def tsrc_data_dirs(self):
|
|
258 |
"""Component's data directories."""
|
|
259 |
return [self.tsrc_dir.joinpath(d) for d in self.data_dirs]
|
|
260 |
|
|
261 |
@property
|
|
262 |
def tsrc_init_dir(self):
|
|
263 |
"""Component's initialization file directory."""
|
|
264 |
return self.tsrc_dir.joinpath("init")
|
|
265 |
|
|
266 |
@property
|
|
267 |
def tsrc_pkg_dir(self):
|
|
268 |
"""Component's .pkg -file directory"""
|
|
269 |
return self.tsrc_dir
|
|
270 |
|
|
271 |
@property
|
|
272 |
def tsrc_trace_activation_dir(self):
|
|
273 |
"""Component's trace activation file directory"""
|
|
274 |
return self.tsrc_dir.joinpath("trace_init")
|
|
275 |
|
|
276 |
@property
|
|
277 |
def tsrc_pmd_dir(self):
|
|
278 |
"""Component's pmd file directory"""
|
|
279 |
pmd_dir = self.build_drive + os.sep
|
|
280 |
return pmd_dir.joinpath("output", "pmd")
|
|
281 |
|
|
282 |
def tsrc_pmd_files(self):
|
|
283 |
"""Component's trace pmd files from the {build_drive}\output directory"""
|
|
284 |
return list(self.tsrc_pmd_dir.walkfiles("*.pmd"))
|
|
285 |
|
|
286 |
def tsrc_trace_activation_files(self):
|
|
287 |
"""Component's trace activation files, from the rtace_init directory."""
|
|
288 |
return list(self.tsrc_trace_activation_dir.walkfiles("*.xml"))
|
|
289 |
|
|
290 |
def tsrc_config_files(self):
|
|
291 |
"""Component's configuration files, from the conf directory."""
|
|
292 |
return list(self.tsrc_conf_dir.walkfiles("*.cfg"))
|
|
293 |
|
|
294 |
def tsrc_ini_files(self):
|
|
295 |
"""Component's initialiation files, from the ini directory."""
|
|
296 |
return list(self.tsrc_init_dir.walkfiles("*.ini"))
|
|
297 |
|
|
298 |
def tsrc_data_files(self):
|
|
299 |
"""Component's data files, from data directories."""
|
|
300 |
files = []
|
|
301 |
files2 = []
|
|
302 |
for data_dir in self.tsrc_data_dirs:
|
|
303 |
if data_dir.exists():
|
|
304 |
files.extend(list(data_dir.walkfiles()))
|
|
305 |
|
|
306 |
#Remove dist policy files
|
|
307 |
for data_file in files:
|
|
308 |
if data_file.name.lower() != "distribution.policy.s60":
|
|
309 |
files2.append(data_file)
|
|
310 |
return files2
|
|
311 |
|
|
312 |
def tsrc_dll_files(self):
|
|
313 |
"""Component's DLL files, reported by ABLD BUILD."""
|
|
314 |
|
|
315 |
dlls = []
|
|
316 |
orig_dir = os.getcwd()
|
|
317 |
try:
|
|
318 |
os.chdir(self.tsrc_bld_dir)
|
|
319 |
#os.system("abld test build %s" % self.target_platform)
|
|
320 |
|
|
321 |
if os.sep == '\\':
|
|
322 |
raptor_cmd = fileutils.which("sbs.bat")
|
|
323 |
else:
|
|
324 |
raptor_cmd = fileutils.which("sbs")
|
|
325 |
if raptor_cmd:
|
|
326 |
process = subprocess.Popen("sbs --what -c %s.test" % self.target_platform.replace(' ', '_'), shell=True, stdout=subprocess.PIPE)
|
|
327 |
else:
|
|
328 |
os.system("bldmake bldfiles")
|
|
329 |
process = subprocess.Popen("abld -w test build %s" % self.target_platform, shell=True, stdout=subprocess.PIPE)
|
|
330 |
pipe = process.communicate()[0]
|
|
331 |
|
|
332 |
for line in pipe.split('\n'):
|
|
333 |
_logger.debug(line.strip())
|
|
334 |
target = path(line.strip())
|
|
335 |
if target.ext == ".dll":
|
|
336 |
|
|
337 |
build_target = self.build_drive.joinpath(target).normpath()
|
|
338 |
if not build_target.exists():
|
|
339 |
_logger.warning("not found: %s" % build_target)
|
|
340 |
else:
|
|
341 |
dlls.append(build_target)
|
|
342 |
finally:
|
|
343 |
os.chdir(orig_dir)
|
|
344 |
return dlls
|
|
345 |
|
|
346 |
def tsrc_pkg_files(self, _dict_):
|
|
347 |
"""Component's package files, from the group directory"""
|
|
348 |
pkg_dirs = []
|
|
349 |
for sub_component in _dict_[self.tsrc_pkg_dir]['content'].keys():
|
|
350 |
pkg_dirs.append(sub_component)
|
|
351 |
return pkg_dirs
|