diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py index 9271ba72ce..f184bcf19e 100755 --- a/test/fuzz/test_runner.py +++ b/test/fuzz/test_runner.py @@ -50,6 +50,11 @@ def main(): action='store_true', help='If true, export coverage information to files in the seed corpus', ) + parser.add_argument( + '--valgrind', + action='store_true', + help='If true, run fuzzing binaries under the valgrind memory error detector. Valgrind 3.14 or later required.', + ) parser.add_argument( 'seed_dir', help='The seed corpus to run on (must contain subfolders for each fuzz target).', @@ -118,10 +123,11 @@ def main(): test_list=test_list_selection, build_dir=config["environment"]["BUILDDIR"], export_coverage=args.export_coverage, + use_valgrind=args.valgrind, ) -def run_once(*, corpus, test_list, build_dir, export_coverage): +def run_once(*, corpus, test_list, build_dir, export_coverage, use_valgrind): for t in test_list: corpus_path = os.path.join(corpus, t) if t in FUZZERS_MISSING_CORPORA: @@ -132,6 +138,8 @@ def run_once(*, corpus, test_list, build_dir, export_coverage): '-detect_leaks=0', corpus_path, ] + if use_valgrind: + args = ['valgrind', '--quiet', '--error-exitcode=1', '--exit-on-first-error=yes'] + args logging.debug('Run {} with args {}'.format(t, args)) result = subprocess.run(args, stderr=subprocess.PIPE, universal_newlines=True) output = result.stderr