From 62d7ee9424377ee15b89ebca4f099bf52a6ee5bf Mon Sep 17 00:00:00 2001 From: dyoungworth Date: Thu, 11 Jul 2019 09:55:01 -0700 Subject: [PATCH 1/3] Fix ctests so each restart test has a seed unique to the first test and any other test --- cmake/AddFdbTest.cmake | 5 +++- tests/TestRunner/TestRunner.py | 42 +++++++++++++++++++--------------- 2 files changed, 27 insertions(+), 20 deletions(-) diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index 3835f82350..ce2edcaacf 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -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}") + set(CURRENT_TEST_FILE_INDEX "${test_file_idx}" PARENT_SCOPE) + math(EXPR assigned_test_number "${test_file_idx} - ${NUM_TEST_FILES}") if(ADD_FDB_TEST_UNIT) message(STATUS "ADDING UNIT TEST ${assigned_id} ${test_name}") @@ -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}) diff --git a/tests/TestRunner/TestRunner.py b/tests/TestRunner/TestRunner.py index d8e1d361a3..38c16243b0 100755 --- a/tests/TestRunner/TestRunner.py +++ b/tests/TestRunner/TestRunner.py @@ -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,28 +314,29 @@ 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) - for trace in traces: - os.remove(trace) + #for trace in traces: + # os.remove(trace) if options.keep_simdirs == 'NONE' or options.keep_simdirs == 'FAILED' and res: print("Delete {}".format(os.path.join(wd, 'simfdb'))) shutil.rmtree(os.path.join(wd, 'simfdb')) From 35be45d4ce758fa1d2294052502e3cf0b36a4b82 Mon Sep 17 00:00:00 2001 From: dyoungworth Date: Thu, 11 Jul 2019 10:01:26 -0700 Subject: [PATCH 2/3] Remove code accidentally left for testing ctest fix --- tests/TestRunner/TestRunner.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/TestRunner/TestRunner.py b/tests/TestRunner/TestRunner.py index 38c16243b0..1be65c25d8 100755 --- a/tests/TestRunner/TestRunner.py +++ b/tests/TestRunner/TestRunner.py @@ -335,8 +335,8 @@ def run_simulation_test(basedir, options): 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) - #for trace in traces: - # os.remove(trace) + for trace in traces: + os.remove(trace) if options.keep_simdirs == 'NONE' or options.keep_simdirs == 'FAILED' and res: print("Delete {}".format(os.path.join(wd, 'simfdb'))) shutil.rmtree(os.path.join(wd, 'simfdb')) From baf8e020d1b0be06dab4e95ad3bc53778fbf5a58 Mon Sep 17 00:00:00 2001 From: dyoungworth Date: Mon, 15 Jul 2019 14:52:24 -0700 Subject: [PATCH 3/3] use one index to track tests in ctest --- cmake/AddFdbTest.cmake | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/cmake/AddFdbTest.cmake b/cmake/AddFdbTest.cmake index ce2edcaacf..4bd4656805 100644 --- a/cmake/AddFdbTest.cmake +++ b/cmake/AddFdbTest.cmake @@ -84,16 +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( 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 test_file_idx "${CURRENT_TEST_FILE_INDEX} + ${NUM_TEST_FILES}") - set(CURRENT_TEST_FILE_INDEX "${test_file_idx}" PARENT_SCOPE) - math(EXPR assigned_test_number "${test_file_idx} - ${NUM_TEST_FILES}") + math(EXPR assigned_id "${test_idx} - ${NUM_TEST_FILES}") if(ADD_FDB_TEST_UNIT) message(STATUS "ADDING UNIT TEST ${assigned_id} ${test_name}") @@ -121,7 +118,7 @@ function(add_fdb_test) --keep-logs ${TEST_KEEP_LOGS} --keep-simdirs ${TEST_KEEP_SIMDIR} --seed ${SEED} - --test-number ${assigned_test_number} + --test-number ${assigned_id} ${BUGGIFY_OPTION} ${ADD_FDB_TEST_TEST_FILES} WORKING_DIRECTORY ${PROJECT_BINARY_DIR})