@@ -52,10 +52,6 @@ def get_unique_software(moduletrees):
52
52
"""
53
53
returns a set of software packages found in the module tree
54
54
"""
55
- BUILDTEST_LOGCONTENT .append ("-------------------------------- \n " )
56
- BUILDTEST_LOGCONTENT .append ("func: get_unique_software \n " )
57
- BUILDTEST_LOGCONTENT .append ("-------------------------------- \n " )
58
-
59
55
logger = logging .getLogger (logID )
60
56
logger .info ("Traversing Module Tree: %s to find all unique software" , moduletrees )
61
57
@@ -120,7 +116,7 @@ def module_version_relation(moduletree):
120
116
# a dictionary can reference via key,value where key is application name and value is the list of versions
121
117
for item in module_set :
122
118
version_set = set ()
123
- logger .debug ("Application: " , item )
119
+ logger .debug ("Application: %s " , item )
124
120
for app in modulelist :
125
121
#logger.debug("ModuleFile: %s", app)
126
122
name = os .path .basename (os .path .dirname (app ))
@@ -255,36 +251,35 @@ def toolchain_exists(toolchain,verbose):
255
251
"""
256
252
success_msg = "Checking Toolchain: " + toolchain [0 ] + "/" + toolchain [1 ] + " ... SUCCESS"
257
253
fail_msg = "Checking Toolchain: " + toolchain [0 ] + "/" + toolchain [1 ] + " ... FAILED"
254
+
255
+ logger = logging .getLogger (logID )
256
+
258
257
# catch all exception cases for invalid value for -t flag
259
258
if len (toolchain ) != 2 :
260
259
print fail_msg
261
260
msg = "Too many arguments, -t takes argument <toolchain-name>,<toolchain-version> \n "
262
261
print msg
263
- BUILDTEST_LOGCONTENT .append (msg )
264
- update_logfile (verbose )
262
+ logger .error ("%s" , msg )
265
263
sys .exit (1 )
266
264
267
265
toolchain_list = list_toolchain ()
268
266
tcname = toolchain [0 ]
269
267
tcversion = toolchain [1 ]
270
268
toolchain_name = tcname + "/" + tcversion
271
- BUILDTEST_LOGCONTENT .append ("-------------------------------------------\n " )
272
- BUILDTEST_LOGCONTENT .append ("func: toolchain_exists \n " )
273
- BUILDTEST_LOGCONTENT .append ("-------------------------------------------\n " )
274
269
275
270
# report error if toolchain is not found in toolchain list. toolchain list only
276
271
# contains the name of toolchain and not the version
277
272
if tcname not in toolchain_list :
278
273
print fail_msg
279
274
msg = "Can't find toolchain: " + tcname + "\n "
280
275
print msg
281
- BUILDTEST_LOGCONTENT .append (msg )
282
- update_logfile (verbose )
276
+ logger .error ("%s" , msg )
283
277
sys .exit (1 )
284
278
285
279
msg = "Toolchain + " + toolchain_name + " found in system"
286
- BUILDTEST_LOGCONTENT . append ( msg )
280
+ logger . info ( "%s" , msg )
287
281
print success_msg
282
+ logger .info ("%s" ,success_msg )
288
283
289
284
def check_software_version_in_easyconfig (easyconfig_repo , verbose ):
290
285
"""
@@ -298,74 +293,84 @@ def check_software_version_in_easyconfig(easyconfig_repo, verbose):
298
293
tcname = get_toolchain_name ()
299
294
tcversion = get_toolchain_version ()
300
295
296
+ logger = logging .getLogger (logID )
297
+
301
298
# if user is testing a software package that is a hidden module file, strip the leading "." for checking
302
299
if isHiddenFile (appversion ):
303
300
appversion = stripHiddenFile (appversion )
304
- BUILDTEST_LOGCONTENT . append ("Stripping leading . from application version: " + appversion + " \n " )
301
+ logger . debug ("Stripping leading . from application version: %s " , appversion )
305
302
306
303
# only check if toolchain version is a hidden module when toolchain is specified by checking length
307
304
if len (tcversion ) != 0 :
308
305
# if user specified a toolchain version that is a hidden module file, strip leading "."
309
306
if isHiddenFile (tcversion ) :
310
307
tcversion = stripHiddenFile (tcversion )
311
- BUILDTEST_LOGCONTENT . append ("Stripping leading . from toolchain version: " + tcversion + " \n " )
308
+ logger . debug ("Stripping leading . from toolchain version: " , tcversion )
312
309
313
- # for Flat Naming Scheme -s will take APP/Version-Toolchain so need to take Toolchain out for comparision
310
+ # for Flat Naming Scheme -s will take APP/Version-Toolchain so need to take Toolchain out for comparison
314
311
if BUILDTEST_MODULE_NAMING_SCHEME == "FNS" :
315
312
arg_tc_name = toolchain [0 ] + "-" + toolchain [1 ]
316
313
appversion = appversion .replace (arg_tc_name ,'' )
314
+ logger .debug ("Detected Module Naming Scheme is Flat Naming Scheme" )
315
+ logger .debug ("Removing toolchain from module version for comparision" )
316
+ # stripping last character if which is a "-" because module version in FNS
317
+ # is <version>-<toolchain>
317
318
if appversion [- 1 ] == "-" :
318
319
appversion = appversion [:- 1 ]
319
320
320
-
321
+
321
322
cmd = "find " + easyconfig_repo + " -name " + appname + "-" + appversion + "*.eb -type f"
323
+ logger .debug ("Attempting to find all easyconfigs based on appname = %s \t appversion = %s" , appname , appversion )
324
+ logger .debug ("Executing Command: %s" , cmd )
322
325
easyconfigfiles = os .popen (cmd ).read ().rstrip ().split ("\n " )
323
326
# remove any empty elements in list when there is no eb files found
324
327
easyconfigfiles = [x for x in easyconfigfiles if x ]
328
+
325
329
# if no easyconfig files found
326
330
if len (easyconfigfiles ) == 0 :
327
331
if len (tcversion ) == 0 :
328
332
msg = "FAILED to find any easyconfig file with the name " + appname + "-" + appversion + ".eb"
329
333
else :
330
334
msg = "FAILED to find any easyconfig file with the name " + appname + "-" + appversion + "-" + tcname + "-" + tcversion + ".eb"
331
335
print msg
336
+ logger .error ("%s" ,msg )
332
337
sys .exit (1 )
333
338
334
-
335
- BUILDTEST_LOGCONTENT .append ("--------------------------------------------- \n " )
336
- BUILDTEST_LOGCONTENT .append ("func: check_software_version_in_easyconfig \n " )
337
- BUILDTEST_LOGCONTENT .append ("--------------------------------------------- \n " )
338
-
339
- BUILDTEST_LOGCONTENT .append ("buildtest will search the following eb files \n " )
339
+ # writing easyconfig file path to log
340
340
for ebfile in easyconfigfiles :
341
- BUILDTEST_LOGCONTENT . append ( ebfile + " \n " )
341
+ logger . debug ( "%s" , ebfile )
342
342
343
343
# boolean value to check if eb file found with parameters for software and toolchain
344
344
match = False
345
345
for ebfile in easyconfigfiles :
346
346
# get name tag from easyconfig
347
347
cmd = """grep "name = " """ + ebfile + """ | cut -f3 -d " " """
348
- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
348
+ logger . debug ( "Executing command: %s " , cmd )
349
349
350
350
name = os .popen (cmd ).read ()
351
- BUILDTEST_LOGCONTENT . append ( "result: " + name + " \n " )
351
+ logger . debug ( "Result: %s" , name )
352
352
353
353
# get version tag from easyconfig, possibility for multiple occurence so get 1st entry
354
354
cmd = """grep "version = " """ + ebfile + """ | cut -f3 -d " " | head -n1 """
355
- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
355
+ logger . debug ( "Executing command: %s" , cmd )
356
356
version = os .popen (cmd ).read ()
357
- BUILDTEST_LOGCONTENT . append ( "result: " + version + " \n " )
357
+ logger . debug ( "Result: %s" , version )
358
358
359
359
cmd = """ grep "toolchain = " """ + ebfile + """ | cut -f4 -d " " | tr -d "," """
360
- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
360
+ logger . debug ( "Executing command: %s" , cmd )
361
361
toolchain_name = os .popen (cmd ).read ()
362
- BUILDTEST_LOGCONTENT . append ( "result: " + toolchain_name + " \n " )
362
+ logger . debug ( "Result: %s" , toolchain_name )
363
363
364
364
365
365
cmd = """ grep "toolchain = " """ + ebfile + """ | cut -f6 -d " " | tr -d "}" """
366
- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
366
+ logger . debug ( "Executing command: %s" , cmd )
367
367
toolchain_version = os .popen (cmd ).read ()
368
- BUILDTEST_LOGCONTENT .append (toolchain_version + "\n " )
368
+ logger .debug ("Result: %s" ,toolchain_version )
369
+
370
+
371
+
372
+ logger .debug ("Before Stripping characters" )
373
+ logger .debug ("name: %s \t version: %s \t toolchain name: %s \t toolchain version: %s" , name , version , toolchain_name , toolchain_version )
369
374
370
375
# strip character ' and newline
371
376
name = name .replace ('\' ' ,'' )
@@ -377,32 +382,21 @@ def check_software_version_in_easyconfig(easyconfig_repo, verbose):
377
382
toolchain_version = toolchain_version .replace ('\' ' ,'' )
378
383
toolchain_version = toolchain_version .replace ('\n ' ,'' )
379
384
380
-
381
- BUILDTEST_LOGCONTENT .append ("Before Stripping characters \n " )
382
- BUILDTEST_LOGCONTENT .append ("name: " + name + "\n " )
383
- BUILDTEST_LOGCONTENT .append ("version: " + version + "\n " )
384
- BUILDTEST_LOGCONTENT .append ("toolchain name:" + toolchain_name + "\n " )
385
- BUILDTEST_LOGCONTENT .append ("toolchain version:" + toolchain_version + "\n " )
386
-
387
- BUILDTEST_LOGCONTENT .append ("\n " )
388
- BUILDTEST_LOGCONTENT .append ("After Stripping characters ' and newline \n " )
389
- BUILDTEST_LOGCONTENT .append ("name: " + name + "\n " )
390
- BUILDTEST_LOGCONTENT .append ("version: " + version + "\n " )
391
- BUILDTEST_LOGCONTENT .append ("toolchain name:" + toolchain_name + "\n " )
392
- BUILDTEST_LOGCONTENT .append ("toolchain version:" + toolchain_version + "\n " )
393
- BUILDTEST_LOGCONTENT .append ("\n " )
385
+ logger .debug ("\n " )
386
+ logger .debug ("After Stripping characters ' and newline" )
387
+ logger .debug ("name: %s \t version: %s \t toolchain name: %s \t toolchain version: %s" , name , version , toolchain_name , toolchain_version )
394
388
395
389
396
390
# get name of eb file and remove .eb extension
397
391
ebname = os .popen ("basename " + ebfile ).read ()
398
- BUILDTEST_LOGCONTENT .append ("easyconfig file= " + ebname )
399
392
393
+ logger .debug ("Before Stripping File extension(.eb) - FILE: %s" , ebname )
394
+
395
+ # stripping characters ".eb" plus newline character a total of 4 from end
400
396
ebname = ebname [:- 4 ]
401
- BUILDTEST_LOGCONTENT . append ( "stripping file extension .eb \n " )
402
- BUILDTEST_LOGCONTENT . append ( "easyconfig file:" + ebname + " \n " )
397
+
398
+ logger . debug ( "After Stripping File extension - FILE: %s" , ebname )
403
399
404
- #print "local logcontent"
405
- #print logcontent
406
400
# in case toolchain version uses '' set it to dummy
407
401
if toolchain_version == '' :
408
402
toolchain_version = ""
@@ -414,47 +408,53 @@ def check_software_version_in_easyconfig(easyconfig_repo, verbose):
414
408
# eb name format used for comparison to calculate versionsuffx
415
409
eb_name_format = name + "-" + version + "-" + toolchain_name + "-" + toolchain_version
416
410
417
- BUILDTEST_LOGCONTENT .append ("eb name format using string concat of <name>-<version>-<toolchain-name>-<toolchain-version> \n " )
418
- BUILDTEST_LOGCONTENT .append ("eb name format string: " + eb_name_format + "\n " )
419
411
420
- # There is no version suffix when file name is just software-version-toolchain
421
- # determine starting position index in easyconfig filename to calculate versionsuffix. If its a dummy toolchain start with version, otherwise from toolchain version
412
+ # There is no version suffix when file name is just
413
+ # software-version-toolchain
414
+ # determine starting position index in easyconfig filename to
415
+ # calculate versionsuffix. If its a dummy toolchain start with
416
+ # version, otherwise from toolchain version
422
417
if toolchain_name == "" :
423
418
startpos = ebname .find (version )+ len (version )
424
419
else :
425
420
# extract version suffix
426
421
startpos = ebname .find (toolchain_version )+ len (toolchain_version )
422
+
427
423
endpos = len (ebname )
428
424
versionsuffix = ebname [startpos :endpos ]
429
425
430
426
# variable used for comparison
431
427
version_versionsuffix = version + versionsuffix
432
428
433
- BUILDTEST_LOGCONTENT . append ("Extracting version suffix from eb name: " + ebname + " \n " )
434
- BUILDTEST_LOGCONTENT . append ("Version Suffix: " + versionsuffix + " \n " )
435
- BUILDTEST_LOGCONTENT . append ("Version + Version Suffix: " + version_versionsuffix + " \n " )
429
+ logger . debug ("Extracting version suffix from eb name: %s" , ebname )
430
+ logger . debug ("Version Suffix: %s" , versionsuffix )
431
+ logger . debug ("Version + Version Suffix: %s" , version_versionsuffix )
436
432
433
+
434
+
435
+ logger .debug ("All CONDITIONS must pass" )
436
+ logger .debug ("NAME String Comparision - STR1: %s \t STR2: %s" , name , appname )
437
+ logger .debug ("VERSION String Comparision - STR1: %s \t STR2: %s" , version_versionsuffix , appversion )
438
+ logger .debug ("TOOLCHAIN NAME String Comparision - STR1: %s \t STR2: %s" , toolchain_name , tcname )
439
+ logger .debug ("TOOLCHAIN VERSION String Comparision - STR1: %s \t STR2: %s" , toolchain_version , tcversion )
437
440
# print name,version_versionsuffix, toolchain_name, toolchain_version
438
441
# print appname, appversion, tcname, tcversion
439
442
if name == appname and version_versionsuffix == appversion and toolchain_name == tcname and toolchain_version == tcversion :
440
- BUILDTEST_LOGCONTENT .append ("Comparing strings: the following strings \n " )
441
- BUILDTEST_LOGCONTENT .append ("name:" + name + " with appname = " + appname + " AND " )
442
- BUILDTEST_LOGCONTENT .append ("version_versionsuffix: " + version_versionsuffix + " with appversion: " + appversion + " AND " )
443
- BUILDTEST_LOGCONTENT .append ("toolchain_name: " + toolchain_name + " with tcname: " + tcname + " AND " )
444
- BUILDTEST_LOGCONTENT .append ("toolchain_version: " + toolchain_version + "with tcversion: " + tcversion + "\n " )
443
+ logger .debug ("All Checks have PASSED!" )
444
+
445
445
print success_msg
446
446
if tcname == "" :
447
447
print "found easyconfig file: " + appname + "-" + appversion + ".eb"
448
448
else :
449
449
print "found easyconfig file: " + appname + "-" + appversion + "-" + tcname + "-" + tcversion + ".eb"
450
450
return True
451
-
451
+ else :
452
+ logger .debug ("All Checks failed to PASSED!" )
452
453
453
454
# mismatch in easyconfig entries for name,version+versionsuffix, and toolchain with specified entries
454
455
if match == False :
455
456
print fail_msg
456
457
msg = "ERROR: Attempting to find easyconfig file " + appname + "-" + appversion + "-" + tcname + "-" + tcversion + ".eb"
457
458
print msg
458
- BUILDTEST_LOGCONTENT .append (msg )
459
- update_logfile (verbose )
459
+ logger .error ("%s" ,msg )
460
460
sys .exit (1 )
0 commit comments