mirror of
https://github.com/bitcoin/bitcoin.git
synced 2024-11-20 02:25:40 +01:00
Merge bitcoin/bitcoin#29821: fuzz: Some test/fuzz/test_runner.py
improvements
47cedee776
fuzz: Introduce `BITCOINFUZZ` environment variable (Hennadii Stepanov)1573e9a11e
fuzz, refactor: Deduplicate fuzz binary path creation (Hennadii Stepanov) Pull request description: These changes are split from https://github.com/bitcoin/bitcoin/pull/29774 and can be beneficial on their own. The new `BITCOINFUZZ` environment variable complements the already existing set of variables used by tests:b5d21182e5/test/functional/test_framework/test_framework.py (L238-L243)
ACKs for top commit: maflcko: lgtm ACK47cedee776
davidgumberg: utACK47cedee776
Tree-SHA512: 45809cfd13dc4a45c44cc433184352e84726cb95bea80fd8f581c59a0b8b0a5495260ff66922f9c57c38adbdbdd102439238f370fd49d6ea27a241a5e6249895
This commit is contained in:
commit
f348ec7c2a
@ -104,9 +104,11 @@ def main():
|
||||
logging.error("Must have fuzz executable built")
|
||||
sys.exit(1)
|
||||
|
||||
fuzz_bin=os.getenv("BITCOINFUZZ", default=os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'))
|
||||
|
||||
# Build list of tests
|
||||
test_list_all = parse_test_list(
|
||||
fuzz_bin=os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'),
|
||||
fuzz_bin=fuzz_bin,
|
||||
source_dir=config['environment']['SRCDIR'],
|
||||
)
|
||||
|
||||
@ -151,7 +153,7 @@ def main():
|
||||
try:
|
||||
help_output = subprocess.run(
|
||||
args=[
|
||||
os.path.join(config["environment"]["BUILDDIR"], 'src', 'test', 'fuzz', 'fuzz'),
|
||||
fuzz_bin,
|
||||
'-help=1',
|
||||
],
|
||||
env=get_fuzz_env(target=test_list_selection[0], source_dir=config['environment']['SRCDIR']),
|
||||
@ -173,7 +175,7 @@ def main():
|
||||
return generate_corpus(
|
||||
fuzz_pool=fuzz_pool,
|
||||
src_dir=config['environment']['SRCDIR'],
|
||||
build_dir=config["environment"]["BUILDDIR"],
|
||||
fuzz_bin=fuzz_bin,
|
||||
corpus_dir=args.corpus_dir,
|
||||
targets=test_list_selection,
|
||||
)
|
||||
@ -184,7 +186,7 @@ def main():
|
||||
corpus=args.corpus_dir,
|
||||
test_list=test_list_selection,
|
||||
src_dir=config['environment']['SRCDIR'],
|
||||
build_dir=config["environment"]["BUILDDIR"],
|
||||
fuzz_bin=fuzz_bin,
|
||||
merge_dirs=[Path(m_dir) for m_dir in args.m_dir],
|
||||
)
|
||||
return
|
||||
@ -194,7 +196,7 @@ def main():
|
||||
corpus=args.corpus_dir,
|
||||
test_list=test_list_selection,
|
||||
src_dir=config['environment']['SRCDIR'],
|
||||
build_dir=config["environment"]["BUILDDIR"],
|
||||
fuzz_bin=fuzz_bin,
|
||||
using_libfuzzer=using_libfuzzer,
|
||||
use_valgrind=args.valgrind,
|
||||
empty_min_time=args.empty_min_time,
|
||||
@ -237,7 +239,7 @@ def transform_rpc_target(targets, src_dir):
|
||||
return targets
|
||||
|
||||
|
||||
def generate_corpus(*, fuzz_pool, src_dir, build_dir, corpus_dir, targets):
|
||||
def generate_corpus(*, fuzz_pool, src_dir, fuzz_bin, corpus_dir, targets):
|
||||
"""Generates new corpus.
|
||||
|
||||
Run {targets} without input, and outputs the generated corpus to
|
||||
@ -270,7 +272,7 @@ def generate_corpus(*, fuzz_pool, src_dir, build_dir, corpus_dir, targets):
|
||||
os.makedirs(target_corpus_dir, exist_ok=True)
|
||||
use_value_profile = int(random.random() < .3)
|
||||
command = [
|
||||
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
|
||||
fuzz_bin,
|
||||
"-rss_limit_mb=8000",
|
||||
"-max_total_time=6000",
|
||||
"-reload=0",
|
||||
@ -283,12 +285,12 @@ def generate_corpus(*, fuzz_pool, src_dir, build_dir, corpus_dir, targets):
|
||||
future.result()
|
||||
|
||||
|
||||
def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dirs):
|
||||
def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, fuzz_bin, merge_dirs):
|
||||
logging.info(f"Merge the inputs from the passed dir into the corpus_dir. Passed dirs {merge_dirs}")
|
||||
jobs = []
|
||||
for t in test_list:
|
||||
args = [
|
||||
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
|
||||
fuzz_bin,
|
||||
'-rss_limit_mb=8000',
|
||||
'-set_cover_merge=1',
|
||||
# set_cover_merge is used instead of -merge=1 to reduce the overall
|
||||
@ -325,13 +327,13 @@ def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dirs
|
||||
future.result()
|
||||
|
||||
|
||||
def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, using_libfuzzer, use_valgrind, empty_min_time):
|
||||
def run_once(*, fuzz_pool, corpus, test_list, src_dir, fuzz_bin, using_libfuzzer, use_valgrind, empty_min_time):
|
||||
jobs = []
|
||||
for t in test_list:
|
||||
corpus_path = corpus / t
|
||||
os.makedirs(corpus_path, exist_ok=True)
|
||||
args = [
|
||||
os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'),
|
||||
fuzz_bin,
|
||||
]
|
||||
empty_dir = not any(corpus_path.iterdir())
|
||||
if using_libfuzzer:
|
||||
|
Loading…
Reference in New Issue
Block a user