Skip to content

Commit a596bdf

Browse files
committed
Merge bitcoin/bitcoin#27919: ci: Run fuzz target even if input folder is empty
0000f55 ci: Run fuzz target even if input folder is empty (MarcoFalke) Pull request description: This should catch trivial integer sanitizer bugs if the author and all reviewers forget to look for them. ACKs for top commit: brunoerg: reACK 0000f55 dergoegge: reACK 0000f55 Tree-SHA512: f139b9d56f0cf1aae339c2890721c77c88d1fea77b73d492c1386ec99b4f393c5b664029919ff4a22e4e8a2929f085699a148c6acc2cc3e40df8a72fd39ff474
2 parents 8d5b93c + 0000f55 commit a596bdf

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

ci/test/06_script_b.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ if [ "${RUN_TIDY}" = "true" ]; then
170170
fi
171171

172172
if [ "$RUN_FUZZ_TESTS" = "true" ]; then
173-
bash -c "LD_LIBRARY_PATH=${DEPENDS_DIR}/${HOST}/lib test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} $MAKEJOBS -l DEBUG ${DIR_FUZZ_IN}"
173+
bash -c "LD_LIBRARY_PATH=${DEPENDS_DIR}/${HOST}/lib test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} $MAKEJOBS -l DEBUG ${DIR_FUZZ_IN} --empty_min_time=60"
174174
fi

test/fuzz/test_runner.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"""
77

88
from concurrent.futures import ThreadPoolExecutor, as_completed
9+
from pathlib import Path
910
import argparse
1011
import configparser
1112
import logging
@@ -41,6 +42,11 @@ def main():
4142
action='store_true',
4243
help='If true, run fuzzing binaries under the valgrind memory error detector',
4344
)
45+
parser.add_argument(
46+
"--empty_min_time",
47+
type=int,
48+
help="If set, run at least this long, if the existing fuzz inputs directory is empty.",
49+
)
4450
parser.add_argument(
4551
'-x',
4652
'--exclude',
@@ -76,6 +82,7 @@ def main():
7682
)
7783

7884
args = parser.parse_args()
85+
args.corpus_dir = Path(args.corpus_dir)
7986

8087
# Set up logging
8188
logging.basicConfig(
@@ -180,6 +187,7 @@ def main():
180187
src_dir=config['environment']['SRCDIR'],
181188
build_dir=config["environment"]["BUILDDIR"],
182189
use_valgrind=args.valgrind,
190+
empty_min_time=args.empty_min_time,
183191
)
184192

185193

@@ -251,16 +259,22 @@ def job(t, args):
251259
future.result()
252260

253261

254-
def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind):
262+
def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind, empty_min_time):
255263
jobs = []
256264
for t in test_list:
257-
corpus_path = os.path.join(corpus, t)
265+
corpus_path = corpus / t
258266
os.makedirs(corpus_path, exist_ok=True)
259267
args = [
260268
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
261-
'-runs=1',
262-
corpus_path,
263269
]
270+
empty_dir = not any(corpus_path.iterdir())
271+
if empty_min_time and empty_dir:
272+
args += [f"-max_total_time={empty_min_time}"]
273+
else:
274+
args += [
275+
"-runs=1",
276+
corpus_path,
277+
]
264278
if use_valgrind:
265279
args = ['valgrind', '--quiet', '--error-exitcode=1'] + args
266280

0 commit comments

Comments
 (0)