Run tests under valgrind when USE_VALGRIND

This commit is contained in:
Andrew Noyes 2019-07-02 09:15:05 -07:00
parent 0d473397c6
commit ac1a135d12
2 changed files with 12 additions and 0 deletions

View File

@ -106,6 +106,10 @@ function(add_fdb_test)
if (ENABLE_BUGGIFY)
set(BUGGIFY_OPTION "-B")
endif()
set(VALGRIND_OPTION "")
if (USE_VALGRIND)
set(VALGRIND_OPTION "--use-valgrind")
endif()
list(TRANSFORM ADD_FDB_TEST_TEST_FILES PREPEND "${CMAKE_CURRENT_SOURCE_DIR}/")
add_test(NAME ${test_name}
COMMAND $<TARGET_FILE:Python::Interpreter> ${TestRunner}
@ -120,6 +124,7 @@ function(add_fdb_test)
--seed ${SEED}
--test-number ${assigned_id}
${BUGGIFY_OPTION}
${VALGRIND_OPTION}
${ADD_FDB_TEST_TEST_FILES}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR})
get_filename_component(test_dir_full ${first_file} DIRECTORY)

View File

@ -295,14 +295,19 @@ def run_simulation_test(basedir, options):
first = True
for testfile in options.testfile:
tmp = list(pargs)
# old_binary is not under test, so don't run under valgrind
valgrind_args = []
if first and options.old_binary is not None and len(options.testfile) > 1:
_logger.info("Run old binary at {}".format(options.old_binary))
tmp[0] = options.old_binary
elif options.use_valgrind:
valgrind_args = ['valgrind', '--error-exitcode=99', '--']
if not first:
tmp.append('-R')
first = False
tmp.append('-f')
tmp.append(testfile)
tmp = valgrind_args + tmp
command = ' '.join(tmp)
_logger.info("COMMAND: {}".format(command))
proc = subprocess.Popen(tmp,
@ -377,6 +382,8 @@ if __name__ == '__main__':
parser.add_argument('--keep-simdirs', default='NONE',
choices=['NONE', 'FAILED', 'ALL'])
parser.add_argument('testfile', nargs="+", help='The tests to run')
parser.add_argument('--use-valgrind', action='store_true', default=False,
help='Run under valgrind')
args = parser.parse_args()
init_logging(args.loglevel, args.logdir)
basedir = os.getcwd()