Skip to content

Commit 51bbadf

Browse files
changed all variable logcontent to BUILDTEST_LOGCONTENT. Now there is
no need to pass in the variable to each function, BUILDTEST_LOGCONTENT is a global variable that can be accessed from any file. There has been more logging output for module and eb verification
1 parent 5bc6c66 commit 51bbadf

File tree

10 files changed

+236
-225
lines changed

10 files changed

+236
-225
lines changed

buildtest.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -211,27 +211,26 @@
211211
if software != None:
212212
software=software.split("/")
213213

214+
# checking if software exists
215+
software_exists(software,verbose)
214216
appname,appversion=software
217+
215218
if toolchain == None:
216219
toolchain = "dummy/dummy"
217220

218221
toolchain=toolchain.split("/")
222+
# checking if its a valid toolchain
223+
toolchain_exists(toolchain,verbose)
224+
219225
tcname,tcversion=toolchain
220226

221227

222-
# checking if its a valid software
223-
logcontent += software_exists(software,verbose)
224-
225-
# checking if its a valid toolchain
226-
toolchain_exists(toolchain)
227228
if verbose >= 1:
228229
text = "Toolchain:" + tcname + " " + tcversion + " found in system \n"
229230
print text
230-
logcontent += text
231231

232232
# check that the software,toolchain match the easyconfig.
233-
ret,logcontent_substr=check_software_version_in_easyconfig(BUILDTEST_EASYCONFIGDIR,software,toolchain)
234-
logcontent+=logcontent_substr
233+
ret=check_software_version_in_easyconfig(BUILDTEST_EASYCONFIGDIR,software,toolchain)
235234
# generate_binary_test(software,toolchain,verbose)
236235

237236
source_app_dir=os.path.join(BUILDTEST_SOURCEDIR,"ebapps",appname)
@@ -242,16 +241,16 @@
242241
logdir=os.environ["BUILDTEST_LOGDIR"]
243242

244243

245-
logcontent += "Source App Directory:" + source_app_dir + "\n"
246-
logcontent += "Config Directory: " + configdir + "\n"
247-
logcontent += "Code Directory:" + codedir + "\n"
244+
BUILDTEST_LOGCONTENT.append("Source App Directory:" + source_app_dir + "\n")
245+
BUILDTEST_LOGCONTENT.append("Config Directory: " + configdir + "\n")
246+
BUILDTEST_LOGCONTENT.append("Code Directory:" + codedir + "\n")
248247

249248
generate_binary_test(args_dict,verbose,None)
250249
# this generates all the compilation tests found in application directory ($BUILDTEST_SOURCEDIR/ebapps/<software>)
251-
logcontent += recursive_gen_test(software,toolchain,configdir,codedir,verbose, logdir)
250+
recursive_gen_test(software,toolchain,configdir,codedir,verbose)
252251

253252
# if flag --testset is set, then
254253
if testset != None:
255-
logcontent+=run_testset(software,toolchain,testset,verbose,logdir)
254+
run_testset(software,toolchain,testset,verbose)
256255

257256
update_logfile(verbose)

master.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,13 @@
2525
from tools.generic import *
2626

2727

28-
def recursive_gen_test(software,toolchain,configdir,codedir,verbose,logdir):
28+
def recursive_gen_test(software,toolchain,configdir,codedir,verbose ):
2929
""" if config directory exists then process .yaml files to build source test """
30-
logcontent = "\n ------------------------------------------------------------ \n"
31-
logcontent += " function: recursive_gen_test \n"
32-
logcontent += "------------------------------------------------------------ \n"
33-
logcontent += " Processing all YAML files in " + configdir
30+
BUILDTEST_LOGCONTENT.append("\n ------------------------------------------------------------ \n")
31+
BUILDTEST_LOGCONTENT.append(" function: recursive_gen_test \n")
32+
BUILDTEST_LOGCONTENT.append("------------------------------------------------------------ \n")
33+
BUILDTEST_LOGCONTENT.append("Processing all YAML files in " + configdir)
34+
3435
if os.path.isdir(configdir):
3536
for root,subdirs,files in os.walk(configdir):
3637

