12
|
1 |
#
|
|
2 |
# Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
3 |
# All rights reserved.
|
|
4 |
# This component and the accompanying materials are made available
|
|
5 |
# under the terms of "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 |
#
|
|
16 |
|
|
17 |
import os
|
|
18 |
import time
|
|
19 |
import sys
|
|
20 |
import inspect
|
|
21 |
import testcases
|
|
22 |
import shutil
|
|
23 |
import platform
|
|
24 |
|
|
25 |
if os.name == 'nt':
|
|
26 |
path = os.path.dirname(sys.argv[0])
|
|
27 |
else:
|
|
28 |
path = os.getcwd()
|
|
29 |
|
|
30 |
TC_DIR = path
|
|
31 |
TEMP_DIR = TC_DIR + os.sep + 'temp'
|
|
32 |
TOOLS_DIR = TC_DIR + os.sep + os.pardir + os.sep + os.pardir
|
|
33 |
EXEC_DIR = TC_DIR + os.sep + os.pardir + os.sep + "bin"
|
|
34 |
|
|
35 |
time_taken = 0
|
|
36 |
total_time_taken = 0
|
|
37 |
totalCount = 0
|
|
38 |
timeval = time.strftime("%a %b %d, %Y at %H:%M:%S", time.localtime())
|
|
39 |
|
|
40 |
if os.environ.get('RVCT22BIN') is None:
|
|
41 |
print 'Environment Variable RVCT22BIN must be set before starting the test harness'
|
|
42 |
sys.exit()
|
|
43 |
|
|
44 |
report_file = 0
|
|
45 |
passed = 0
|
|
46 |
failed = 0
|
|
47 |
ostr = ""
|
|
48 |
|
|
49 |
def UpdateTimeTaken(tm):
|
|
50 |
global time_taken, total_time_taken
|
|
51 |
time_taken = tm
|
|
52 |
total_time_taken += tm
|
|
53 |
|
|
54 |
|
|
55 |
def write(key, res):
|
|
56 |
global passed
|
|
57 |
global failed
|
|
58 |
global totalCount
|
|
59 |
global ostr
|
|
60 |
totalCount = totalCount + 1
|
|
61 |
ostr = ostr+" <testcase classname=\"BCFilter\" name=\""+key+"\" time=\""+str(round(time_taken,3))+"\">\n"
|
|
62 |
if res[2] == 'PASSED':
|
|
63 |
passed = passed + 1
|
|
64 |
else:
|
|
65 |
failed = failed + 1
|
|
66 |
ostr = ostr+" <failure message=\"Failed\" type=\"Failed\">Failed</failure>\n"
|
|
67 |
ostr = ostr+" <expresults>"+res[0]+"</expresults>\n"
|
|
68 |
ostr = ostr+" <actresults>"+res[1]+"</actresults>\n"
|
|
69 |
ostr = ostr+" </testcase>\n"
|
|
70 |
|
|
71 |
class registry:
|
|
72 |
_register = {}
|
|
73 |
items = 0
|
|
74 |
cur_item = -1
|
|
75 |
keys = []
|
|
76 |
def __init__(self):
|
|
77 |
pass
|
|
78 |
|
|
79 |
def __iter__(self):
|
|
80 |
return self
|
|
81 |
|
|
82 |
def __getitem__(self, item):
|
|
83 |
return self._register[item]
|
|
84 |
|
|
85 |
def next(self):
|
|
86 |
if self.cur_item >= (self.items-1):
|
|
87 |
self.cur_item = -1
|
|
88 |
raise StopIteration
|
|
89 |
else:
|
|
90 |
self.cur_item = self.cur_item + 1
|
|
91 |
return tuple([ self.keys[self.cur_item],self._register[self.keys[self.cur_item]] ])
|
|
92 |
|
|
93 |
def register(self, key, val):
|
|
94 |
self._register[key] = val
|
|
95 |
self.items = self.items + 1
|
|
96 |
self.keys.append(key)
|
|
97 |
|
|
98 |
def deregister(self, key):
|
|
99 |
if self._register.has_key(key):
|
|
100 |
self._register.pop(key)
|
|
101 |
self.items = self.items - 1
|
|
102 |
|
|
103 |
def next_entry(self):
|
|
104 |
if self.cur_item < (self.items-1):
|
|
105 |
self.cur_item = self.cur_item + 1
|
|
106 |
return tuple([ self.keys[self.cur_item],self._register[self.keys[self.cur_item]] ])
|
|
107 |
else:
|
|
108 |
return tuple()
|
|
109 |
|
|
110 |
def prev_entry(self):
|
|
111 |
if self.cur_item != -1:
|
|
112 |
self.cur_item = self.cur_item - 1
|
|
113 |
return tuple([ self.keys[self.cur_item], self._register[self.keys[self.cur_item]] ])
|
|
114 |
else:
|
|
115 |
return tuple()
|
|
116 |
|
|
117 |
def count():
|
|
118 |
return self.items
|
|
119 |
|
|
120 |
def setUp(key):
|
|
121 |
print '\n---------------------------------------------------------------'
|
|
122 |
|
|
123 |
def tearDown():
|
|
124 |
print '\n---------------------------------------------------------------'
|
|
125 |
|
|
126 |
def testAll(db):
|
|
127 |
global ostr
|
|
128 |
result = 0
|
|
129 |
os.chdir(TC_DIR)
|
|
130 |
for key, value in db:
|
|
131 |
print '\n---------------------------------------------------------------'
|
|
132 |
stime = time.clock()
|
|
133 |
res = value()
|
|
134 |
etime = time.clock()
|
|
135 |
print '\n---------------------------------------------------------------'
|
|
136 |
UpdateTimeTaken(etime-stime)
|
|
137 |
write(key, res)
|
|
138 |
|
|
139 |
def register_tc(db):
|
|
140 |
index = 3
|
|
141 |
if 'c' == sys.argv[2]:
|
|
142 |
index = 4
|
|
143 |
if len(sys.argv) > index:
|
|
144 |
cases = []
|
|
145 |
file = open( sys.argv[index] )
|
|
146 |
for line in file:
|
|
147 |
cases.append(line.rstrip('\r\n').lower())
|
|
148 |
file.close()
|
|
149 |
for key,value in inspect.getmembers(testcases):
|
|
150 |
if inspect.isfunction(value) and key.split('_')[0] == 'test':
|
|
151 |
if len(sys.argv) > index:
|
|
152 |
if key in cases:
|
|
153 |
db.register(key, value)
|
|
154 |
else:
|
|
155 |
db.register(key, value)
|
|
156 |
|
|
157 |
|
|
158 |
def open_results():
|
|
159 |
if os.path.exists(REPORT) and os.name == 'nt':
|
|
160 |
os.startfile(REPORT)
|
|
161 |
return
|
|
162 |
|
|
163 |
def write_header(file):
|
|
164 |
global failed
|
|
165 |
global totalCount
|
|
166 |
global total_time_taken
|
|
167 |
file.write('<?xml version="1.0" encoding="UTF-8" standalone="no" ?>\n')
|
|
168 |
file.write('<?xml-stylesheet type="text/xsl" href="checkbctestresults.xsl"?>\n')
|
|
169 |
file.write("<testsuite errors=\"0\" failures=\""+str(failed)+"\" hostname=\""+platform.node()+"\" name=\"BCFilter\" tests=\""+str(totalCount)+"\" time=\""+str(round(total_time_taken,3))+"\" timestamp=\""+str(timeval)+"\">\n")
|
|
170 |
file.write("<properties>\n</properties>\n")
|
|
171 |
|
|
172 |
def write_footer(file, db):
|
|
173 |
global ostr
|
|
174 |
file.write(ostr)
|
|
175 |
file.write("</testsuite>\n")
|
|
176 |
file.close()
|
|
177 |
|
|
178 |
def copy_toolset():
|
|
179 |
dir = os.getcwd()
|
|
180 |
changed_TOOL_DIR = TOOLS_DIR;
|
|
181 |
HA=""
|
|
182 |
BCF=""
|
|
183 |
LA=""
|
|
184 |
|
|
185 |
file = open( sys.argv[1] )
|
|
186 |
cases = file.readlines()
|
|
187 |
file.close()
|
|
188 |
for tc in cases:
|
|
189 |
temp = tc.find('checkbc')
|
|
190 |
if(temp!=-1):
|
|
191 |
if(tc.split('=')[1].split(';')[0]== 'trunk'):
|
|
192 |
changed_TOOL_DIR = changed_TOOL_DIR+ os.sep + os.pardir
|
|
193 |
elif(tc.split('=')[1].split(';')[0]!= 'bin'):
|
|
194 |
changed_TOOL_DIR = changed_TOOL_DIR+ os.sep + os.pardir+ os.sep + os.pardir
|
|
195 |
|
|
196 |
for tc in cases:
|
|
197 |
temp = tc.find('ha')
|
|
198 |
if(temp != -1):
|
|
199 |
haDir = tc.split('=')[1].split(';')[0]
|
|
200 |
if(haDir == 'trunk'):
|
|
201 |
HA = changed_TOOL_DIR+os.sep+"headeranalyser"+os.sep+"trunk"+os.sep+"bin"
|
|
202 |
elif(haDir != 'bin'):
|
|
203 |
HA = changed_TOOL_DIR+os.sep+"headeranalyser"+os.sep+"tags"+os.sep+haDir+os.sep+"bin"
|
|
204 |
else:
|
|
205 |
HA = changed_TOOL_DIR+os.sep+"headeranalyser"+os.sep+"bin"
|
|
206 |
|
|
207 |
for tc in cases:
|
|
208 |
temp = tc.find('bcf')
|
|
209 |
if(temp != -1):
|
|
210 |
bcDir = tc.split('=')[1].split(';')[0]
|
|
211 |
if(bcDir == 'trunk'):
|
|
212 |
BCF = changed_TOOL_DIR+os.sep+"bcfilter"+os.sep+"trunk"+os.sep+"bin"
|
|
213 |
elif(bcDir != 'bin'):
|
|
214 |
BCF = changed_TOOL_DIR+os.sep+"bcfilter"+os.sep+"tags"+os.sep+bcDir+os.sep+"bin"
|
|
215 |
else:
|
|
216 |
BCF = changed_TOOL_DIR+os.sep+"bcfilter"+os.sep+"bin"
|
|
217 |
|
|
218 |
for tc in cases:
|
|
219 |
temp = tc.find('la')
|
|
220 |
if(temp != -1):
|
|
221 |
laDir = tc.split('=')[1].split(';')[0]
|
|
222 |
if(laDir == 'trunk'):
|
|
223 |
LA = changed_TOOL_DIR+os.sep+"libraryanalyser"+os.sep+"trunk"+os.sep+"bin"
|
|
224 |
elif(laDir != 'bin'):
|
|
225 |
LA = changed_TOOL_DIR+os.sep+"libraryanalyser"+os.sep+"tags"+os.sep+laDir+os.sep+"bin"
|
|
226 |
else:
|
|
227 |
LA = changed_TOOL_DIR+os.sep+"ordinalchecker"+os.sep+"bin"
|
|
228 |
|
|
229 |
os.chdir( TC_DIR + os.sep + os.pardir )
|
|
230 |
if not os.path.exists(EXEC_DIR):
|
|
231 |
os.makedirs(EXEC_DIR)
|
|
232 |
|
|
233 |
copy(HA+os.sep+"forced_9.1.h" ,"bin"+os.sep )
|
|
234 |
copy(HA+os.sep+"forced_9.2.h" ,"bin"+os.sep )
|
|
235 |
copy(HA+os.sep+"forced_9.3.h" ,"bin"+os.sep )
|
|
236 |
copy(HA+os.sep+"forced_9.4.h" ,"bin"+os.sep )
|
|
237 |
copy(HA+os.sep+"forced_9.4v2.h" ,"bin"+os.sep )
|
|
238 |
copy(HA+os.sep+"forced_10.1.h" ,"bin"+os.sep )
|
|
239 |
copy(HA+os.sep+"forced_mobileruntime.h" ,"bin"+os.sep )
|
|
240 |
copy(HA+os.sep+"forced_kernel.h" ,"bin"+os.sep )
|
|
241 |
copy(HA+os.sep+"forced_shai.h" ,"bin"+os.sep )
|
|
242 |
|
|
243 |
if os.name == 'nt':
|
|
244 |
copy(BCF+os.sep+"bcfilter.exe" ,"bin"+os.sep )
|
|
245 |
copy(BCF+os.sep+"libxerces-c2_7_0.dll" ,"bin"+os.sep )
|
|
246 |
|
|
247 |
copy(HA+os.sep+"ha.exe" ,"bin"+os.sep )
|
|
248 |
copy(HA+os.sep+"ha_gccxml_cc1plus.exe" ,"bin"+os.sep )
|
|
249 |
copy(HA+os.sep+"boost_thread-gcc-mt-1_33_1.dll" ,"bin"+os.sep )
|
|
250 |
copy(HA+os.sep+"mingwm10.dll" ,"bin"+os.sep )
|
|
251 |
|
|
252 |
copy(LA+os.sep+"la.exe" ,"bin"+os.sep )
|
|
253 |
copy(LA+os.sep+"cfilt.exe" ,"bin"+os.sep )
|
|
254 |
else:
|
|
255 |
copy(BCF+os.sep+"bcfilter" ,"bin"+os.sep )
|
|
256 |
copy(BCF+os.sep+"libxerces-c2_7_0.dll" ,"bin"+os.sep )
|
|
257 |
|
|
258 |
copy(HA+os.sep+"ha" ,"bin"+os.sep )
|
|
259 |
copy(HA+os.sep+"ha_gccxml_cc1plus" ,"bin"+os.sep )
|
|
260 |
copy(HA+os.sep+"boost_thread-gcc-mt-1_33_1.dll" ,"bin"+os.sep )
|
|
261 |
copy(HA+os.sep+"mingwm10.dll" ,"bin"+os.sep )
|
|
262 |
|
|
263 |
copy(LA+os.sep+"la" ,"bin"+os.sep )
|
|
264 |
copy(LA+os.sep+"cfilt" ,"bin"+os.sep )
|
|
265 |
os.chdir(dir)
|
|
266 |
|
|
267 |
def copy(src, dst):
|
|
268 |
try:
|
|
269 |
shutil.copy(src, dst )
|
|
270 |
except IOError, e:
|
|
271 |
print e
|
|
272 |
shutil.rmtree(EXEC_DIR)
|
|
273 |
sys.exit(1)
|
|
274 |
|
|
275 |
if __name__ == '__main__':
|
|
276 |
#Check for proper python version and then continue execution
|
|
277 |
if not "2.4" <= platform.python_version() < "3.0":
|
|
278 |
python_error()
|
|
279 |
lst = []
|
|
280 |
db = registry()
|
|
281 |
if len(sys.argv) < 3:
|
|
282 |
print "Usage: TestCheckBC.py <toolPathFile> [c] <outputfile> [<testcasefile>]"
|
|
283 |
print "<toolPathFile> - Text file with info regarding which path to be taken for each component."
|
|
284 |
print " These can be either bin / trunk / tag number"
|
|
285 |
print " - bin, if it is for S60 Release"
|
|
286 |
print " - trunk, if executable should be taken from trunk "
|
|
287 |
print " - tag number, specify the tag no from which executable should be taken"
|
|
288 |
print "[c] - Optional parameter to Copy binaries, if not already existing."
|
|
289 |
print "<outputfile> - report filename eg: report.xml"
|
|
290 |
print "[<testcasefile>] - Optional parameter. Text file with list of test cases mentioned, those to be executed."
|
|
291 |
sys.exit(1)
|
|
292 |
if not os.path.exists(TEMP_DIR):
|
|
293 |
os.makedirs(TEMP_DIR)
|
|
294 |
if not os.path.exists(TEMP_DIR + os.sep + 'results'):
|
|
295 |
os.makedirs(TEMP_DIR + os.sep + 'results')
|
|
296 |
|
|
297 |
if 'c' == sys.argv[2]:
|
|
298 |
copy_toolset()
|
|
299 |
if(len(sys.argv)== 3):
|
|
300 |
print '---------files copied--------'
|
|
301 |
sys.exit(0)
|
|
302 |
REPORT = TC_DIR + os.sep + 'reports' + os.sep + sys.argv[3]
|
|
303 |
else:
|
|
304 |
if not os.path.exists(EXEC_DIR):
|
|
305 |
copy_toolset()
|
|
306 |
print 'Toolset not found. New copy created'
|
|
307 |
REPORT = TC_DIR + os.sep + 'reports' + os.sep + sys.argv[2]
|
|
308 |
|
|
309 |
register_tc(db)
|
|
310 |
report_file = open(REPORT, 'w')
|
|
311 |
testAll(db)
|
|
312 |
write_header(report_file)
|
|
313 |
write_footer(report_file, db)
|
|
314 |
shutil.rmtree(TEMP_DIR)
|
|
315 |
open_results() |