Skip to content

Commit

Permalink
Merge pull request #863 from rhc54/topic/fixes
Browse files Browse the repository at this point in the history
Few corrections
  • Loading branch information
rhc54 authored Sep 27, 2019
2 parents 1b91d6f + 49241df commit 2dd61bf
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 20 deletions.
24 changes: 16 additions & 8 deletions pylib/Stages/TestRun/PMIxUnit.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
# @param modules_swap Modules to swap
# @param timeout Time limit for application execution
# @param dependencies Middleware dependencies
# @param subdir Subdirectory where tests are located
# @param parent Stage that built the tests
# @}
class PMIxUnit(TestRunMTTStage):

Expand All @@ -43,6 +45,8 @@ def __init__(self):
self.options['modules_swap'] = (None, "Modules to swap")
self.options['timeout'] = (None, "Time limit for application execution")
self.options['dependencies'] = (None, "Middleware dependencies")
self.options['subdir'] = (None, "Subdirectory where tests are located")
self.options['parent'] = (None, "Stage that built the tests")
self.testDef = None
self.cmds = None
return
Expand Down Expand Up @@ -86,11 +90,6 @@ def execute(self, log, keyvals, testDef):
else:
mykeyvals[k] = keyvals[k]

# parse any provided options - these will override the defaults
cmds = {}
testDef.parseOptions(log, self.options, mykeyvals, cmds)
self.cmds = cmds

# check the log for the title so we can
# see if this is setting our default behavior
try:
Expand All @@ -117,10 +116,15 @@ def execute(self, log, keyvals, testDef):
log['stderr'] = "Section not specified"
return

# parse any provided options - these will override the defaults
cmds = {}
testDef.parseOptions(log, self.options, mykeyvals, cmds)
self.cmds = cmds

# must be executing a test of some kind - the install stage
# must be specified so we can find the tests to be run
try:
parent = keyvals['parent']
parent = cmds['parent']
except KeyError:
log['status'] = 1
log['stderr'] = "Parent test install stage was not provided"
Expand Down Expand Up @@ -227,7 +231,7 @@ def execute(self, log, keyvals, testDef):
break
# mark that this was done
midpath = True
except KeyError:
except:
# if it was already installed, then no location would be provided
pass

Expand Down Expand Up @@ -298,8 +302,12 @@ def execute(self, log, keyvals, testDef):
# to change to the test location and begin executing, first saving
# our current location so we can return when done
cwd = os.getcwd()
try:
if cmds['subdir'] is not None:
location = os.path.join(location, cmds['subdir'])
except:
pass
os.chdir(location)

testDef.logger.verbose_print("PMIxUnit: looking for tests in " + location)

# cycle thru the list of tests and execute each of them
Expand Down
71 changes: 59 additions & 12 deletions pylib/Tools/Build/Autotools.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,35 @@ def execute(self, log, keyvals, testDef):
# check if we need to point to middleware
# do this before we load environment modules so we can append to the list if needed
midpath = False
try:
savebinpath = os.environ['PATH']
except KeyError:
savebinpath = None
try:
savelibpath = os.environ['LIBRARY_PATH']
except KeyError:
savelibpath = None
try:
savecpath = os.environ['CPATH']
except KeyError:
savecpath = None
try:
saveldlibpath = os.environ['LD_LIBRARY_PATH']
except KeyError:
saveldlibpath = None
try:
if cmds['middleware'] is not None:
# pass it down
log['middleware'] = cmds['middleware']
# get the log entry of its location
midlog = testDef.logger.getLog(cmds['middleware'])
if midlog is not None:
# there may be more than one middleware noted here
# so break it apart just in case
# might be comma-delimited or space delimited
mware = re.split("\s|,", cmds['middleware'])
for m in mware:
# get the log entry of its location
midlog = testDef.logger.getLog(m)
if midlog is None:
continue
# get the location of the middleware
try:
if midlog['location'] is not None:
Expand All @@ -145,7 +167,6 @@ def execute(self, log, keyvals, testDef):
oldbinpath = os.environ['PATH']
pieces = oldbinpath.split(':')
except KeyError:
oldbinpath = ""
pieces = []
bindir = os.path.join(midlog['location'], "bin")
pieces.insert(0, bindir)
Expand All @@ -156,7 +177,6 @@ def execute(self, log, keyvals, testDef):
oldldlibpath = os.environ['LD_LIBRARY_PATH']
pieces = oldldlibpath.split(':')
except KeyError:
oldldlibpath = ""
pieces = []
bindir = os.path.join(midlog['location'], "lib")
pieces.insert(0, bindir)
Expand All @@ -167,7 +187,6 @@ def execute(self, log, keyvals, testDef):
oldcpath = os.environ['CPATH']
pieces = oldcpath.split(':')
except KeyError:
oldcpath = ""
pieces = []
bindir = os.path.join(midlog['location'], "include")
pieces.insert(0, bindir)
Expand All @@ -178,7 +197,6 @@ def execute(self, log, keyvals, testDef):
oldlibpath = os.environ['LIBRARY_PATH']
pieces = oldlibpath.split(':')
except KeyError:
oldlibpath = ""
pieces = []
bindir = os.path.join(midlog['location'], "lib")
pieces.insert(0, bindir)
Expand Down Expand Up @@ -290,7 +308,12 @@ def execute(self, log, keyvals, testDef):
# save the current directory so we can return to it
cwd = os.getcwd()
# now move to the package location
os.chdir(location)
try:
os.chdir(location)
except:
log['status'] = 1
return

# see if they want us to execute autogen
try:
if cmds['autogen_cmd'] is not None:
Expand Down Expand Up @@ -532,10 +555,34 @@ def execute(self, log, keyvals, testDef):

# if we added middleware to the paths, remove it
if midpath:
os.environ['PATH'] = oldbinpath
os.environ['LD_LIBRARY_PATH'] = oldldlibpath
os.environ['CPATH'] = oldcpath
os.environ['LIBRARY_PATH'] = oldlibpath
if savebinpath is None:
try:
del os.environ['PATH']
except:
pass
else:
os.environ['PATH'] = savebinpath
if saveldlibpath is None:
try:
del os.environ['LD_LIBRARY_PATH']
except:
pass
else:
os.environ['LD_LIBRARY_PATH'] = saveldlibpath
if savecpath is None:
try:
del os.environ['CPATH']
except:
pass
else:
os.environ['CPATH'] = savecpath
if savelibpath is None:
try:
del os.environ['LIBRARY_PATH']
except:
pass
else:
os.environ['LIBRARY_PATH'] = savelibpath

# Add confirmation that build is complete
try:
Expand Down

0 comments on commit 2dd61bf

Please sign in to comment.