@@ -49,6 +50,5 @@ def recursive_gen_test(software,toolchain,configdir,codedir,verbose,logdir):
4950
# error processing config file, then parse_config will return an empty dictionary
5051
if len(configmap) == 0:
5152
continue
52-
logcontent+=generate_source_test(software,toolchain,configmap,code_destdir,verbose,subdir,logdir)
53-
return logcontent
53+
generate_source_test(software,toolchain,configmap,code_destdir,verbose,subdir)
5454

modules.py

Lines changed: 97 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -124,64 +124,93 @@ def get_toolchain(easyconfigdir):
124124
BUILDTEST_LOGCONTENT.append("-------------------------------------\n")
125125

126126
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+
127131
# only care about unique toolchains
128132
toolchain=set()
129-
logcontent = ""
130133
# find all toolchains in the easyconfig files
131134
for ebfile in easyconfigfiles:
132135

133-
logcontent += ebfile + "\n"
134136

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")
136139
toolchain_name=os.popen(cmd).read().rstrip()
137140
cmd="""grep "toolchain =" """ + ebfile + """ | cut -f6 -d " " | tr -d "}'" """
141+
BUILDTEST_LOGCONTENT.append("Running Command: " + cmd + "\n")
138142
toolchain_version=os.popen(cmd).read().rstrip()
139143
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")
140148
return toolchain
141149

142150
def software_exists(software,verbose):
143151
"""
144152
checks whether software exist, there must be a module file present with the
145153
same name specified as the argument.
146154
"""
147-
logcontent = ""
148155
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)
150160
sys.exit(1)
151161

152162
softwarecollection=get_unique_software_version(BUILDTEST_MODULE_EBROOT)
153163
software_name=software[0]+" "+software[1]
154164
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)
156169
sys.exit(1)
170+
157171
text = "Software:" + str(software) + " found in system \n"
158-
logcontent = text
159-
return logcontent
172+
BUILDTEST_LOGCONTENT.append(text)
173+
160174

161175

162-
def toolchain_exists(toolchain):
176+
def toolchain_exists(toolchain,verbose):
163177
"""
164178
checks to see if toolchain passed on command line exist in toolchain list
165179
"""
166180

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+
167189
toolchain_list=get_toolchain(BUILDTEST_EASYCONFIGDIR)
168190

191+
BUILDTEST_LOGCONTENT.append("-------------------------------------------\n")
192+
BUILDTEST_LOGCONTENT.append("func: toolchain_exists \n")
193+
BUILDTEST_LOGCONTENT.append("-------------------------------------------\n")
169194
# if toolchain is installed as hidden file then strip the "." prior to checking in list
170195
if isHiddenFile(toolchain[1]) == True:
171196
strip_version=stripHiddenFile(toolchain[1])
172197
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")
173200
else:
174201
toolchain_name=toolchain[0]+" "+toolchain[1]
175202

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
181204
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)
183209
sys.exit(1)
184210

