Merge pull request #1832 from dyoungworth/bugFix
Fix ctests so each restart test has a seed unique to the first test
This commit is contained in:
commit
2520b69803
|
@ -84,13 +84,13 @@ function(add_fdb_test)
|
|||
if (NOT "${ADD_FDB_TEST_TEST_NAME}" STREQUAL "")
|
||||
set(test_name ${ADD_FDB_TEST_TEST_NAME})
|
||||
endif()
|
||||
math(EXPR test_idx "${CURRENT_TEST_INDEX} + 1")
|
||||
math(EXPR test_idx "${CURRENT_TEST_INDEX} + ${NUM_TEST_FILES}")
|
||||
set(CURRENT_TEST_INDEX "${test_idx}" PARENT_SCOPE)
|
||||
# set(<var> <value> PARENT_SCOPE) doesn't set the
|
||||
# value in this scope (only in the parent scope). So
|
||||
# if the value was undefined before, it will still be
|
||||
# undefined.
|
||||
math(EXPR assigned_id "${test_idx} - 1")
|
||||
math(EXPR assigned_id "${test_idx} - ${NUM_TEST_FILES}")
|
||||
if(ADD_FDB_TEST_UNIT)
|
||||
message(STATUS
|
||||
"ADDING UNIT TEST ${assigned_id} ${test_name}")
|
||||
|
|
|
@ -282,12 +282,10 @@ def run_simulation_test(basedir, options):
|
|||
pargs.append(options.log_format)
|
||||
test_dir = td.get_current_test_dir()
|
||||
if options.seed is not None:
|
||||
pargs.append('-s')
|
||||
seed = int(options.seed, 0)
|
||||
if options.test_number:
|
||||
idx = int(options.test_number)
|
||||
seed = ((seed + idx) % (2**32-2)) + 1
|
||||
pargs.append("{}".format(seed))
|
||||
wd = os.path.join(test_dir,
|
||||
'test_{}'.format(options.name.replace('/', '_')))
|
||||
os.mkdir(wd)
|
||||
|
@ -300,7 +298,12 @@ def run_simulation_test(basedir, options):
|
|||
tmp[0] = options.old_binary
|
||||
if not first:
|
||||
tmp.append('-R')
|
||||
if seed is not None:
|
||||
seed = ((seed + 1) % (2**32-2))
|
||||
first = False
|
||||
if seed is not None:
|
||||
tmp.append('-s')
|
||||
tmp.append("{}".format(seed))
|
||||
tmp.append('-f')
|
||||
tmp.append(testfile)
|
||||
command = ' '.join(tmp)
|
||||
|
@ -311,23 +314,24 @@ def run_simulation_test(basedir, options):
|
|||
cwd=wd)
|
||||
proc.wait()
|
||||
return_codes[command] = proc.returncode
|
||||
if proc.returncode != 0:
|
||||
break
|
||||
outfile = os.path.join(test_dir, 'traces.{}'.format(options.log_format))
|
||||
res = True
|
||||
if options.aggregate_traces == 'NONE':
|
||||
res = process_traces(basedir, options.name,
|
||||
wd, None, 'NONE', options.symbolicate,
|
||||
options.log_format, return_codes, options.seed)
|
||||
else:
|
||||
with open(outfile, 'a') as f:
|
||||
os.lockf(f.fileno(), os.F_LOCK, 0)
|
||||
pos = f.tell()
|
||||
outfile = os.path.join(test_dir, 'traces.{}'.format(options.log_format))
|
||||
res = True
|
||||
if options.aggregate_traces == 'NONE':
|
||||
res = process_traces(basedir, options.name,
|
||||
wd, f, options.aggregate_traces, options.symbolicate,
|
||||
wd, None, 'NONE', options.symbolicate,
|
||||
options.log_format, return_codes, options.seed)
|
||||
f.seek(pos)
|
||||
os.lockf(f.fileno(), os.F_ULOCK, 0)
|
||||
|
||||
else:
|
||||
with open(outfile, 'a') as f:
|
||||
os.lockf(f.fileno(), os.F_LOCK, 0)
|
||||
pos = f.tell()
|
||||
res = process_traces(basedir, options.name,
|
||||
wd, f, options.aggregate_traces, options.symbolicate,
|
||||
options.log_format, return_codes, options.seed)
|
||||
f.seek(pos)
|
||||
os.lockf(f.fileno(), os.F_ULOCK, 0)
|
||||
if proc.returncode != 0 or res == False:
|
||||
break
|
||||
if options.keep_logs == 'NONE' or options.keep_logs == 'FAILED' and res:
|
||||
print("Deleting old logs in {}".format(wd))
|
||||
traces = get_traces(wd, options.log_format)
|
||||
|
|
Loading…
Reference in New Issue