Skip to content

Commit 2dd61bf

Browse files
authored
Merge pull request #863 from rhc54/topic/fixes
Few corrections
2 parents 1b91d6f + 49241df commit 2dd61bf

File tree

2 files changed

+75
-20
lines changed

2 files changed

+75
-20
lines changed

pylib/Stages/TestRun/PMIxUnit.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
# @param modules_swap Modules to swap
2929
# @param timeout Time limit for application execution
3030
# @param dependencies Middleware dependencies
31+
# @param subdir Subdirectory where tests are located
32+
# @param parent Stage that built the tests
3133
# @}
3234
class PMIxUnit(TestRunMTTStage):
3335

@@ -43,6 +45,8 @@ def __init__(self):
4345
self.options['modules_swap'] = (None, "Modules to swap")
4446
self.options['timeout'] = (None, "Time limit for application execution")
4547
self.options['dependencies'] = (None, "Middleware dependencies")
48+
self.options['subdir'] = (None, "Subdirectory where tests are located")
49+
self.options['parent'] = (None, "Stage that built the tests")
4650
self.testDef = None
4751
self.cmds = None
4852
return
@@ -86,11 +90,6 @@ def execute(self, log, keyvals, testDef):
8690
else:
8791
mykeyvals[k] = keyvals[k]
8892

89-
# parse any provided options - these will override the defaults
90-
cmds = {}
91-
testDef.parseOptions(log, self.options, mykeyvals, cmds)
92-
self.cmds = cmds
93-
9493
# check the log for the title so we can
9594
# see if this is setting our default behavior
9695
try:
@@ -117,10 +116,15 @@ def execute(self, log, keyvals, testDef):
117116
log['stderr'] = "Section not specified"
118117
return
119118

119+
# parse any provided options - these will override the defaults
120+
cmds = {}
121+
testDef.parseOptions(log, self.options, mykeyvals, cmds)
122+
self.cmds = cmds
123+
120124
# must be executing a test of some kind - the install stage
121125
# must be specified so we can find the tests to be run
122126
try:
123-
parent = keyvals['parent']
127+
parent = cmds['parent']
124128
except KeyError:
125129
log['status'] = 1
126130
log['stderr'] = "Parent test install stage was not provided"
@@ -227,7 +231,7 @@ def execute(self, log, keyvals, testDef):
227231
break
228232
# mark that this was done
229233
midpath = True
230-
except KeyError:
234+
except:
231235
# if it was already installed, then no location would be provided
232236
pass
233237

@@ -298,8 +302,12 @@ def execute(self, log, keyvals, testDef):
298302
# to change to the test location and begin executing, first saving
299303
# our current location so we can return when done
300304
cwd = os.getcwd()
305+
try:
306+
if cmds['subdir'] is not None:
307+
location = os.path.join(location, cmds['subdir'])
308+
except:
309+
pass
301310
os.chdir(location)
302-
303311
testDef.logger.verbose_print("PMIxUnit: looking for tests in " + location)
304312

305313
# cycle thru the list of tests and execute each of them

pylib/Tools/Build/Autotools.py

