11 from __future__
import print_function
17 from BuildMTTTool
import *
38 BuildMTTTool.__init__(self)
41 self.
options[
'middleware'] = (
None,
"Middleware stage that these tests are to be built against")
42 self.
options[
'parent'] = (
None,
"Section that precedes this one in the dependency tree")
43 self.
options[
'autogen_cmd'] = (
None,
"Command to be executed to setup the configure script, usually called autogen.sh or autogen.pl")
44 self.
options[
'configure_options'] = (
None,
"Options to be passed to configure. Note that the prefix will be automatically set and need not be provided here")
45 self.
options[
'make_options'] = (
None,
"Options to be passed to the make command")
46 self.
options[
'build_in_place'] = (
False,
"Build tests in current location (no prefix or install)")
47 self.
options[
'merge_stdout_stderr'] = (
False,
"Merge stdout and stderr into one output stream")
48 self.
options[
'stdout_save_lines'] = (-1,
"Number of lines of stdout to save")
49 self.
options[
'stderr_save_lines'] = (-1,
"Number of lines of stderr to save")
50 self.
options[
'modules'] = (
None,
"Modules to load")
51 self.
options[
'modules_unload'] = (
None,
"Modules to unload")
58 IPlugin.activate(self)
64 IPlugin.deactivate(self)
72 lines = testDef.printOptions(self.
options)
79 testDef.logger.verbose_print(
"Autotools Execute")
82 testDef.parseOptions(log, self.
options, keyvals, cmds)
85 if cmds[
'parent']
is not None:
90 parentlog = testDef.logger.getLog(cmds[
'parent'])
93 log[
'stderr'] =
"Parent",cmds[
'parent'],
"log not found"
97 log[
'stderr'] =
"Parent log not recorded"
102 log[
'stderr'] =
"Parent not specified"
105 location = parentlog[
'location']
108 log[
'stderr'] =
"Location of package to build was not specified in parent stage"
113 usedModuleUnload =
False
115 if cmds[
'modules_unload']
is not None:
116 status,stdout,stderr = testDef.modcmd.unloadModules(cmds[
'modules_unload'], testDef)
118 log[
'status'] = status
119 log[
'stderr'] = stderr
121 usedModuleUnload =
True
127 if cmds[
'modules']
is not None:
128 status,stdout,stderr = testDef.modcmd.loadModules(cmds[
'modules'], testDef)
130 log[
'status'] = status
131 log[
'stderr'] = stderr
140 availUtil = list(testDef.loader.utilities.keys())
141 for util
in availUtil:
142 for pluginInfo
in testDef.utilities.getPluginsOfCategory(util):
143 if "Compilers" == pluginInfo.plugin_object.print_name():
144 plugin = pluginInfo.plugin_object
147 log[
'compiler'] = {
'status' : 1,
'family' :
"unknown",
'version' :
"unknown"}
150 plugin.execute(compilerLog, testDef)
151 log[
'compiler'] = compilerLog
152 testDef.logger.verbose_print(log[
'compiler'])
156 fullLog = testDef.logger.getLog(
None)
157 mpi_info_found =
False
160 mpi_info_found =
True
161 if mpi_info_found
is False:
163 availUtil = list(testDef.loader.utilities.keys())
164 for util
in availUtil:
165 for pluginInfo
in testDef.utilities.getPluginsOfCategory(util):
166 if "MPIVersion" == pluginInfo.plugin_object.print_name():
167 plugin = pluginInfo.plugin_object
170 log[
'mpi_info'] = {
'name' :
'unknown',
'version' :
'unknown'}
173 plugin.execute(mpi_info, testDef)
174 log[
'mpi_info'] = mpi_info
176 testDef.logger.verbose_print(
"mpi_info already in log so skipping MPIVersion")
180 log[
'configure_options'] = cmds[
'configure_options']
182 log[
'configure_options'] =
''
185 if cmds[
'build_in_place']:
187 log[
'location'] = location
191 pfx = os.path.join(testDef.options[
'scratchdir'], log[
'section'].replace(
':',
'_'))
193 pfx = os.path.abspath(pfx)
195 log[
'location'] = pfx
196 prefix =
"--prefix={0}".format(pfx)
199 pfx = os.path.join(testDef.options[
'scratchdir'], log[
'section'].replace(
':',
'_'))
201 pfx = os.path.abspath(pfx)
203 log[
'location'] = pfx
204 prefix =
"--prefix={0}".format(pfx)
211 if os.path.exists(pfx)
and os.path.isdir(pfx):
212 testDef.logger.verbose_print(
"As-Is location " + pfx +
" exists and is a directory")
218 cfg = os.path.join(location,
"configure")
219 if os.path.exists(cfg):
221 testDef.logger.verbose_print(
"As-Is location " + location +
" has configure present")
227 if testDef.options[
'dryrun']:
235 if cmds[
'middleware']
is not None:
237 log[
'middleware'] = cmds[
'middleware']
239 midlog = testDef.logger.getLog(cmds[
'middleware'])
240 if midlog
is not None:
243 if midlog[
'location']
is not None:
246 oldbinpath = os.environ[
'PATH']
247 pieces = oldbinpath.split(
':')
251 bindir = os.path.join(midlog[
'location'],
"bin")
252 pieces.insert(0, bindir)
253 newpath =
":".join(pieces)
254 os.environ[
'PATH'] = newpath
257 oldldlibpath = os.environ[
'LD_LIBRARY_PATH']
258 pieces = oldldlibpath.split(
':')
262 bindir = os.path.join(midlog[
'location'],
"lib")
263 pieces.insert(0, bindir)
264 newpath =
":".join(pieces)
265 os.environ[
'LD_LIBRARY_PATH'] = newpath
268 oldcpath = os.environ[
'CPATH']
269 pieces = oldcpath.split(
':')
273 bindir = os.path.join(midlog[
'location'],
"include")
274 pieces.insert(0, bindir)
275 newpath =
":".join(pieces)
276 os.environ[
'CPATH'] = newpath
279 oldlibpath = os.environ[
'LIBRARY_PATH']
280 pieces = oldlibpath.split(
':')
284 bindir = os.path.join(midlog[
'location'],
"lib")
285 pieces.insert(0, bindir)
286 newpath =
":".join(pieces)
287 os.environ[
'LIBRARY_PATH'] = newpath
295 if midlog[
'parameters']
is not None:
296 for md
in midlog[
'parameters']:
297 if "modules" == md[0]:
299 if cmds[
'modules']
is not None:
301 mods = md[1].split(
',')
302 newmods = modules.split(
',')
305 cmds[
'modules'] =
','.join(mods)
307 cmds[
'modules'] = md[1]
320 if cmds[
'autogen_cmd']
is not None:
322 args = cmds[
'autogen_cmd'].split()
324 agargs.append(arg.strip())
325 status, stdout, stderr, _ = testDef.execmd.execute(cmds, agargs, testDef)
327 log[
'status'] = status
328 log[
'stdout'] = stdout
329 log[
'stderr'] = stderr
332 status,stdout,stderr = testDef.modcmd.unloadModules(cmds[
'modules'], testDef)
334 log[
'status'] = status
335 log[
'stderr'] = stderr
339 status,stdout,stderr = testDef.modcmd.loadModules(cmds[
'modules_unload'], testDef)
341 log[
'status'] = status
342 log[
'stderr'] = stderr
351 log[
'autogen'] = (stdout, stderr)
359 cfgargs = [
"./configure"]
360 if prefix
is not None:
361 cfgargs.append(prefix)
364 if cmds[
'configure_options']
is not None:
365 args = shlex.split(cmds[
'configure_options'])
367 cfgargs.append(arg.strip())
370 status, stdout, stderr, _ = testDef.execmd.execute(cmds, cfgargs, testDef)
372 log[
'status'] = status
373 log[
'stdout'] = stdout
374 log[
'stderr'] = stderr
377 status,stdout,stderr = testDef.modcmd.unloadModules(cmds[
'modules'], testDef)
379 log[
'status'] = status
380 log[
'stderr'] = stderr
387 log[
'configure'] = (stdout, stderr)
393 if cmds[
'make_options']
is not None:
394 args = cmds[
'make_options'].split()
396 bldargs.append(arg.strip())
399 args = testDef.options.default_make_options.split()
401 bldargs.append(arg.strip())
403 bldargs.append(
"clean")
404 status, stdout, stderr, _ = testDef.execmd.execute(cmds, bldargs, testDef)
406 log[
'status'] = status
407 log[
'stdout'] = stdout
408 log[
'stderr'] = stderr
411 status,stdout,stderr = testDef.modcmd.unloadModules(cmds[
'modules'], testDef)
413 log[
'status'] = status
414 log[
'stderr'] = stderr
421 log[
'make_clean'] = (stdout, stderr)
423 bldargs = bldargs[0:-1]
424 bldargs.append(
"all")
425 status, stdout, stderr, _ = testDef.execmd.execute(cmds, bldargs, testDef)
427 log[
'status'] = status
428 log[
'stdout'] = stdout
429 log[
'stderr'] = stderr
432 status,stdout,stderr = testDef.modcmd.unloadModules(cmds[
'modules'], testDef)
434 log[
'status'] = status
435 log[
'stderr'] = stderr
442 log[
'make_all'] = (stdout, stderr)
444 if prefix
is not None:
445 bldargs = bldargs[0:-1]
446 bldargs.append(
"install")
447 status, stdout, stderr, _ = testDef.execmd.execute(cmds, bldargs, testDef)
450 log[
'status'] = status
451 log[
'stdout'] = stdout
452 log[
'stderr'] = stderr
455 status,stdout,stderr = testDef.modcmd.unloadModules(cmds[
'modules'], testDef)
457 log[
'status'] = status
458 log[
'stderr'] = stderr
462 os.environ[
'PATH'] = oldbinpath
463 os.environ[
'LD_LIBRARY_PATH'] = oldldlibpath
464 os.environ[
'CPATH'] = oldcpath
465 os.environ[
'LIBRARY_PATH'] = oldlibpath