Skip to content

Commit eb819d2

Browse files
committed
Small fixes for new tape test output examination.
1 parent 7c9d4b3 commit eb819d2

File tree

1 file changed

+17
-9
lines changed

1 file changed

+17
-9
lines changed

TestCases/TestCase.py

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@ def run_test(self, with_tsan=False, with_asan=False, with_tapetests=False):
145145
timed_out = False
146146
iter_missing = True
147147
start_solver = True
148+
tapetest_out = True
148149

149150
# if root, add flag to mpirun
150151
self.command.allow_mpi_as_root()
@@ -197,8 +198,8 @@ def run_test(self, with_tsan=False, with_asan=False, with_tapetests=False):
197198

198199
if not with_tsan and not with_asan and not with_tapetests: # Sanitizer findings result in non-zero return code, no need to examine the output. Tapetest output is examined separately.
199200
# Examine the output
200-
f = open(logfilename,'r')
201-
output = f.readlines()
201+
with open(logfilename,'r') as f:
202+
output = f.readlines()
202203
if not timed_out and len(self.test_vals) != 0:
203204
start_solver = False
204205
for line in output:
@@ -248,14 +249,14 @@ def run_test(self, with_tsan=False, with_asan=False, with_tapetests=False):
248249
# print(j)
249250

250251
if with_tapetests and self.enabled_with_tapetests: # examine the tapetest output
251-
f = open(logfilename,'r')
252-
output = f.readlines()
252+
with open(logfilename,'r') as f:
253+
output = f.readlines()
253254
if not timed_out and len(self.tapetest_vals) != 0:
254-
start_solver = False
255+
tapetest_out = False
255256
for line in output:
256-
if not start_solver: # Don't bother parsing anything before "Total number of tape inconsistencies"; for consistency, we keep the "start_solver" boolean
257+
if not tapetest_out: # Don't bother parsing anything before "Total number of tape inconsistencies"
257258
if line.find('Total number of tape inconsistencies:') > -1:
258-
start_solver=True
259+
tapetest_out = True
259260
raw_data = line.split(':') # Split line into description and the string representing the number of errors
260261
data = raw_data[1].strip() # Clear the string representing the number of errors (for now, expecting a single integer, but zone-wise error numbers are planned)
261262

@@ -270,6 +271,10 @@ def run_test(self, with_tsan=False, with_asan=False, with_tapetests=False):
270271
exceed_tol = True
271272
passed = False
272273

274+
if not tapetest_out:
275+
passed = False
276+
277+
273278
process.communicate()
274279
if process.returncode != 0:
275280
passed = False
@@ -288,9 +293,12 @@ def run_test(self, with_tsan=False, with_asan=False, with_tapetests=False):
288293
if exceed_tol:
289294
print('ERROR: Difference between computed input and test_vals exceeded tolerance. TOL=%f'%self.tol)
290295

291-
if not start_solver:
296+
if not start_solver and not with_tapetests:
292297
print('ERROR: The code was not able to get to the "Begin solver" section.')
293298

299+
if not tapetest_out and with_tapetests:
300+
print('ERROR: The code was not able to get to the "Total number of tape inconsistencies" line.')
301+
294302
if not with_tsan and not with_asan and not with_tapetests and iter_missing:
295303
print('ERROR: The iteration number %d could not be found.'%self.test_iter)
296304

@@ -725,7 +733,7 @@ def run_geo(self, with_tsan=False, with_asan=False, with_tapetests=False):
725733
delta_vals.append( abs(float(data[j])-self.test_vals[j]) )
726734
if delta_vals[j] > self.tol:
727735
exceed_tol = True
728-
passed = False
736+
passed = False
729737
else:
730738
iter_missing = True
731739

0 commit comments

Comments
 (0)