211+
msg = "Toolchain + " + toolchain_name + " found in system"
212+
BUILDTEST_LOGCONTENT.append(msg)
213+
185214
def check_software_version_in_easyconfig(moduletree,software,toolchain):
186215
"""
187216
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):
197226
cmd="find " + os.path.join(moduletree,appname) + " -name *.eb -type f"
198227
easyconfigfiles=os.popen(cmd).read().rstrip().split("\n")
199228

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")
202236

203237
# boolean value to check if eb file found with parameters for software and toolchain
204238
match=False
205239

206240
# if user is testing a software package that is a hidden module file, strip the leading "." for checking
207241
if isHiddenFile(appversion):
208242
appversion = stripHiddenFile(appversion)
209-
logcontent += "Stripping leading . from application version: " + appversion
243+
BUILDTEST_LOGCONTENT.append("Stripping leading . from application version: " + appversion + "\n")
210244

211245
# if user specified a toolchain version that is a hidden module file, strip leading "."
212246
if isHiddenFile(tcversion):
213247
tcversion = stripHiddenFile(tcversion)
214-
logcontent += "Stripping leading . from toolchain version: " + tcversion
248+
BUILDTEST_LOGCONTENT.append("Stripping leading . from toolchain version: " + tcversion + "\n")
215249

216250
for ebfile in easyconfigfiles:
217251
# get name tag from easyconfig
218252
cmd="""grep "name = " """ + ebfile + """ | cut -f3 -d " " """
219-
logcontent += "executing command: " + cmd + "\n"
253+
BUILDTEST_LOGCONTENT.append("executing command: " + cmd + "\n")
220254

221255
name=os.popen(cmd).read()
222-
logcontent += "result: " + name + "\n"
256+
BUILDTEST_LOGCONTENT.append("result: " + name + "\n")
223257

224258
# get version tag from easyconfig, possibility for multiple occurence so get 1st entry
225259
cmd="""grep "version = " """ + ebfile + """ | cut -f3 -d " " | head -n1 """
226-
logcontent += "executing command: " + cmd + "\n"
260+
BUILDTEST_LOGCONTENT.append("executing command: " + cmd + "\n")
227261
version=os.popen(cmd).read()
228-
logcontent += "result: " + version + "\n"
262+
BUILDTEST_LOGCONTENT.append("result: " + version + "\n")
229263

230264
cmd=""" grep "toolchain = " """ + ebfile + """ | cut -f4 -d " " | tr -d "," """
231-
logcontent += "executing command: " + cmd + "\n"
265+
BUILDTEST_LOGCONTENT.append("executing command: " + cmd + "\n")
232266
toolchain_name=os.popen(cmd).read()
233-
logcontent += "result: " + toolchain_name + "\n"
267+
BUILDTEST_LOGCONTENT.append("result: " + toolchain_name + "\n")
234268

235269

236270
cmd=""" grep "toolchain = " """ + ebfile + """ | cut -f6 -d " " | tr -d "}" """
237-
logcontent += "executing command: " + cmd + "\n"
271+
BUILDTEST_LOGCONTENT.append("executing command: " + cmd + "\n")
238272
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")
247274

248275
# strip character ' and newline
249276
name=name.replace('\'','')
@@ -255,21 +282,29 @@ def check_software_version_in_easyconfig(moduletree,software,toolchain):
255282
toolchain_version=toolchain_version.replace('\'','')
256283
toolchain_version=toolchain_version.replace('\n','')
257284

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+
265300

266301
# get name of eb file and remove .eb extension
267302
ebname=os.popen("basename " + ebfile).read()
268-
logcontent = "easyconfig file= " + ebname
303+
BUILDTEST_LOGCONTENT.append("easyconfig file= " + ebname)
269304

270305
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")
273308

274309
#print "local logcontent"
275310
#print logcontent
@@ -283,8 +318,8 @@ def check_software_version_in_easyconfig(moduletree,software,toolchain):
283318
# eb name format used for comparison to calculate versionsuffx
284319
eb_name_format=name+"-"+version+"-"+toolchain_name+"-"+toolchain_version
285320

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")
288323

289324
# There is no version suffix when file name is just software-version-toolchain
290325
# 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):
299334
# variable used for comparison
300335
version_versionsuffix=version + versionsuffix
301336

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")
305340

306341
# master condition to determine if easyconfig parameter match argument for software and toolchain
307342
if tcname == "dummy" and tcversion == "dummy":
308343
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
313348
else:
314349
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
321356

322357
# mismatch in easyconfig entries for name,version+versionsuffix, and toolchain with specified entries
323358
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)
329362
sys.exit(1)

0 commit comments

Comments
 (0)