@@ -124,64 +124,93 @@ def get_toolchain(easyconfigdir):
124
124
BUILDTEST_LOGCONTENT .append ("-------------------------------------\n " )
125
125
126
126
BUILDTEST_LOGCONTENT .append ("Executing command: find " + easyconfigdir + " -name *.eb -type f" + "\n " )
127
+ BUILDTEST_LOGCONTENT .append ("The following eb files found \n " )
128
+ for ebfile in easyconfigfiles :
129
+ BUILDTEST_LOGCONTENT .append (ebfile + "\n " )
130
+
127
131
# only care about unique toolchains
128
132
toolchain = set ()
129
- logcontent = ""
130
133
# find all toolchains in the easyconfig files
131
134
for ebfile in easyconfigfiles :
132
135
133
- logcontent += ebfile + "\n "
134
136
135
- cmd = """grep "toolchain =" """ + ebfile + """ | cut -f4 -d " " | tr -d "'," """
137
+ cmd = """grep "toolchain =" """ + ebfile + """ | cut -f4 -d " " | tr -d "'," """
138
+ BUILDTEST_LOGCONTENT .append ("Running Command: " + cmd + "\n " )
136
139
toolchain_name = os .popen (cmd ).read ().rstrip ()
137
140
cmd = """grep "toolchain =" """ + ebfile + """ | cut -f6 -d " " | tr -d "}'" """
141
+ BUILDTEST_LOGCONTENT .append ("Running Command: " + cmd + "\n " )
138
142
toolchain_version = os .popen (cmd ).read ().rstrip ()
139
143
toolchain .add (toolchain_name + " " + toolchain_version )
144
+
145
+ BUILDTEST_LOGCONTENT .append ("\n \n The Following Toolchain were found :\n " )
146
+ for tc in toolchain :
147
+ BUILDTEST_LOGCONTENT .append (tc + "\n " )
140
148
return toolchain
141
149
142
150
def software_exists (software ,verbose ):
143
151
"""
144
152
checks whether software exist, there must be a module file present with the
145
153
same name specified as the argument.
146
154
"""
147
- logcontent = ""
148
155
if len (software ) != 2 :
149
- print "Too many arguments, -s takes argument <software>,<version>"
156
+ msg = "Too many arguments, -s takes argument <software>,<version> \n "
157
+ print msg
158
+ BUILDTEST_LOGCONTENT .append (msg )
159
+ update_logfile (verbose )
150
160
sys .exit (1 )
151
161
152
162
softwarecollection = get_unique_software_version (BUILDTEST_MODULE_EBROOT )
153
163
software_name = software [0 ]+ " " + software [1 ]
154
164
if software_name not in softwarecollection :
155
- print "Can't find software: " , software_name
165
+ msg = "Can't find software: " + software_name + "\n "
166
+ print msg
167
+ BUILDTEST_LOGCONTENT .append (msg )
168
+ update_logfile (verbose )
156
169
sys .exit (1 )
170
+
157
171
text = "Software:" + str (software ) + " found in system \n "
158
- logcontent = text
159
- return logcontent
172
+ BUILDTEST_LOGCONTENT . append ( text )
173
+
160
174
161
175
162
- def toolchain_exists (toolchain ):
176
+ def toolchain_exists (toolchain , verbose ):
163
177
"""
164
178
checks to see if toolchain passed on command line exist in toolchain list
165
179
"""
166
180
181
+ # catch all exception cases for invalid value for -t flag
182
+ if len (toolchain ) != 2 :
183
+ msg = "Too many arguments, -t takes argument <toolchain-name>,<toolchain-version> \n "
184
+ print msg
185
+ BUILDTEST_LOGCONTENT .append (msg )
186
+ update_logfile (verbose )
187
+ sys .exit (1 )
188
+
167
189
toolchain_list = get_toolchain (BUILDTEST_EASYCONFIGDIR )
168
190
191
+ BUILDTEST_LOGCONTENT .append ("-------------------------------------------\n " )
192
+ BUILDTEST_LOGCONTENT .append ("func: toolchain_exists \n " )
193
+ BUILDTEST_LOGCONTENT .append ("-------------------------------------------\n " )
169
194
# if toolchain is installed as hidden file then strip the "." prior to checking in list
170
195
if isHiddenFile (toolchain [1 ]) == True :
171
196
strip_version = stripHiddenFile (toolchain [1 ])
172
197
toolchain_name = toolchain [0 ]+ " " + strip_version
198
+ msg = "Toolchain version specified as hidden file. Striping leading . for matching purpose \n "
199
+ BUILDTEST_LOGCONTENT .append ("msg" )
173
200
else :
174
201
toolchain_name = toolchain [0 ]+ " " + toolchain [1 ]
175
202
176
- # catch all exception cases in invalid value for -t flag
177
- if len (toolchain ) != 2 :
178
- print "Too many arguments, -t takes argument <toolchain-name>,<toolchain-version>"
179
- sys .exit (1 )
180
- # check if toolchain is in list
203
+ # report error if toolchain is not found in toolchain list
181
204
if toolchain_name not in toolchain_list :
182
- print "Can't find toolchain: " , toolchain_name
205
+ msg = "Can't find toolchain: " + toolchain_name + "\n "
206
+ print msg
207
+ BUILDTEST_LOGCONTENT .append (msg )
208
+ update_logfile (verbose )
183
209
sys .exit (1 )
184
210
211
+ msg = "Toolchain + " + toolchain_name + " found in system"
212
+ BUILDTEST_LOGCONTENT .append (msg )
213
+
185
214
def check_software_version_in_easyconfig (moduletree ,software ,toolchain ):
186
215
"""
187
216
return True if name,version+versionsuffix,toolchain from command line is found
@@ -197,53 +226,51 @@ def check_software_version_in_easyconfig(moduletree,software,toolchain):
197
226
cmd = "find " + os .path .join (moduletree ,appname ) + " -name *.eb -type f"
198
227
easyconfigfiles = os .popen (cmd ).read ().rstrip ().split ("\n " )
199
228
200
- logcontent = "buildtest will search the following eb files"
201
- logcontent += str (easyconfigfiles ) + "\n "
229
+ BUILDTEST_LOGCONTENT .append ("--------------------------------------------- \n " )
230
+ BUILDTEST_LOGCONTENT .append ("func: check_software_version_in_easyconfig \n " )
231
+ BUILDTEST_LOGCONTENT .append ("--------------------------------------------- \n " )
232
+
233
+ BUILDTEST_LOGCONTENT .append ("buildtest will search the following eb files \n " )
234
+ for ebfile in easyconfigfiles :
235
+ BUILDTEST_LOGCONTENT .append (ebfile + "\n " )
202
236
203
237
# boolean value to check if eb file found with parameters for software and toolchain
204
238
match = False
205
239
206
240
# if user is testing a software package that is a hidden module file, strip the leading "." for checking
207
241
if isHiddenFile (appversion ):
208
242
appversion = stripHiddenFile (appversion )
209
- logcontent += "Stripping leading . from application version: " + appversion
243
+ BUILDTEST_LOGCONTENT . append ( "Stripping leading . from application version: " + appversion + " \n " )
210
244
211
245
# if user specified a toolchain version that is a hidden module file, strip leading "."
212
246
if isHiddenFile (tcversion ):
213
247
tcversion = stripHiddenFile (tcversion )
214
- logcontent += "Stripping leading . from toolchain version: " + tcversion
248
+ BUILDTEST_LOGCONTENT . append ( "Stripping leading . from toolchain version: " + tcversion + " \n " )
215
249
216
250
for ebfile in easyconfigfiles :
217
251
# get name tag from easyconfig
218
252
cmd = """grep "name = " """ + ebfile + """ | cut -f3 -d " " """
219
- logcontent += "executing command: " + cmd + "\n "
253
+ BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + "\n " )
220
254
221
255
name = os .popen (cmd ).read ()
222
- logcontent += "result: " + name + "\n "
256
+ BUILDTEST_LOGCONTENT . append ( "result: " + name + "\n " )
223
257
224
258
# get version tag from easyconfig, possibility for multiple occurence so get 1st entry
225
259
cmd = """grep "version = " """ + ebfile + """ | cut -f3 -d " " | head -n1 """
226
- logcontent += "executing command: " + cmd + "\n "
260
+ BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + "\n " )
227
261
version = os .popen (cmd ).read ()
228
- logcontent += "result: " + version + "\n "
262
+ BUILDTEST_LOGCONTENT . append ( "result: " + version + "\n " )
229
263
230
264
cmd = """ grep "toolchain = " """ + ebfile + """ | cut -f4 -d " " | tr -d "," """
231
- logcontent += "executing command: " + cmd + "\n "
265
+ BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + "\n " )
232
266
toolchain_name = os .popen (cmd ).read ()
233
- logcontent += "result: " + toolchain_name + "\n "
267
+ BUILDTEST_LOGCONTENT . append ( "result: " + toolchain_name + "\n " )
234
268
235
269
236
270
cmd = """ grep "toolchain = " """ + ebfile + """ | cut -f6 -d " " | tr -d "}" """
237
- logcontent += "executing command: " + cmd + "\n "
271
+ BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + "\n " )
238
272
toolchain_version = os .popen (cmd ).read ()
239
- logcontent += "result: " + toolchain_version + "\n "
240
-
241
-
242
- logcontent += "Before Stripping characters \n "
243
- logcontent += "name: " + name + "\n "
244
- logcontent += "version: " + version + "\n "
245
- logcontent += "toolchain name:" + toolchain_name + "\n "
246
- logcontent += "toolchain version:" + toolchain_version + "\n "
273
+ BUILDTEST_LOGCONTENT .append (toolchain_version + "\n " )
247
274
248
275
# strip character ' and newline
249
276
name = name .replace ('\' ' ,'' )
@@ -255,21 +282,29 @@ def check_software_version_in_easyconfig(moduletree,software,toolchain):
255
282
toolchain_version = toolchain_version .replace ('\' ' ,'' )
256
283
toolchain_version = toolchain_version .replace ('\n ' ,'' )
257
284
258
- logcontent += "\n "
259
- logcontent += "After Stripping characters ' and newline \n "
260
- logcontent += "name: " + name + "\n "
261
- logcontent += "version: " + version + "\n "
262
- logcontent += "toolchain name:" + toolchain_name + "\n "
263
- logcontent += "toolchain version:" + toolchain_version + "\n "
264
-
285
+
286
+ BUILDTEST_LOGCONTENT .append ("Before Stripping characters \n " )
287
+ BUILDTEST_LOGCONTENT .append ("name: " + name + "\n " )
288
+ BUILDTEST_LOGCONTENT .append ("version: " + version + "\n " )
289
+ BUILDTEST_LOGCONTENT .append ("toolchain name:" + toolchain_name + "\n " )
290
+ BUILDTEST_LOGCONTENT .append ("toolchain version:" + toolchain_version + "\n " )
291
+
292
+ BUILDTEST_LOGCONTENT .append ("\n " )
293
+ BUILDTEST_LOGCONTENT .append ("After Stripping characters ' and newline \n " )
294
+ BUILDTEST_LOGCONTENT .append ("name: " + name + "\n " )
295
+ BUILDTEST_LOGCONTENT .append ("version: " + version + "\n " )
296
+ BUILDTEST_LOGCONTENT .append ("toolchain name:" + toolchain_name + "\n " )
297
+ BUILDTEST_LOGCONTENT .append ("toolchain version:" + toolchain_version + "\n " )
298
+ BUILDTEST_LOGCONTENT .append ("\n " )
299
+
265
300
266
301
# get name of eb file and remove .eb extension
267
302
ebname = os .popen ("basename " + ebfile ).read ()
268
- logcontent = "easyconfig file= " + ebname
303
+ BUILDTEST_LOGCONTENT . append ( "easyconfig file= " + ebname )
269
304
270
305
ebname = ebname [:- 4 ]
271
- logcontent += "stripping file extension .eb \n "
272
- logcontent += "easyconfig file:" + ebname + "\n "
306
+ BUILDTEST_LOGCONTENT . append ( "stripping file extension .eb \n " )
307
+ BUILDTEST_LOGCONTENT . append ( "easyconfig file:" + ebname + "\n " )
273
308
274
309
#print "local logcontent"
275
310
#print logcontent
@@ -283,8 +318,8 @@ def check_software_version_in_easyconfig(moduletree,software,toolchain):
283
318
# eb name format used for comparison to calculate versionsuffx
284
319
eb_name_format = name + "-" + version + "-" + toolchain_name + "-" + toolchain_version
285
320
286
- logcontent += "eb name format using string concat of <name>-<version>-<toolchain-name>-<toolchain-version> \n "
287
- logcontent += "eb name format string: " + eb_name_format + "\n "
321
+ BUILDTEST_LOGCONTENT . append ( "eb name format using string concat of <name>-<version>-<toolchain-name>-<toolchain-version> \n " )
322
+ BUILDTEST_LOGCONTENT . append ( "eb name format string: " + eb_name_format + "\n " )
288
323
289
324
# There is no version suffix when file name is just software-version-toolchain
290
325
# determine starting position index in easyconfig filename to calculate versionsuffix. If its a dummy toolchain start with version, otherwise from toolchain version
@@ -299,31 +334,29 @@ def check_software_version_in_easyconfig(moduletree,software,toolchain):
299
334
# variable used for comparison
300
335
version_versionsuffix = version + versionsuffix
301
336
302
- logcontent += "Extracting version suffix from eb name: " + ebname + "\n "
303
- logcontent += "Version Suffix: " + versionsuffix + "\n "
304
- logcontent += "Version + Version Suffix: " + version_versionsuffix + "\n "
337
+ BUILDTEST_LOGCONTENT . append ( "Extracting version suffix from eb name: " + ebname + "\n " )
338
+ BUILDTEST_LOGCONTENT . append ( "Version Suffix: " + versionsuffix + "\n " )
339
+ BUILDTEST_LOGCONTENT . append ( "Version + Version Suffix: " + version_versionsuffix + "\n " )
305
340
306
341
# master condition to determine if easyconfig parameter match argument for software and toolchain
307
342
if tcname == "dummy" and tcversion == "dummy" :
308
343
if name == appname and version_versionsuffix == appversion :
309
- logcontent += "Comparing strings: the following strings" + " \n "
310
- logcontent += "name: " + name + " with appname: " + appname + " AND \n "
311
- logcontent += "version_versionsuffix: " + version_versionsuffix + " with appversion: " + appversion + "\n "
312
- return True , logcontent
344
+ BUILDTEST_LOGCONTENT . append ( "Comparing strings: the following strings \n " )
345
+ BUILDTEST_LOGCONTENT . append ( "name: " + name + " with appname: " + appname + " AND " )
346
+ BUILDTEST_LOGCONTENT . append ( "version_versionsuffix: " + version_versionsuffix + " with appversion: " + appversion + "\n " )
347
+ return True
313
348
else :
314
349
if name == appname and version_versionsuffix == appversion and toolchain_name == tcname and toolchain_version == tcversion :
315
- logcontent += "Comparing strings: the following strings \n "
316
- logcontent += "name:" + name + " with appname = " + appname + " AND \n "
317
- logcontent += "version_versionsuffix: " + version_versionsuffix + " with appversion: " + appversion + " AND \n "
318
- logcontent += "toolchain_name: " + toolchain_name + " with tcname: " + tcname + " AND \n "
319
- logcontent += "toolchain_version: " + toolchain_version + "with tcversion: " + tcversion + "\n "
320
- return True , logcontent
350
+ BUILDTEST_LOGCONTENT . append ( "Comparing strings: the following strings \n " )
351
+ BUILDTEST_LOGCONTENT . append ( "name:" + name + " with appname = " + appname + " AND " )
352
+ BUILDTEST_LOGCONTENT . append ( "version_versionsuffix: " + version_versionsuffix + " with appversion: " + appversion + " AND " )
353
+ BUILDTEST_LOGCONTENT . append ( "toolchain_name: " + toolchain_name + " with tcname: " + tcname + " AND " )
354
+ BUILDTEST_LOGCONTENT . append ( "toolchain_version: " + toolchain_version + "with tcversion: " + tcversion + "\n " )
355
+ return True
321
356
322
357
# mismatch in easyconfig entries for name,version+versionsuffix, and toolchain with specified entries
323
358
if match == False :
324
- print "Can't find easyconfig file with argument:"
325
- print "software= " , software [0 ]
326
- print "version:" , software [1 ]
327
- print "toolchain name:" ,toolchain [0 ]
328
- print "toolchain version:" , toolchain [1 ]
359
+ msg = "Can't find easyconfig file with argument: -s " + software + " -t " + toolchain
360
+ BUILDTEST_LOGCONTENT .append (msg )
361
+ update_logfile (verbose )
329
362
sys .exit (1 )
0 commit comments