@@ -52,10 +52,6 @@ def get_unique_software(moduletrees):
5252 """
5353 returns a set of software packages found in the module tree
5454 """
55- BUILDTEST_LOGCONTENT .append ("-------------------------------- \n " )
56- BUILDTEST_LOGCONTENT .append ("func: get_unique_software \n " )
57- BUILDTEST_LOGCONTENT .append ("-------------------------------- \n " )
58-
5955 logger = logging .getLogger (logID )
6056 logger .info ("Traversing Module Tree: %s to find all unique software" , moduletrees )
6157
@@ -120,7 +116,7 @@ def module_version_relation(moduletree):
120116 # a dictionary can reference via key,value where key is application name and value is the list of versions
121117 for item in module_set :
122118 version_set = set ()
123- logger .debug ("Application: " , item )
119+ logger .debug ("Application: %s " , item )
124120 for app in modulelist :
125121 #logger.debug("ModuleFile: %s", app)
126122 name = os .path .basename (os .path .dirname (app ))
@@ -255,36 +251,35 @@ def toolchain_exists(toolchain,verbose):
255251 """
256252 success_msg = "Checking Toolchain: " + toolchain [0 ] + "/" + toolchain [1 ] + " ... SUCCESS"
257253 fail_msg = "Checking Toolchain: " + toolchain [0 ] + "/" + toolchain [1 ] + " ... FAILED"
254+
255+ logger = logging .getLogger (logID )
256+
258257 # catch all exception cases for invalid value for -t flag
259258 if len (toolchain ) != 2 :
260259 print fail_msg
261260 msg = "Too many arguments, -t takes argument <toolchain-name>,<toolchain-version> \n "
262261 print msg
263- BUILDTEST_LOGCONTENT .append (msg )
264- update_logfile (verbose )
262+ logger .error ("%s" , msg )
265263 sys .exit (1 )
266264
267265 toolchain_list = list_toolchain ()
268266 tcname = toolchain [0 ]
269267 tcversion = toolchain [1 ]
270268 toolchain_name = tcname + "/" + tcversion
271- BUILDTEST_LOGCONTENT .append ("-------------------------------------------\n " )
272- BUILDTEST_LOGCONTENT .append ("func: toolchain_exists \n " )
273- BUILDTEST_LOGCONTENT .append ("-------------------------------------------\n " )
274269
275270 # report error if toolchain is not found in toolchain list. toolchain list only
276271 # contains the name of toolchain and not the version
277272 if tcname not in toolchain_list :
278273 print fail_msg
279274 msg = "Can't find toolchain: " + tcname + "\n "
280275 print msg
281- BUILDTEST_LOGCONTENT .append (msg )
282- update_logfile (verbose )
276+ logger .error ("%s" , msg )
283277 sys .exit (1 )
284278
285279 msg = "Toolchain + " + toolchain_name + " found in system"
286- BUILDTEST_LOGCONTENT . append ( msg )
280+ logger . info ( "%s" , msg )
287281 print success_msg
282+ logger .info ("%s" ,success_msg )
288283
289284def check_software_version_in_easyconfig (easyconfig_repo , verbose ):
290285 """
@@ -298,74 +293,84 @@ def check_software_version_in_easyconfig(easyconfig_repo, verbose):
298293 tcname = get_toolchain_name ()
299294 tcversion = get_toolchain_version ()
300295
296+ logger = logging .getLogger (logID )
297+
301298 # if user is testing a software package that is a hidden module file, strip the leading "." for checking
302299 if isHiddenFile (appversion ):
303300 appversion = stripHiddenFile (appversion )
304- BUILDTEST_LOGCONTENT . append ("Stripping leading . from application version: " + appversion + " \n " )
301+ logger . debug ("Stripping leading . from application version: %s " , appversion )
305302
306303 # only check if toolchain version is a hidden module when toolchain is specified by checking length
307304 if len (tcversion ) != 0 :
308305 # if user specified a toolchain version that is a hidden module file, strip leading "."
309306 if isHiddenFile (tcversion ) :
310307 tcversion = stripHiddenFile (tcversion )
311- BUILDTEST_LOGCONTENT . append ("Stripping leading . from toolchain version: " + tcversion + " \n " )
308+ logger . debug ("Stripping leading . from toolchain version: " , tcversion )
312309
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
314311 if BUILDTEST_MODULE_NAMING_SCHEME == "FNS" :
315312 arg_tc_name = toolchain [0 ] + "-" + toolchain [1 ]
316313 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>
317318 if appversion [- 1 ] == "-" :
318319 appversion = appversion [:- 1 ]
319320
320-
321+
321322 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 )
322325 easyconfigfiles = os .popen (cmd ).read ().rstrip ().split ("\n " )
323326 # remove any empty elements in list when there is no eb files found
324327 easyconfigfiles = [x for x in easyconfigfiles if x ]
328+
325329 # if no easyconfig files found
326330 if len (easyconfigfiles ) == 0 :
327331 if len (tcversion ) == 0 :
328332 msg = "FAILED to find any easyconfig file with the name " + appname + "-" + appversion + ".eb"
329333 else :
330334 msg = "FAILED to find any easyconfig file with the name " + appname + "-" + appversion + "-" + tcname + "-" + tcversion + ".eb"
331335 print msg
336+ logger .error ("%s" ,msg )
332337 sys .exit (1 )
333338
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
340340 for ebfile in easyconfigfiles :
341- BUILDTEST_LOGCONTENT . append ( ebfile + " \n " )
341+ logger . debug ( "%s" , ebfile )
342342
343343 # boolean value to check if eb file found with parameters for software and toolchain
344344 match = False
345345 for ebfile in easyconfigfiles :
346346 # get name tag from easyconfig
347347 cmd = """grep "name = " """ + ebfile + """ | cut -f3 -d " " """
348- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
348+ logger . debug ( "Executing command: %s " , cmd )
349349
350350 name = os .popen (cmd ).read ()
351- BUILDTEST_LOGCONTENT . append ( "result: " + name + " \n " )
351+ logger . debug ( "Result: %s" , name )
352352
353353 # get version tag from easyconfig, possibility for multiple occurence so get 1st entry
354354 cmd = """grep "version = " """ + ebfile + """ | cut -f3 -d " " | head -n1 """
355- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
355+ logger . debug ( "Executing command: %s" , cmd )
356356 version = os .popen (cmd ).read ()
357- BUILDTEST_LOGCONTENT . append ( "result: " + version + " \n " )
357+ logger . debug ( "Result: %s" , version )
358358
359359 cmd = """ grep "toolchain = " """ + ebfile + """ | cut -f4 -d " " | tr -d "," """
360- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
360+ logger . debug ( "Executing command: %s" , cmd )
361361 toolchain_name = os .popen (cmd ).read ()
362- BUILDTEST_LOGCONTENT . append ( "result: " + toolchain_name + " \n " )
362+ logger . debug ( "Result: %s" , toolchain_name )
363363
364364
365365 cmd = """ grep "toolchain = " """ + ebfile + """ | cut -f6 -d " " | tr -d "}" """
366- BUILDTEST_LOGCONTENT . append ( "executing command: " + cmd + " \n " )
366+ logger . debug ( "Executing command: %s" , cmd )
367367 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 )
369374
370375 # strip character ' and newline
371376 name = name .replace ('\' ' ,'' )
@@ -377,32 +382,21 @@ def check_software_version_in_easyconfig(easyconfig_repo, verbose):
377382 toolchain_version = toolchain_version .replace ('\' ' ,'' )
378383 toolchain_version = toolchain_version .replace ('\n ' ,'' )
379384
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 )
394388
395389
396390 # get name of eb file and remove .eb extension
397391 ebname = os .popen ("basename " + ebfile ).read ()
398- BUILDTEST_LOGCONTENT .append ("easyconfig file= " + ebname )
399392
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
400396 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 )
403399
404- #print "local logcontent"
405- #print logcontent
406400 # in case toolchain version uses '' set it to dummy
407401 if toolchain_version == '' :
408402 toolchain_version = ""
@@ -414,47 +408,53 @@ def check_software_version_in_easyconfig(easyconfig_repo, verbose):
414408 # eb name format used for comparison to calculate versionsuffx
415409 eb_name_format = name + "-" + version + "-" + toolchain_name + "-" + toolchain_version
416410
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 " )
419411
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
422417 if toolchain_name == "" :
423418 startpos = ebname .find (version )+ len (version )
424419 else :
425420 # extract version suffix
426421 startpos = ebname .find (toolchain_version )+ len (toolchain_version )
422+
427423 endpos = len (ebname )
428424 versionsuffix = ebname [startpos :endpos ]
429425
430426 # variable used for comparison
431427 version_versionsuffix = version + versionsuffix
432428
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 )
436432
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 )
437440 # print name,version_versionsuffix, toolchain_name, toolchain_version
438441 # print appname, appversion, tcname, tcversion
439442 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+
445445 print success_msg
446446 if tcname == "" :
447447 print "found easyconfig file: " + appname + "-" + appversion + ".eb"
448448 else :
449449 print "found easyconfig file: " + appname + "-" + appversion + "-" + tcname + "-" + tcversion + ".eb"
450450 return True
451-
451+ else :
452+ logger .debug ("All Checks failed to PASSED!" )
452453
453454 # mismatch in easyconfig entries for name,version+versionsuffix, and toolchain with specified entries
454455 if match == False :
455456 print fail_msg
456457 msg = "ERROR: Attempting to find easyconfig file " + appname + "-" + appversion + "-" + tcname + "-" + tcversion + ".eb"
457458 print msg
458- BUILDTEST_LOGCONTENT .append (msg )
459- update_logfile (verbose )
459+ logger .error ("%s" ,msg )
460460 sys .exit (1 )
0 commit comments