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 2 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
5 changes: 4 additions & 1 deletion cmake/AddFdbTest.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ function(add_fdb_test)
# if the value was undefined before, it will still be
# undefined.
math(EXPR assigned_id "${test_idx} - 1")
math(EXPR test_file_idx "${CURRENT_TEST_FILE_INDEX} + ${NUM_TEST_FILES}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only thing you should change here is the math-expression for test_idx

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will do. I kept the old test_idx just so when printing tests you get a contiguous count, but that doesn't happen when tests are skipped anyway

set(CURRENT_TEST_FILE_INDEX "${test_file_idx}" PARENT_SCOPE)
math(EXPR assigned_test_number "${test_file_idx} - ${NUM_TEST_FILES}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Basically same as above: instead of introducing a new variable, just change the math for assigned_id

if(ADD_FDB_TEST_UNIT)
message(STATUS
"ADDING UNIT TEST ${assigned_id} ${test_name}")
Expand Down Expand Up @@ -118,7 +121,7 @@ function(add_fdb_test)
--keep-logs ${TEST_KEEP_LOGS}
--keep-simdirs ${TEST_KEEP_SIMDIR}
--seed ${SEED}
--test-number ${assigned_id}
--test-number ${assigned_test_number}
${BUGGIFY_OPTION}
${ADD_FDB_TEST_TEST_FILES}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
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