Skip to content

Commit 1b068c5

Browse files
tests: Add --valgrind option to test/fuzz/test_runner.py for running fuzzing test cases under valgrind
1 parent 2a2631f commit 1b068c5

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)