aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfanquake <fanquake@gmail.com>2023-06-29 13:05:42 +0100
committerfanquake <fanquake@gmail.com>2023-06-29 13:08:58 +0100
commit3d51f7c9a8b0dc247370922cc52a5d9f93948dfe (patch)
tree8486a3d15cab3f68c0f19828836a61adf44fab20
parentd4018f0b6cbff43a1b8d2d57c5df2286f4d6e9d5 (diff)
parentfae7c50d201726f605938c3511dd9119efeea5ec (diff)
downloadbitcoin-3d51f7c9a8b0dc247370922cc52a5d9f93948dfe.tar.xz
Merge bitcoin/bitcoin#27932: test: Fuzz on macOS
fae7c50d201726f605938c3511dd9119efeea5ec test: Run fuzz tests on macOS (MarcoFalke) Pull request description: Any reason not to? ACKs for top commit: jamesob: Github ACK https://github.com/bitcoin/bitcoin/pull/27932/commits/fae7c50d201726f605938c3511dd9119efeea5ec dergoegge: utACK fae7c50d201726f605938c3511dd9119efeea5ec Tree-SHA512: e45122d73fafb17cea312258314b826cb0745e08daadd28465f687ec02d4c127d2f8cbe20179a9fff5712038850c02c968abb4838fa088b7555e28709317d3a3
-rwxr-xr-xci/test/00_setup_env_mac_native_arm64.sh2
-rw-r--r--src/test/fuzz/rpc.cpp1
-rw-r--r--test/config.ini.in2
-rwxr-xr-xtest/fuzz/test_runner.py29
4 files changed, 21 insertions, 13 deletions
diff --git a/ci/test/00_setup_env_mac_native_arm64.sh b/ci/test/00_setup_env_mac_native_arm64.sh
index a6799d7b88..09c05f3bbd 100755
--- a/ci/test/00_setup_env_mac_native_arm64.sh
+++ b/ci/test/00_setup_env_mac_native_arm64.sh
@@ -14,3 +14,5 @@ export CI_OS_NAME="macos"
export NO_DEPENDS=1
export OSX_SDK=""
export CCACHE_SIZE=300M
+export RUN_FUZZ_TESTS=true
+export FUZZ_TESTS_CONFIG="--exclude banman" # https://github.com/bitcoin/bitcoin/issues/27924
diff --git a/src/test/fuzz/rpc.cpp b/src/test/fuzz/rpc.cpp
index b1858a1800..45a2294081 100644
--- a/src/test/fuzz/rpc.cpp
+++ b/src/test/fuzz/rpc.cpp
@@ -73,6 +73,7 @@ const std::vector<std::string> RPC_COMMANDS_NOT_SAFE_FOR_FUZZING{
"addpeeraddress", // avoid DNS lookups
"dumptxoutset", // avoid writing to disk
"dumpwallet", // avoid writing to disk
+ "enumeratesigners",
"echoipc", // avoid assertion failure (Assertion `"EnsureAnyNodeContext(request.context).init" && check' failed.)
"generatetoaddress", // avoid prohibitively slow execution (when `num_blocks` is large)
"generatetodescriptor", // avoid prohibitively slow execution (when `nblocks` is large)
diff --git a/test/config.ini.in b/test/config.ini.in
index af3d994c84..291599da45 100644
--- a/test/config.ini.in
+++ b/test/config.ini.in
@@ -22,7 +22,7 @@ RPCAUTH=@abs_top_srcdir@/share/rpcauth/rpcauth.py
@BUILD_BITCOIN_UTIL_TRUE@ENABLE_BITCOIN_UTIL=true
@BUILD_BITCOIN_WALLET_TRUE@ENABLE_WALLET_TOOL=true
@BUILD_BITCOIND_TRUE@ENABLE_BITCOIND=true
-@ENABLE_FUZZ_TRUE@ENABLE_FUZZ=true
+@ENABLE_FUZZ_BINARY_TRUE@ENABLE_FUZZ_BINARY=true
@ENABLE_ZMQ_TRUE@ENABLE_ZMQ=true
@ENABLE_EXTERNAL_SIGNER_TRUE@ENABLE_EXTERNAL_SIGNER=true
@ENABLE_USDT_TRACEPOINTS_TRUE@ENABLE_USDT_TRACEPOINTS=true
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)