@@ -120,6 +120,7 @@ def generate_source_test(configmap,codedir,verbose,subdir):
120
120
tcname = get_toolchain_name ()
121
121
tcver = get_toolchain_version ()
122
122
123
+ logger = logging .getLogger (logID )
123
124
# app_destdir is root of test directory
124
125
app_destdir = os .path .join (BUILDTEST_TESTDIR ,"ebapp" ,appname ,appver ,tcname ,tcver )
125
126
@@ -128,11 +129,6 @@ def generate_source_test(configmap,codedir,verbose,subdir):
128
129
destdir = os .path .join (app_destdir ,subdir )
129
130
cmakelist = os .path .join (destdir ,"CMakeLists.txt" )
130
131
131
- BUILDTEST_LOGCONTENT .append ("\n " )
132
- BUILDTEST_LOGCONTENT .append ("------------------------------------------------ \n " )
133
- BUILDTEST_LOGCONTENT .append ("function: generate_source_test \n " )
134
- BUILDTEST_LOGCONTENT .append ("------------------------------------------------ \n " )
135
-
136
132
# if subdirectory exists, create subdirectory in destdir so we can write test script
137
133
if subdir != "" :
138
134
# if sub directory does not exist, then create all directories and its parents directories
@@ -151,11 +147,11 @@ def generate_source_test(configmap,codedir,verbose,subdir):
151
147
if "buildopts" in configmap :
152
148
flags = configmap ["buildopts" ]
153
149
154
- BUILDTEST_LOGCONTENT . append ("Test Name: " + testname + " \n " )
155
- BUILDTEST_LOGCONTENT . append ("Test Path: " + testpath + " \n " )
156
- BUILDTEST_LOGCONTENT . append ("Source File: " + sourcefilepath + " \n " )
157
- BUILDTEST_LOGCONTENT . append ("Executable Name: " + executable + " \n " )
158
- BUILDTEST_LOGCONTENT . append ("Build Flags: " + flags + " \n " )
150
+ logger . debug ("Test Name: %s" , testname )
151
+ logger . debug ("Test Path: %s" , testpath )
152
+ logger . debug ("Source File: %s" , sourcefilepath )
153
+ logger . debug ("Executable Name: %s" , executable )
154
+ logger . debug ("Build Flags: %s" , flags )
159
155
160
156
161
157
# write the preamble to test-script to initialize app environment using module cmds
@@ -172,11 +168,14 @@ def generate_source_test(configmap,codedir,verbose,subdir):
172
168
# used for parallel processing to specify # of procs with mpirun -np
173
169
nproc = ""
174
170
171
+
172
+ logger .debug ("""Checking for YAML key "buildcmd" and "runcmd" """ )
173
+
175
174
# if there is a buildcmd & runcmd in yaml file, place this directly in test script
176
175
if "buildcmd" in configmap and "runcmd" in configmap :
177
176
178
- BUILDTEST_LOGCONTENT . append ("YAML file found buildcmd and runcmd. \n " )
179
- BUILDTEST_LOGCONTENT . append ("buildtest will generate explicit build/run commands from buildcmd and runcmd fields \n " )
177
+ logger . debug ("YAML file found buildcmd and runcmd." )
178
+ logger . debug ("buildtest will generate explicit build/run commands from buildcmd and runcmd field " )
180
179
181
180
# only process buildcmd if there is a value specified for buildcmd key
182
181
if configmap ["buildcmd" ] != None :
@@ -186,7 +185,7 @@ def generate_source_test(configmap,codedir,verbose,subdir):
186
185
buildcmd += cmd + "\n "
187
186
else :
188
187
msg = "buildcmd is declared but value is not specified \n "
189
- BUILDTEST_LOGCONTENT . append ( msg )
188
+ logger . debug ( "%s" , msg )
190
189
191
190
if configmap ["runcmd" ] != None :
192
191
# process the runcmd tag similar same as buildcmd and store in variable
@@ -197,10 +196,9 @@ def generate_source_test(configmap,codedir,verbose,subdir):
197
196
else :
198
197
msg = "runcmd is declared but value is not specified. Need runcmd to run executable \n "
199
198
print msg
200
- BUILDTEST_LOGCONTENT .append (msg )
201
- BUILDTEST_LOGCONTENT .append ("Program Terminating \n " )
202
- update_logfile (verbose )
203
- sys .exit (1 )
199
+ logger .debug .append ("%s" ,msg )
200
+ logging .warning ("Unable to create test from YAML config, skipping test generation" )
201
+ return
204
202
205
203
206
204
if verbose >= 1 :
@@ -230,17 +228,15 @@ def generate_source_test(configmap,codedir,verbose,subdir):
230
228
if "buildcmd" in configmap and "runcmd" not in configmap or "buildcmd" not in configmap and "runcmd" in configmap :
231
229
print "Need to specify both key: buildcmd and runcmd"
232
230
233
- BUILDTEST_LOGCONTENT .append ("Need to declare both key: buildcmd and runcmd \n " )
234
- BUILDTEST_LOGCONTENT .append ("Program Terminating \n " )
235
- update_logfile (verbose )
236
- sys .exit (1 )
231
+ logger .warning ("Need to declare both key: buildcmd and runcmd. Skipping to next YAML config \n " )
232
+ return
237
233
238
234
# get the compiler tag and type based on application and toolchain
239
235
compiler ,compiler_type = get_compiler (configmap ,appname ,tcname )
240
236
241
- BUILDTEST_LOGCONTENT . append ("buildtest will auto-generate buildcmd & runcmd \n " )
242
- BUILDTEST_LOGCONTENT . append ("Compiler: " + compiler + " \n " )
243
- BUILDTEST_LOGCONTENT . append ("Compiler Type: " + compiler_type + " \n " )
237
+ logger . debug ("buildtest will auto-generate buildcmd & runcmd" )
238
+ logger . debug ("Compiler: %s" , compiler )
239
+ logger . debug ("Compiler Type: %s" , compiler_type )
244
240
245
241
# set buildcmd based on compiler_type. compiler is either nvcc,gcc,icc,mpicc, or mpiicc for intel
246
242
if compiler_type == "gnu" or compiler_type == "intel" or compiler_type == "cuda" :
@@ -254,13 +250,13 @@ def generate_source_test(configmap,codedir,verbose,subdir):
254
250
if "nproc" in configmap :
255
251
nproc = str (configmap ["nproc" ])
256
252
257
- BUILDTEST_LOGCONTENT . append ("nproc key found in YAML config file \n " )
258
- BUILDTEST_LOGCONTENT . append ("nproc: " + nproc + " \n " )
253
+ logger . debug ("nproc key found in YAML config file" )
254
+ logger . debug ("nproc: " , nproc )
259
255
# if nproc is not specified set it to 1 when building mpi apps
260
256
else :
261
257
nproc = "1"
262
258
263
- BUILDTEST_LOGCONTENT . append ("nproc key not found in YAML config file, will set nproc = 1 \n " )
259
+ logger . debug ("nproc key not found in YAML config file, will set nproc = 1" )
264
260
# add argument to runcmd in MPI jobs
265
261
if "args" in configmap :
266
262
arglist = configmap ["args" ]
@@ -329,8 +325,8 @@ def generate_source_test(configmap,codedir,verbose,subdir):
329
325
for cmd in configmap ["runextracmd" ]:
330
326
fd .write (cmd + "\n " )
331
327
332
- BUILDTEST_LOGCONTENT . append ("runextracmd found in YAML config file \n " )
333
- BUILDTEST_LOGCONTENT . append ("runextracmd:" + str (configmap ["runextracmd" ]) + " \n " )
328
+ logger . debug ("runextracmd found in YAML config file" )
329
+ logger . debug ("runextracmd: %s" , str (configmap ["runextracmd" ]))
334
330
fd .close ()
335
331
336
332
# by default run the commands below which will add the test to CMakeLists.txt and update the logfile
@@ -339,17 +335,17 @@ def generate_source_test(configmap,codedir,verbose,subdir):
339
335
340
336
# print "Creating Test: " + testpath
341
337
342
- BUILDTEST_LOGCONTENT .append ("Creating Test: " + testpath + "\n " )
343
- BUILDTEST_LOGCONTENT .append ("Content of Testfile: " + testpath + "\n " )
344
- BUILDTEST_LOGCONTENT .append ("----------------------- \n " )
345
-
338
+ logger .debug ("Creating Test: %s " , testpath )
339
+ logger .debug ("[TEST START-BLOCK]" )
340
+
346
341
fd = open (testpath ,'r' )
347
- content = fd .read ()
348
- BUILDTEST_LOGCONTENT .append (content )
342
+ content = fd .read ().splitlines ()
343
+ for line in content :
344
+ logger .debug (line )
349
345
fd .close ()
350
346
347
+ logger .debug ("[TEST END-BLOCK]" )
351
348
352
- BUILDTEST_LOGCONTENT .append ("\n -------------------------------------------------- \n " )
353
349
354
350
# if keyword iter is found in YAML, lets try to recreate N tests by renaming test such as
355
351
# hello.sh to hello_1.sh and create N-1 copies with file names hello_2.sh, hello_3.sh, ...
@@ -603,13 +599,17 @@ def process_binary_file(filename,args_dict,test_type,verbose,pkg):
603
599
add_test_str = "add_test(NAME system-" + pkg + "-" + testname + "\t COMMAND sh " + testname + "\t WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) \n "
604
600
605
601
606
- logger .debug ("Adding content: %s " , add_test_str , )
602
+ logger .debug ("Adding content: %s " , add_test_str )
607
603
fd .write (add_test_str )
608
604
609
605
# print "Creating Test:", testpath
610
606
611
607
print
612
- print "Generating " + str (count ) + " binary tests for package: " + pkg
608
+ if test_type == "system" :
609
+ print "Generating " + str (count ) + " binary tests for package: " + pkg
610
+ else :
611
+ print "Generating " + str (count ) + " binary tests for Application: " + name + "/" + version
612
+
613
613
print "Binary Tests are written in " + test_destdir
614
614
615
615
0 commit comments