diff options
author | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-06-22 11:49:28 +0200 |
---|---|---|
committer | MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> | 2023-06-22 13:54:17 +0200 |
commit | fae7c50d201726f605938c3511dd9119efeea5ec (patch) | |
tree | ced2a7116399f7777d67288e6b826065ea9d0df1 /test/fuzz | |
parent | 0c84a0e4841f00d931aa7339e9aa8f26eb2f3a61 (diff) | |
download | bitcoin-fae7c50d201726f605938c3511dd9119efeea5ec.tar.xz |
test: Run fuzz tests on macOS
Also, fix a few bugs:
* Error: RPC command "enumeratesigners" not found in RPC_COMMANDS_SAFE_FOR_FUZZING or RPC_COMMANDS_NOT_SAFE_FOR_FUZZING. Please update test/fuzz/rpc.cpp.
* in run_once: ...format(" ".join(result.args), ... TypeError: sequence item 2: expected str instance, PosixPath found
Diffstat (limited to 'test/fuzz')
-rwxr-xr-x | test/fuzz/test_runner.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py index d953f48584..84028f3dc5 100755 --- a/test/fuzz/test_runner.py +++ b/test/fuzz/test_runner.py @@ -95,8 +95,8 @@ def main(): configfile = os.path.abspath(os.path.dirname(__file__)) + "/../config.ini" config.read_file(open(configfile, encoding="utf8")) - if not config["components"].getboolean("ENABLE_FUZZ"): - logging.error("Must have fuzz targets built") + if not config["components"].getboolean("ENABLE_FUZZ_BINARY"): + logging.error("Must have fuzz executable built") sys.exit(1) # Build list of tests @@ -148,11 +148,12 @@ def main(): ], env=get_fuzz_env(target=test_list_selection[0], source_dir=config['environment']['SRCDIR']), timeout=20, - check=True, + check=False, stderr=subprocess.PIPE, text=True, ).stderr - if "libFuzzer" not in help_output: + using_libfuzzer = "libFuzzer" in help_output + if (args.generate or args.m_dir) and not using_libfuzzer: logging.error("Must be built with libFuzzer") sys.exit(1) except subprocess.TimeoutExpired: @@ -186,6 +187,7 @@ def main(): test_list=test_list_selection, src_dir=config['environment']['SRCDIR'], build_dir=config["environment"]["BUILDDIR"], + using_libfuzzer=using_libfuzzer, use_valgrind=args.valgrind, empty_min_time=args.empty_min_time, ) @@ -259,7 +261,7 @@ def merge_inputs(*, fuzz_pool, corpus, test_list, src_dir, build_dir, merge_dir) future.result() -def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind, empty_min_time): +def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, using_libfuzzer, use_valgrind, empty_min_time): jobs = [] for t in test_list: corpus_path = corpus / t @@ -268,13 +270,16 @@ def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind, os.path.join(build_dir, 'src', 'test', 'fuzz', 'fuzz'), ] empty_dir = not any(corpus_path.iterdir()) - if empty_min_time and empty_dir: - args += [f"-max_total_time={empty_min_time}"] + if using_libfuzzer: + if empty_min_time and empty_dir: + args += [f"-max_total_time={empty_min_time}"] + else: + args += [ + "-runs=1", + corpus_path, + ] else: - args += [ - "-runs=1", - corpus_path, - ] + args += [corpus_path] if use_valgrind: args = ['valgrind', '--quiet', '--error-exitcode=1'] + args @@ -301,7 +306,7 @@ def run_once(*, fuzz_pool, corpus, test_list, src_dir, build_dir, use_valgrind, logging.info(e.stdout) if e.stderr: logging.info(e.stderr) - logging.info("Target \"{}\" failed with exit code {}".format(" ".join(result.args), e.returncode)) + logging.info(f"Target {result.args} failed with exit code {e.returncode}") sys.exit(1) |