Skip to content

Commit 94c0287

Browse files
author
MarcoFalke
committed
Merge #18159: tests: Add --valgrind option to test/fuzz/test_runner.py for running fuzzing test cases under valgrind
1b068c5 tests: Add --valgrind option to test/fuzz/test_runner.py for running fuzzing test cases under valgrind (practicalswift) Pull request description: Add `--valgrind` option to `test/fuzz/test_runner.py` for running fuzzing test cases under `valgrind`. Test this PR using: ``` $ make distclean $ ./autogen.sh $ CC=clang CXX=clang++ ./configure --enable-fuzz --with-sanitizers=fuzzer $ make $ git clone https://github.com/bitcoin-core/qa-assets $ test/fuzz/test_runner.py --valgrind -l DEBUG qa-assets/fuzz_seed_corpus/ ``` ACKs for top commit: MarcoFalke: ACK 1b068c5 🌒 Tree-SHA512: e6eb99af1bceaa6f36f49092a05de415848099ccc1497cc098a62e925954c978cb37a46410b44ed5eef2c6464ca4ecb06397b75b5d35701f5a8525436e47b9fd
2 parents 33861a8 + 1b068c5 commit 94c0287

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

test/fuzz/test_runner.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ def main():
6161
action='store_true',
6262
help='If true, export coverage information to files in the seed corpus',
6363
)
64+
parser.add_argument(
65+
'--valgrind',
66+
action='store_true',
67+
help='If true, run fuzzing binaries under the valgrind memory error detector. Valgrind 3.14 or later required.',
68+
)
6469
parser.add_argument(
6570
'seed_dir',
6671
help='The seed corpus to run on (must contain subfolders for each fuzz target).',
@@ -129,10 +134,11 @@ def main():
129134
test_list=test_list_selection,
130135
build_dir=config["environment"]["BUILDDIR"],
131136
export_coverage=args.export_coverage,
137+
use_valgrind=args.valgrind,
132138
)
133139

134140

135-
def run_once(*, corpus, test_list, build_dir, export_coverage):
141+
def run_once(*, corpus, test_list, build_dir, export_coverage, use_valgrind):
136142
for t in test_list:
137143
corpus_path = os.path.join(corpus, t)
138144
if t in FUZZERS_MISSING_CORPORA:
@@ -143,6 +149,8 @@ def run_once(*, corpus, test_list, build_dir, export_coverage):
143149
'-detect_leaks=0',
144150
corpus_path,
145151
]
152+
if use_valgrind:
153+
args = ['valgrind', '--quiet', '--error-exitcode=1', '--exit-on-first-error=yes'] + args
146154
logging.debug('Run {} with args {}'.format(t, args))
147155
result = subprocess.run(args, stderr=subprocess.PIPE, universal_newlines=True)
148156
output = result.stderr

0 commit comments

Comments
 (0)