Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix ctests so each restart test has a seed unique to the first test #1832

Merged
merged 4 commits into from
Jul 16, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions cmake/AddFdbTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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}")
Expand Down
38 changes: 21 additions & 17 deletions tests/TestRunner/TestRunner.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand Down