587
|
1 |
# -*- encoding: latin-1 -*-
|
|
2 |
|
|
3 |
#============================================================================
|
|
4 |
#Name : test_parsers.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 |
import os
|
|
23 |
import tempfile
|
|
24 |
import mocker
|
|
25 |
from path import path
|
|
26 |
import StringIO
|
|
27 |
|
|
28 |
import ats3.parsers
|
|
29 |
import ats3.testconfigurator
|
|
30 |
|
|
31 |
import logging
|
|
32 |
logging.getLogger().setLevel(logging.ERROR)
|
|
33 |
|
|
34 |
TSRC_DIR = None
|
|
35 |
|
|
36 |
def setup_module():
|
|
37 |
"""Setup the test environment. The testing of the test parser script requires spesific
|
|
38 |
structure to be available with bld.inf files (with the content written into those)."""
|
|
39 |
global TSRC_DIR
|
|
40 |
TSRC_DIR = path(tempfile.mkdtemp()).normpath()
|
|
41 |
test_component = TSRC_DIR
|
|
42 |
for path_parts in (("tsrc", "group"),
|
|
43 |
("tsrc", "tc1", "group"),
|
|
44 |
("tsrc", "tc1", "data"),
|
|
45 |
("tsrc", "tc1", "dependent_1", "group"),
|
|
46 |
("tsrc", "tc1", "dependent_2", "group"),
|
|
47 |
("tsrc", "tc1", "subtest", "group"),
|
|
48 |
("tsrc", "tc1", "subtest", "data"),
|
|
49 |
("tsrc", "tc1", "subtest", "if_test", "group"),
|
|
50 |
("tsrc", "tc2", "group"),
|
|
51 |
("tsrc", "tc2", "data"),
|
|
52 |
("tsrc", "tc3", "group"),
|
|
53 |
("tsrc", "tc3", "data"),
|
|
54 |
("tmp", "macros"),
|
|
55 |
):
|
|
56 |
filepath = path.joinpath(test_component, *path_parts).normpath()
|
|
57 |
if not filepath.exists():
|
|
58 |
os.makedirs(filepath)
|
|
59 |
|
|
60 |
|
|
61 |
tsrc = open(path.joinpath(TSRC_DIR, "tsrc", "group", "bld.inf"), 'w')
|
|
62 |
tsrc.write(
|
|
63 |
r"""
|
|
64 |
#include "../tc1/group/bld.inf"
|
|
65 |
#include "../tc2/group/bld.inf"
|
|
66 |
#include "../tc3/group/bld.inf"
|
|
67 |
|
|
68 |
PRJ_TESTMMPFILES
|
|
69 |
|
|
70 |
""")
|
|
71 |
tsrc.close()
|
|
72 |
|
|
73 |
tc1 = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "group", "bld.inf"), 'w')
|
|
74 |
tc1.write(
|
|
75 |
r"""
|
|
76 |
#include "../dependent_1/group/bld.inf"
|
|
77 |
#include "../dependent_2/group/bld.inf"
|
|
78 |
#include "../subtest/group/bld.inf"
|
|
79 |
|
|
80 |
PRJ_TESTMMPFILES
|
|
81 |
tc1.mmp
|
|
82 |
|
|
83 |
PRJ_MMPFILES
|
|
84 |
not_included.mmp
|
|
85 |
""")
|
|
86 |
tc1.close()
|
|
87 |
|
|
88 |
tc1_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "group", "tc1.mmp"), 'w')
|
|
89 |
tc1_mmp.write(
|
|
90 |
r"""
|
|
91 |
TARGET tc1.dll
|
|
92 |
TARGETTYPE dll
|
|
93 |
LIBRARY stiftestinterface.lib
|
|
94 |
LIBRARY user.lib
|
|
95 |
""")
|
|
96 |
tc1_mmp.close()
|
|
97 |
|
|
98 |
tc1_sub = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "subtest", "group", "bld.inf"), "w")
|
|
99 |
tc1_sub.write(
|
|
100 |
r"""
|
|
101 |
PRJ_TESTMMPFILES
|
|
102 |
sub_test.mmp
|
|
103 |
#ifndef RD_TEST1
|
|
104 |
#include "../if_test/group/bld.inf"
|
|
105 |
#endif
|
|
106 |
""")
|
|
107 |
tc1_sub.close()
|
|
108 |
tc1_sub_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "subtest", "group", "sub_test.mmp"), 'w')
|
|
109 |
tc1_sub_mmp.write(
|
|
110 |
r"""
|
|
111 |
TARGET sub_test.dll
|
|
112 |
TARGETTYPE dll
|
|
113 |
LIBRARY stiftestinterface.lib
|
|
114 |
""")
|
|
115 |
tc1_sub_mmp.close()
|
|
116 |
|
|
117 |
|
|
118 |
tc1_if = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "subtest", "if_test", "group", "bld.inf"), "w")
|
|
119 |
tc1_if.write(
|
|
120 |
r"""
|
|
121 |
PRJ_TESTMMPFILES
|
|
122 |
if_test.mmp
|
|
123 |
""")
|
|
124 |
tc1_if.close()
|
|
125 |
tc1_if_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "subtest", "if_test", "group", "if_test.mmp"), 'w')
|
|
126 |
tc1_if_mmp.write(
|
|
127 |
r"""
|
|
128 |
TARGET tc1_if.dll
|
|
129 |
TARGETTYPE dll
|
|
130 |
LIBRARY stifunit.lib
|
|
131 |
""")
|
|
132 |
tc1_if_mmp.close()
|
|
133 |
|
|
134 |
tc1_dep1 = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_1", "group", "bld.inf"), "w")
|
|
135 |
tc1_dep1.write(
|
|
136 |
r"""
|
|
137 |
PRJ_TESTMMPFILES
|
|
138 |
dependent_1.mmp
|
|
139 |
onemore.mmp
|
|
140 |
""")
|
|
141 |
tc1_dep1.close()
|
|
142 |
|
|
143 |
tc1_dep1_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_1", "group", "dependent_1.mmp"), 'w')
|
|
144 |
tc1_dep1_mmp.write(
|
|
145 |
r"""
|
|
146 |
TARGET dependent_1.dll
|
|
147 |
TARGETTYPE PLUGIN
|
|
148 |
""")
|
|
149 |
tc1_dep1_mmp.close()
|
|
150 |
|
|
151 |
tc1_dep2 = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_2", "group", "bld.inf"), "w")
|
|
152 |
tc1_dep2.write(
|
|
153 |
r"""
|
|
154 |
PRJ_TESTMMPFILES
|
|
155 |
dependent_2.mmp
|
|
156 |
""")
|
|
157 |
tc1_dep2.close()
|
|
158 |
|
|
159 |
tc1_dep2_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "dependent_2", "group", "dependent_2.mmp"), 'w')
|
|
160 |
tc1_dep2_mmp.write(
|
|
161 |
r"""
|
|
162 |
TARGET dependent_2.dll
|
|
163 |
TARGETTYPE PLUGIN
|
|
164 |
""")
|
|
165 |
tc1_dep2_mmp.close()
|
|
166 |
|
|
167 |
tc1_pkg = open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "group", "tc1.pkg"), 'w')
|
|
168 |
tc1_pkg.write(
|
|
169 |
r"""
|
|
170 |
;Language - standard language definitions
|
|
171 |
&EN
|
|
172 |
|
|
173 |
; standard SIS file header
|
|
174 |
#{"BTEngTestApp"},(0x04DA27D5),1,0,0
|
|
175 |
|
|
176 |
;Supports Series 60 v 3.0
|
|
177 |
(0x101F7961), 0, 0, 0, {"Series60ProductID"}
|
|
178 |
|
|
179 |
;Localized Vendor Name
|
|
180 |
%{"BTEngTestApp"}
|
|
181 |
|
|
182 |
;Unique Vendor name
|
|
183 |
:"Nokia"
|
|
184 |
|
|
185 |
; Files to copy
|
|
186 |
"..\data\file1.dll"-"c:\sys\bin\file1.dll"
|
|
187 |
"..\data\file1.txt"-"e:\sys\bin\file1.txt" , FF ; FF stands for Normal file
|
|
188 |
"..\data\file2.mp3"-"e:\sys\bin\file2.mp3"
|
|
189 |
"..\data\TestFramework.ini"-"c:\sys\bin\TestFramework.ini"
|
|
190 |
;"..\xyz\TestFramework.ini"-"!:\sys\bin\TestFramework.ini" (commented line)
|
|
191 |
"../data/temp.ini"-"!:/sys/bin/temp.ini" , FF ; "something here"
|
|
192 |
"..\data\tc1.cfg"-"e:\sys\bin\tc1.cfg"
|
|
193 |
"..\data\tc1.sisx"-"e:\sys\bin\tc1.sisx"
|
|
194 |
"..\data\DUMP.xyz"-"e:\sys\bin\DUMP.xyz"
|
|
195 |
|
|
196 |
|
|
197 |
""".replace('\\', os.sep))
|
|
198 |
tc1_pkg.close()
|
|
199 |
|
|
200 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "data", "file1.dll"), 'w').close()
|
|
201 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "data", "file1.txt"), 'w').close()
|
|
202 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "data", "file2.mp3"), 'w').close()
|
|
203 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "data", "TestFramework.ini"), 'w').close()
|
|
204 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "data", "temp.ini"), 'w').close()
|
|
205 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc1", "data", "DUMP.xyz"), 'w').close()
|
|
206 |
|
|
207 |
tc2 = open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "group", "bld.inf"), "w")
|
|
208 |
tc2.write(
|
|
209 |
r"""
|
|
210 |
PRJ_TESTMMPFILES
|
|
211 |
tc2.mmp
|
|
212 |
""")
|
|
213 |
tc2.close()
|
|
214 |
tc2_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "group", "tc2.mmp"), 'w')
|
|
215 |
tc2_mmp.write(
|
|
216 |
r"""
|
|
217 |
TARGET tc2.dll
|
|
218 |
TARGETTYPE dll
|
|
219 |
LIBRARY EUnit.lib
|
|
220 |
""")
|
|
221 |
tc2_mmp.close()
|
|
222 |
|
|
223 |
tc2_pkg = open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "group", "tc2.pkg"), 'w')
|
|
224 |
tc2_pkg.write(
|
|
225 |
r"""
|
|
226 |
;Language - standard language definitions
|
|
227 |
&EN
|
|
228 |
|
|
229 |
; standard SIS file header
|
|
230 |
#{"BTEngTestApp"},(0x04DA27D5),1,0,0
|
|
231 |
|
|
232 |
;Supports Series 60 v 3.0
|
|
233 |
(0x101F7961), 0, 0, 0, {"Series60ProductID"}
|
|
234 |
|
|
235 |
;Localized Vendor Name
|
|
236 |
%{"BTEngTestApp"}
|
|
237 |
|
|
238 |
;Unique Vendor name
|
|
239 |
:"Nokia"
|
|
240 |
|
|
241 |
; Files to copy
|
|
242 |
"..\data\file1.dll"-"c:\sys\bin\file1.dll"
|
|
243 |
"..\data\file1.txt"-"e:\sys\bin\file1.txt"
|
|
244 |
"..\data\file2.mp3"-"e:\sys\bin\file2.mp3"
|
|
245 |
"..\data\TestFramework.ini"-"!:\sys\bin\TestFramework.ini" , FF ; FF stands for Normal file
|
|
246 |
"..\data\tc2.cfg"-"!:\sys\bin\tc2.cfg"
|
|
247 |
""".replace('\\', os.sep))
|
|
248 |
tc2_pkg.close()
|
|
249 |
|
|
250 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "data", "file1.dll"), 'w').close()
|
|
251 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "data", "file1.txt"), 'w').close()
|
|
252 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "data", "file2.mp3"), 'w').close()
|
|
253 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "data", "TestFramework.ini"), 'w').close()
|
|
254 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "data", "tc2.cfg"), 'w').close()
|
|
255 |
|
|
256 |
|
|
257 |
tc3 = open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "group", "bld.inf"), "w")
|
|
258 |
tc3.write(
|
|
259 |
r"""
|
|
260 |
PRJ_TESTMMPFILES
|
|
261 |
tc3.mmp
|
|
262 |
""")
|
|
263 |
tc3.close()
|
|
264 |
tc3_mmp = open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "group", "tc3.mmp"), 'w')
|
|
265 |
tc3_mmp.write(
|
|
266 |
r"""
|
|
267 |
TARGET tc3.dll
|
|
268 |
TARGETTYPE dll
|
|
269 |
LIBRARY EUnit.lib
|
|
270 |
""")
|
|
271 |
tc3_mmp.close()
|
|
272 |
|
|
273 |
tc3_pkg = open(path.joinpath(TSRC_DIR, "tsrc", "tc2", "group", "tc2.pkg"), 'w')
|
|
274 |
tc3_pkg.write(
|
|
275 |
r"""
|
|
276 |
;Language - standard language definitions
|
|
277 |
&EN
|
|
278 |
|
|
279 |
; standard SIS file header
|
|
280 |
#{"BTEngTestApp"},(0x04DA27D5),1,0,0
|
|
281 |
|
|
282 |
;Supports Series 60 v 3.0
|
|
283 |
(0x101F7961), 0, 0, 0, {"Series60ProductID"}
|
|
284 |
|
|
285 |
;Localized Vendor Name
|
|
286 |
%{"BTEngTestApp"}
|
|
287 |
|
|
288 |
;Unique Vendor name
|
|
289 |
:"Nokia"
|
|
290 |
|
|
291 |
; Files to copy
|
|
292 |
"..\data\file1.dll"-"c:\sys\bin\file1.dll"
|
|
293 |
"..\data\file1.txt"-"e:\sys\bin\file1.txt"
|
|
294 |
"..\data\file2.mp3"-"e:\sys\bin\file2.mp3" , FF ; FF stands for Normal file
|
|
295 |
"..\data\TestFramework.ini"-"!:\sys\bin\TestFramework.ini"
|
|
296 |
"..\data\temp.ini"-"!:\sys\bin\temp.ini"
|
|
297 |
"..\data\tc2.cfg"-"!:\sys\bin\tc2.cfg"
|
|
298 |
""".replace('\\', os.sep))
|
|
299 |
tc3_pkg.close()
|
|
300 |
|
|
301 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "data", "file1.dll"), 'w').close()
|
|
302 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "data", "file1.txt"), 'w').close()
|
|
303 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "data", "file2.mp3"), 'w').close()
|
|
304 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "data", "TestFramework.ini"), 'w').close()
|
|
305 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "data", "temp.ini"), 'w').close()
|
|
306 |
open(path.joinpath(TSRC_DIR, "tsrc", "tc3", "data", "tc2.cfg"), 'w').close()
|
|
307 |
|
|
308 |
macros = open(path.joinpath(TSRC_DIR, "tmp", "macros", "bldcodeline.hrh"), 'w')
|
|
309 |
macros.write(
|
|
310 |
r"""
|
|
311 |
#ifndef __BLDCODELINE_HRH
|
|
312 |
#define __BLDCODELINE_HRH
|
|
313 |
|
|
314 |
/** #RD_TEST */
|
|
315 |
#define RD_TEST1
|
|
316 |
|
|
317 |
/** #RD_TEST2 */
|
|
318 |
#define RD_TEST2
|
|
319 |
|
|
320 |
/** #RD_TEST3 */
|
|
321 |
#define RD_TEST3
|
|
322 |
|
|
323 |
#endif // __BLDCODELINE_HRH
|
|
324 |
|
|
325 |
""")
|
|
326 |
macros.close()
|
|
327 |
|
|
328 |
|
|
329 |
def teardown_module():
|
|
330 |
""" Cleanup environment after testing. """
|
|
331 |
def __init__():
|
|
332 |
TSRC_DIR.rmtree()
|
|
333 |
|
|
334 |
|
|
335 |
# list_of_paths = []
|
|
336 |
# list_of_paths = path.walk(TSRC_DIR)
|
|
337 |
# for file in list_of_paths[2]:
|
|
338 |
# continue
|
|
339 |
# for dir in list_of_paths[1]:
|
|
340 |
# continue
|
|
341 |
|
|
342 |
|
|
343 |
class TestPkgFileParser(mocker.MockerTestCase):
|
|
344 |
"""Testing Package file parser"""
|
|
345 |
def __init__(self, methodName="runTest"):
|
|
346 |
mocker.MockerTestCase.__init__(self, methodName)
|
|
347 |
|
|
348 |
def setUp(self):
|
|
349 |
"""Setup for PkgFile parser"""
|
|
350 |
self.pkg_file_path1 = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "tc1", "group"))
|
|
351 |
self.pkg_file_path2 = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "tc2", "group"))
|
|
352 |
self.pkg_file_path3 = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "tc3", "group"))
|
|
353 |
self.tcp = ats3.parsers.PkgFileParser("tc1.pkg")
|
|
354 |
|
|
355 |
self.data_files = [
|
|
356 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "file1.dll").normpath(), path(r"c:" + os.sep + "sys" + os.sep + "bin" + os.sep + "file1.dll").normpath(), "testmodule", 'tc1.pkg'),
|
|
357 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "file1.txt").normpath(), path(r"e:" + os.sep + "sys" + os.sep + "bin" + os.sep + "file1.txt").normpath(), "data", 'tc1.pkg'),
|
|
358 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "file2.mp3").normpath(), path(r"e:" + os.sep + "sys" + os.sep + "bin" + os.sep + "file2.mp3").normpath(), "data", 'tc1.pkg'),
|
|
359 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "TestFramework.ini").normpath(), path(r"c:" + os.sep + "sys" + os.sep + "bin" + os.sep + "TestFramework.ini").normpath(), "engine_ini", 'tc1.pkg'),
|
|
360 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "temp.ini").normpath(), path(r"c:" + os.sep + "sys" + os.sep + "bin" + os.sep + "temp.ini").normpath(), "engine_ini", 'tc1.pkg'),
|
|
361 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "tc1.cfg").normpath(), path(r"e:" + os.sep + "sys" + os.sep + "bin" + os.sep + "tc1.cfg").normpath(), "conf", 'tc1.pkg'),
|
|
362 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "tc1.sisx").normpath(), path(r"e:" + os.sep + "sys" + os.sep + "bin" + os.sep + "tc1.sisx").normpath(), "", 'tc1.pkg'),
|
|
363 |
(path(TSRC_DIR+r"" + os.sep + "tsrc" + os.sep + "tc1" + os.sep + "data" + os.sep + "DUMP.xyz").normpath(), path(r"e:" + os.sep + "sys" + os.sep + "bin" + os.sep + "DUMP.xyz").normpath(), "data", 'tc1.pkg'),
|
|
364 |
]
|
618
|
365 |
for p, _, _, _ in self.data_files:
|
|
366 |
open(p, 'w').close()
|
587
|
367 |
|
|
368 |
def test_get_pkg_files(self):
|
|
369 |
"""Test if pkg files are returned from a specified location"""
|
|
370 |
assert self.tcp.get_pkg_files(self.pkg_file_path1, False) == ["tc1.pkg"]
|
|
371 |
|
|
372 |
|
|
373 |
|
|
374 |
def test_parser_receives_path(self):
|
|
375 |
"""Test if None is returned when a path to PKG file is incorrect"""
|
|
376 |
assert self.tcp.get_data_files("string") == []
|
|
377 |
|
|
378 |
def test_data_files_creation_without_exclude(self):
|
|
379 |
""" Tests if PKG file parser creates data files list as expected without exclude"""
|
|
380 |
assert self.tcp.get_data_files(self.pkg_file_path1, "d:") == self.data_files
|
|
381 |
|
|
382 |
def test_data_files_creation_with_exclude(self):
|
|
383 |
""" Tests if PKG file parser creates data files list as expected with exclude"""
|
|
384 |
self.data_files.pop()
|
|
385 |
assert self.tcp.get_data_files(self.pkg_file_path1, "d:", "\.xyz") == self.data_files
|
|
386 |
|
|
387 |
def test_data_files_creation_without_drive_with_exclude(self):
|
|
388 |
""" Tests if PKG file parser creates data files list as expected without drive with exclude"""
|
|
389 |
|
|
390 |
self.data_files.pop()
|
|
391 |
assert self.tcp.get_data_files(self.pkg_file_path1, "", "\.xyz") == self.data_files
|
|
392 |
|
|
393 |
def test_data_files_creation_without_drive_without_exclude(self):
|
|
394 |
""" Tests if PKG file parser creates data files list as expected without drive without exclude"""
|
|
395 |
|
|
396 |
assert self.tcp.get_data_files(self.pkg_file_path1, "") == self.data_files
|
|
397 |
|
|
398 |
|
|
399 |
class TestCppParser(mocker.MockerTestCase):
|
|
400 |
"""Testing CPP parser"""
|
|
401 |
def __init__(self, methodName="runTest"):
|
|
402 |
mocker.MockerTestCase.__init__(self, methodName)
|
|
403 |
|
|
404 |
def setUp(self):
|
|
405 |
self.bld_path = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "group"))
|
|
406 |
self.bld_path_comp1 = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "tc1", "group"))
|
|
407 |
self.tcp = ats3.parsers.CppParser()
|
|
408 |
upper_bld_path = os.path.dirname(self.bld_path)
|
|
409 |
|
|
410 |
self.dependent_paths_dictionary = {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/if_test/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/if_test/group"))): {'pkg_files': [], 'mmp_files': ['if_test.mmp'], 'harness': 'STIFUNIT', 'type': ''}}},
|
|
411 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2//group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2/group"))): {'pkg_files': ['tc2.pkg'], 'mmp_files': ['tc2.mmp'], 'harness': 'EUNIT', 'type': 'executable'}}},
|
|
412 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group"))): {'pkg_files':[], 'mmp_files': ['tc3.mmp'], 'harness': 'EUNIT', 'type': 'executable'}}},
|
|
413 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group"))): {'content': {(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/subtest/group"))): {'pkg_files': [], 'mmp_files': ['sub_test.mmp'], 'harness': 'STIF', 'type': 'executable'},
|
|
414 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/dependent_1/group"))): {'pkg_files': [], 'mmp_files': ['dependent_1.mmp', 'onemore.mmp'], 'harness': "", 'type':''},
|
|
415 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/dependent_2/group"))): {'pkg_files': [], 'mmp_files': ['dependent_2.mmp'], 'harness': "", 'type': 'dependent'},
|
|
416 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group"))): {'pkg_files': ['tc1.pkg'], 'mmp_files': ['tc1.mmp'],'harness': 'STIF', 'type': 'executable'}}}}
|
|
417 |
|
|
418 |
self.extended_path_list = [(os.path.normpath(upper_bld_path), upper_bld_path),
|
|
419 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group")), upper_bld_path),
|
|
420 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_1/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
|
|
421 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_2/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
|
|
422 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../subtest/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group"))),
|
|
423 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../subtest/group/../if_test/group")), os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../subtest/group"))),
|
|
424 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2/group")), upper_bld_path),
|
|
425 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group")), upper_bld_path),
|
|
426 |
(os.path.normpath(os.path.join(upper_bld_path, "../tsrc/group/group")), upper_bld_path),
|
|
427 |
]
|
|
428 |
self.path_list = [os.path.normpath(os.path.join(upper_bld_path, "group")),
|
|
429 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group")),
|
|
430 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_1/group")),
|
|
431 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../dependent_2/group")),
|
|
432 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../subtest/group")),
|
|
433 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc1/group/../subtest/group/../if_test/group")),
|
|
434 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc2/group")),
|
|
435 |
os.path.normpath(os.path.join(upper_bld_path, "../tsrc/tc3/group")),
|
|
436 |
]
|
|
437 |
self.path_list_without_undefined = [os.path.normpath(upper_bld_path),
|
|
438 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group")),
|
|
439 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../dependent_1/group")),
|
|
440 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../dependent_2/group")),
|
|
441 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../subtest/group")),
|
|
442 |
os.path.normpath(os.path.join(upper_bld_path, "../tc2/group")),
|
|
443 |
os.path.normpath(os.path.join(upper_bld_path, "../tc3/group")),
|
|
444 |
]
|
|
445 |
self.cpp_output = ['# 1 "bld.inf"',
|
|
446 |
'# 1 "../tc1/group/bld.inf" 1',
|
|
447 |
'# 1 "../tc1/group/../dependent_1/group/bld.inf" 1',
|
|
448 |
'# 4 "../tc1/group/bld.inf" 2',
|
|
449 |
'# 1 "../tc1/group/../dependent_2/group/bld.inf" 1',
|
|
450 |
'# 5 "../tc1/group/bld.inf" 2',
|
|
451 |
'# 1 "../tc1/group/../subtest/group/bld.inf" 1',
|
|
452 |
'# 1 "../tc1/group/../subtest/group/../if_test/group/bld.inf" 1',
|
|
453 |
'# 4 "../tc1/group/../subtest/group/bld.inf" 2',
|
|
454 |
'# 6 "../tc1/group/bld.inf" 2',
|
|
455 |
'# 3 "bld.inf" 2',
|
|
456 |
'# 1 "../tc2/group/bld.inf" 1',
|
|
457 |
'# 4 "bld.inf" 2',
|
|
458 |
'# 1 "../tc3/group/bld.inf" 1',
|
|
459 |
'# 5 "bld.inf" 2']
|
|
460 |
|
|
461 |
|
|
462 |
|
|
463 |
def test_pathlist_output(self):
|
|
464 |
"""Test get_cpp_output-method using "n" -parameter"""
|
|
465 |
assert self.path_list.sort() == self.tcp.get_cpp_output(self.bld_path, "n").sort()
|
|
466 |
|
|
467 |
def test_extended_pathlist_output(self):
|
|
468 |
"""Test get_cpp_output-method using "e" -parameter"""
|
|
469 |
assert self.extended_path_list.sort() == self.tcp.get_cpp_output(self.bld_path, "e").sort()
|
|
470 |
|
|
471 |
def test_dictionary_pathlist_output(self):
|
|
472 |
"""Test get_cpp_output-method using "d" -parameter (dependent paths)"""
|
|
473 |
output = """# 1 "bld.inf"
|
|
474 |
|
|
475 |
# 1 "../tc1/group/bld.inf" 1
|
|
476 |
|
|
477 |
# 1 "../tc1/group/../dependent_1/group/bld.inf" 1
|
|
478 |
|
|
479 |
PRJ_TESTMMPFILES
|
|
480 |
dependent_1.mmp
|
|
481 |
onemore.mmp
|
|
482 |
|
|
483 |
# 2 "../tc1/group/bld.inf" 2
|
|
484 |
|
|
485 |
# 1 "../tc1/group/../dependent_2/group/bld.inf" 1
|
|
486 |
|
|
487 |
PRJ_TESTMMPFILES
|
|
488 |
dependent_2.mmp
|
|
489 |
|
|
490 |
# 3 "../tc1/group/bld.inf" 2
|
|
491 |
|
|
492 |
# 1 "../tc1/group/../subtest/group/bld.inf" 1
|
|
493 |
|
|
494 |
PRJ_TESTMMPFILES
|
|
495 |
sub_test.mmp
|
|
496 |
|
|
497 |
# 1 "../tc1/group/../subtest/group/../if_test/group/bld.inf" 1
|
|
498 |
|
|
499 |
PRJ_TESTMMPFILES
|
|
500 |
if_test.mmp
|
|
501 |
|
|
502 |
# 5 "../tc1/group/../subtest/group/bld.inf" 2
|
|
503 |
|
|
504 |
|
|
505 |
|
|
506 |
# 4 "../tc1/group/bld.inf" 2
|
|
507 |
|
|
508 |
|
|
509 |
PRJ_TESTMMPFILES
|
|
510 |
tc1.mmp
|
|
511 |
|
|
512 |
PRJ_MMPFILES
|
|
513 |
not_included.mmp
|
|
514 |
|
|
515 |
# 2 "bld.inf" 2
|
|
516 |
|
|
517 |
# 1 "../tc2/group/bld.inf" 1
|
|
518 |
|
|
519 |
PRJ_TESTMMPFILES
|
|
520 |
tc2.mmp
|
|
521 |
|
|
522 |
# 3 "bld.inf" 2
|
|
523 |
|
|
524 |
# 1 "../tc3/group/bld.inf" 1
|
|
525 |
|
|
526 |
PRJ_TESTMMPFILES
|
|
527 |
tc3.mmp
|
|
528 |
|
|
529 |
# 4 "bld.inf" 2
|
|
530 |
|
|
531 |
|
|
532 |
PRJ_TESTMMPFILES
|
|
533 |
|
|
534 |
|
|
535 |
"""
|
|
536 |
|
|
537 |
result = self.tcp.create_dependency_dictionary(StringIO.StringIO(output), self.bld_path)
|
|
538 |
print "INPUT :", self.dependent_paths_dictionary
|
|
539 |
print "OUTPUT:", result
|
|
540 |
|
|
541 |
assert self.dependent_paths_dictionary == result
|
|
542 |
|
|
543 |
def test_conditional_cpp_parsing(self):
|
|
544 |
"""Test functionality of cpp parser when removing conditionals"""
|
|
545 |
assert self.path_list_without_undefined.sort() == self.tcp.get_cpp_output(bld_path=self.bld_path, output_parameter="n", imacros=os.path.normpath(os.path.join(TSRC_DIR, "tmp", "macros", "bldcodeline.hrh"))).sort()
|
|
546 |
|
|
547 |
class TestBldFileParser(mocker.MockerTestCase):
|
|
548 |
"""Testing BldFileParser Class"""
|
|
549 |
|
|
550 |
def __init__(self, methodName="runTest"):
|
|
551 |
mocker.MockerTestCase.__init__(self, methodName)
|
|
552 |
|
|
553 |
def setUp(self):
|
|
554 |
"""Setup for BldFile parser"""
|
|
555 |
|
|
556 |
self.bld_path = path.joinpath(TSRC_DIR, "tsrc", "group", "bld.inf").normpath()
|
|
557 |
upper_bld_path = self.bld_path.dirname()
|
|
558 |
self.tcp = ats3.parsers.BldFileParser()
|
|
559 |
|
|
560 |
self.test_mmp_files = [
|
|
561 |
['tc1.mmp'],
|
|
562 |
['dependent_1.mmp', 'onemore.mmp'],
|
|
563 |
['dependent_2.mmp'],
|
|
564 |
['sub_test.mmp'],
|
|
565 |
['if_test.mmp'],
|
|
566 |
['tc2.mmp'],
|
|
567 |
["tc3.mmp"],
|
|
568 |
]
|
|
569 |
|
|
570 |
self.path_list = [path.joinpath(upper_bld_path, "../tc1/group").normpath(),
|
|
571 |
path.joinpath(upper_bld_path, "../tc1/group/../dependent_1/group").normpath(),
|
|
572 |
path.joinpath(upper_bld_path, "../tc1/group/../dependent_2/group").normpath(),
|
|
573 |
path.joinpath(upper_bld_path, "../tc1/group/../subtest/group").normpath(),
|
|
574 |
path.joinpath(upper_bld_path, "../tc1/group/../subtest/group/../if_test/group").normpath(),
|
|
575 |
path.joinpath(upper_bld_path, "../tc2/group").normpath(),
|
|
576 |
path.joinpath(upper_bld_path, "../tc3/group").normpath(),
|
|
577 |
]
|
|
578 |
|
|
579 |
|
|
580 |
def test_testmmp_files_with_full_path(self):
|
|
581 |
"""Test if mmp file is returned with its full path"""
|
|
582 |
self.mmp_file_path = [path.joinpath(TSRC_DIR, "tsrc", "tc1", "group", "tc1.mmp").normpath()]
|
|
583 |
assert self.tcp.get_test_mmp_files(os.path.normpath(os.path.join(self.path_list[0], "bld.inf"))) == self.mmp_file_path
|
|
584 |
|
|
585 |
|
|
586 |
|
|
587 |
def test_testmmp_files(self):
|
|
588 |
"""Tests if test mmp files are included"""
|
|
589 |
self.lst_test_mmp = []
|
|
590 |
|
|
591 |
for p in self.path_list:
|
|
592 |
self.lst_test_mmp.append(self.tcp.get_test_mmp_files(os.path.normpath(os.path.join(p, "bld.inf")), False))
|
|
593 |
|
|
594 |
assert self.lst_test_mmp == self.test_mmp_files
|
|
595 |
|
|
596 |
def test_ignore_comments(self):
|
|
597 |
""" Test if comments are ignored correctly. """
|
|
598 |
for input_, output in [
|
|
599 |
("abc.mmp /* apuva.mmp */ xyz.mmp", ("abc.mmp xyz.mmp")),
|
|
600 |
("abc.mmp /* apuva.mmp */", ("abc.mmp")),
|
|
601 |
("/* apuva.mmp */", ""),
|
|
602 |
(" // apuva.mmp", ""),
|
|
603 |
(" apuva.mmp", "apuva.mmp"),
|
|
604 |
("xyz.mmp // apuva.mmp", "xyz.mmp"),
|
|
605 |
("abc.mmp /* apuva.mmp */ xyz.mmp //rst.mmp", ("abc.mmp xyz.mmp")),
|
|
606 |
]:
|
|
607 |
assert self.tcp.ignore_comments_from_input(input_) == output
|
|
608 |
|
|
609 |
def test_broken_path(self):
|
|
610 |
"""Tests if 'None' is returned when path is broken"""
|
|
611 |
upper_bld_path = os.path.dirname(self.bld_path)
|
|
612 |
assert self.tcp.get_test_mmp_files(os.path.normpath(os.path.join(upper_bld_path, "../tc99/group"))) == None
|
|
613 |
|
|
614 |
def test_empty_parameter(self):
|
|
615 |
"""Tests if 'None' is returned when bld file path is empty"""
|
|
616 |
upper_bld_path = os.path.dirname(self.bld_path)
|
|
617 |
assert self.tcp.get_test_mmp_files("") == None
|
|
618 |
|
|
619 |
|
|
620 |
class TestMmpFileParser(mocker.MockerTestCase):
|
|
621 |
"""Testing MmpFileParser Class"""
|
|
622 |
def __init__(self, methodName="runTest"):
|
|
623 |
mocker.MockerTestCase.__init__(self, methodName)
|
|
624 |
|
|
625 |
def setUp(self):
|
|
626 |
self.bld_path = os.path.normpath(os.path.join(TSRC_DIR, "tsrc", "group", "bld.inf"))
|
|
627 |
upper_bld_path = os.path.dirname(self.bld_path)
|
|
628 |
self.tcp = ats3.parsers.MmpFileParser()
|
|
629 |
self.tc1_type = "dll"
|
|
630 |
self.tc1_name = "tc1.dll"
|
|
631 |
self.tc1_dll_type = "executable"
|
|
632 |
self.tc1_harness = "STIF"
|
|
633 |
self.tc1_libraries = ['stiftestinterface.lib', 'user.lib']
|
|
634 |
self.tc1_all = (self.tc1_name, self.tc1_type, self.tc1_libraries, self.tc1_harness)
|
|
635 |
self.tc1_no_harness = (self.tc1_name, self.tc1_type, self.tc1_libraries)
|
|
636 |
self.tc1_name_type = (self.tc1_name, self.tc1_type)
|
|
637 |
self.tc1_iftest_harness = "STIFUNIT"
|
|
638 |
self.tc1_iftest_name = "tc1_if.dll"
|
|
639 |
self.tc1_iftest_type = "dll"
|
|
640 |
|
|
641 |
self.test_mmp_files = [['tc1.mmp'], ['dependent_1.mmp', 'onemore.mmp'], ['dependent_2.mmp'], ['sub_test.mmp'], ['if_test.mmp'],
|
|
642 |
['tc2.mmp'], ["tc3.mmp"]]
|
|
643 |
|
|
644 |
self.path_list = [os.path.normpath(os.path.join(upper_bld_path, "../tc1/group")),
|
|
645 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../dependent_1/group")),
|
|
646 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../dependent_2/group")),
|
|
647 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../subtest/group")),
|
|
648 |
os.path.normpath(os.path.join(upper_bld_path, "../tc1/group/../subtest/group/../if_test/group")),
|
|
649 |
os.path.normpath(os.path.join(upper_bld_path, "../tc2/group")),
|
|
650 |
os.path.normpath(os.path.join(upper_bld_path, "../tc3/group")),
|
|
651 |
]
|
|
652 |
|
|
653 |
def test_get_dlltype(self):
|
|
654 |
"""Test if get_filetype returns right type for given mmp"""
|
|
655 |
assert self.tc1_dll_type == self.tcp.get_dll_type(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')))
|
|
656 |
|
|
657 |
def test_get_target_filename(self):
|
|
658 |
"""Test if get_filename returns right name for dll for given mmp"""
|
|
659 |
assert self.tc1_name == self.tcp.get_target_filename(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')))
|
|
660 |
|
|
661 |
def test_get_libraries(self):
|
|
662 |
"""Test if get_harness returns right harness for given mmp"""
|
|
663 |
assert self.tc1_libraries == self.tcp.get_libraries(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')))
|
|
664 |
|
|
665 |
def test_get_harness(self):
|
|
666 |
"""Test if get_harness returns right harness for given mmp"""
|
|
667 |
assert self.tc1_harness == self.tcp.get_harness(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')))
|
|
668 |
|
|
669 |
def test_read_information_method(self):
|
|
670 |
"""Test if read_information_from_mmp returns wanted output for given parameter and mmp-file"""
|
|
671 |
assert self.tc1_all == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 0)
|
|
672 |
assert self.tc1_no_harness == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 1)
|
|
673 |
assert self.tc1_name_type == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 2)
|
|
674 |
assert self.tc1_name == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 3)
|
|
675 |
assert self.tc1_type == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 4)
|
|
676 |
assert self.tc1_libraries == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 5)
|
|
677 |
assert self.tc1_harness == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 6)
|
|
678 |
assert self.tc1_iftest_name == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[4], 'if_test.mmp')), 3)
|
|
679 |
assert self.tc1_iftest_type == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[4], 'if_test.mmp')), 4)
|
|
680 |
assert self.tc1_iftest_harness == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[4], 'if_test.mmp')), 6)
|
|
681 |
assert self.tc1_dll_type == self.tcp.read_information_from_mmp(os.path.normpath(os.path.join(self.path_list[0], 'tc1.mmp')), 7)
|
|
682 |
|
|
683 |
class TestParsers(mocker.MockerTestCase):
|
|
684 |
"""Testing Parsers functionality"""
|
|
685 |
def __init__(self, methodName="runTest"):
|
|
686 |
mocker.MockerTestCase.__init__(self, methodName)
|
|
687 |
|
|
688 |
def setUp(self):
|
|
689 |
pass
|