Lines changed: 59 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,13 +130,35 @@ def execute(self, log, keyvals, testDef):
130130
# check if we need to point to middleware
131131
# do this before we load environment modules so we can append to the list if needed
132132
midpath = False
133+
try:
134+
savebinpath = os.environ['PATH']
135+
except KeyError:
136+
savebinpath = None
137+
try:
138+
savelibpath = os.environ['LIBRARY_PATH']
139+
except KeyError:
140+
savelibpath = None
141+
try:
142+
savecpath = os.environ['CPATH']
143+
except KeyError:
144+
savecpath = None
145+
try:
146+
saveldlibpath = os.environ['LD_LIBRARY_PATH']
147+
except KeyError:
148+
saveldlibpath = None
133149
try:
134150
if cmds['middleware'] is not None:
135151
# pass it down
136152
log['middleware'] = cmds['middleware']
137-
# get the log entry of its location
138-
midlog = testDef.logger.getLog(cmds['middleware'])
139-
if midlog is not None:
153+
# there may be more than one middleware noted here
154+
# so break it apart just in case
155+
# might be comma-delimited or space delimited
156+
mware = re.split("\s|,", cmds['middleware'])
157+
for m in mware:
158+
# get the log entry of its location
159+
midlog = testDef.logger.getLog(m)
160+
if midlog is None:
161+
continue
140162
# get the location of the middleware
141163
try:
142164
if midlog['location'] is not None:
@@ -145,7 +167,6 @@ def execute(self, log, keyvals, testDef):
145167
oldbinpath = os.environ['PATH']
146168
pieces = oldbinpath.split(':')
147169
except KeyError:
148-
oldbinpath = ""
149170
pieces = []
150171
bindir = os.path.join(midlog['location'], "bin")
151172
pieces.insert(0, bindir)
@@ -156,7 +177,6 @@ def execute(self, log, keyvals, testDef):
156177
oldldlibpath = os.environ['LD_LIBRARY_PATH']
157178
pieces = oldldlibpath.split(':')
158179
except KeyError:
159-
oldldlibpath = ""
160180
pieces = []
161181
bindir = os.path.join(midlog['location'], "lib")
162182
pieces.insert(0, bindir)
@@ -167,7 +187,6 @@ def execute(self, log, keyvals, testDef):
167187
oldcpath = os.environ['CPATH']
168188
pieces = oldcpath.split(':')
169189
except KeyError:
170-
oldcpath = ""
171190
pieces = []
172191
bindir = os.path.join(midlog['location'], "include")
173192
pieces.insert(0, bindir)
@@ -178,7 +197,6 @@ def execute(self, log, keyvals, testDef):
178197
oldlibpath = os.environ['LIBRARY_PATH']
179198
pieces = oldlibpath.split(':')
180199
except KeyError:
181-
oldlibpath = ""
182200
pieces = []
183201
bindir = os.path.join(midlog['location'], "lib")
184202
pieces.insert(0, bindir)
@@ -290,7 +308,12 @@ def execute(self, log, keyvals, testDef):
290308
# save the current directory so we can return to it
291309
cwd = os.getcwd()
292310
# now move to the package location
293-
os.chdir(location)
311+
try:
312+
os.chdir(location)
313+
except:
314+
log['status'] = 1
315+
return
316+
294317
# see if they want us to execute autogen
295318
try:
296319
if cmds['autogen_cmd'] is not None:
@@ -532,10 +555,34 @@ def execute(self, log, keyvals, testDef):
532555

533556
# if we added middleware to the paths, remove it
534557
if midpath:
535-
os.environ['PATH'] = oldbinpath
536-
os.environ['LD_LIBRARY_PATH'] = oldldlibpath
537-
os.environ['CPATH'] = oldcpath
538-
os.environ['LIBRARY_PATH'] = oldlibpath
558+
if savebinpath is None:
559+
try:
560+
del os.environ['PATH']
561+
except:
562+
pass
563+
else:
564+
os.environ['PATH'] = savebinpath
565+
if saveldlibpath is None:
566+
try:
567+
del os.environ['LD_LIBRARY_PATH']
568+
except:
569+
pass
570+
else:
571+
os.environ['LD_LIBRARY_PATH'] = saveldlibpath
572+
if savecpath is None:
573+
try:
574+
del os.environ['CPATH']
575+
except:
576+
pass
577+
else:
578+
os.environ['CPATH'] = savecpath
579+
if savelibpath is None:
580+
try:
581+
del os.environ['LIBRARY_PATH']
582+
except:
583+
pass
584+
else:
585+
os.environ['LIBRARY_PATH'] = savelibpath
539586

540587
# Add confirmation that build is complete
541588
try:

0 commit comments

Comments
 (0)