diff options
-rw-r--r-- | .travis.yml | 5 | ||||
-rw-r--r-- | ci/test/00_setup_env_native_fuzz_with_valgrind.sh | 18 | ||||
-rwxr-xr-x | ci/test/06_script_b.sh | 2 | ||||
-rw-r--r-- | doc/build-osx.md | 1 | ||||
-rw-r--r-- | doc/developer-notes.md | 3 | ||||
-rw-r--r-- | src/rpc/misc.cpp | 4 | ||||
-rw-r--r-- | src/rpc/util.cpp | 1 | ||||
-rw-r--r-- | src/rpc/util.h | 6 | ||||
-rw-r--r-- | src/wallet/rpcwallet.cpp | 6 | ||||
-rwxr-xr-x | test/fuzz/test_runner.py | 33 |
10 files changed, 65 insertions, 14 deletions
diff --git a/.travis.yml b/.travis.yml index c5b8c476b7..9a111c03ad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -135,6 +135,11 @@ jobs: FILE_ENV="./ci/test/00_setup_env_native_fuzz.sh" - stage: test + name: 'x86_64 Linux [GOAL: install] [bionic] [no depends, only system libs, fuzzers under valgrind]' + env: >- + FILE_ENV="./ci/test/00_setup_env_native_fuzz_with_valgrind.sh" + + - stage: test name: 'x86_64 Linux [GOAL: install] [bionic] [no wallet]' env: >- FILE_ENV="./ci/test/00_setup_env_native_nowallet.sh" diff --git a/ci/test/00_setup_env_native_fuzz_with_valgrind.sh b/ci/test/00_setup_env_native_fuzz_with_valgrind.sh new file mode 100644 index 0000000000..6e1c400d50 --- /dev/null +++ b/ci/test/00_setup_env_native_fuzz_with_valgrind.sh @@ -0,0 +1,18 @@ +#!/usr/bin/env bash +# +# Copyright (c) 2019 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. + +export LC_ALL=C.UTF-8 + +export CONTAINER_NAME=ci_native_fuzz_valgrind +export PACKAGES="clang-8 llvm-8 python3 libevent-dev bsdmainutils libboost-system-dev libboost-filesystem-dev libboost-chrono-dev libboost-test-dev libboost-thread-dev valgrind" +export NO_DEPENDS=1 +export RUN_UNIT_TESTS=false +export RUN_FUNCTIONAL_TESTS=false +export RUN_FUZZ_TESTS=true +export FUZZ_TESTS_CONFIG="--exclude integer,parse_iso8601 --valgrind" +export GOAL="install" +export BITCOIN_CONFIG="--enable-fuzz --with-sanitizers=fuzzer CC=clang-8 CXX=clang++-8" +# Use clang-8, instead of default clang on bionic, which is clang-6 and does not come with libfuzzer on aarch64 diff --git a/ci/test/06_script_b.sh b/ci/test/06_script_b.sh index 537493a710..3b32513353 100755 --- a/ci/test/06_script_b.sh +++ b/ci/test/06_script_b.sh @@ -36,6 +36,6 @@ fi if [ "$RUN_FUZZ_TESTS" = "true" ]; then BEGIN_FOLD fuzz-tests - DOCKER_EXEC test/fuzz/test_runner.py -l DEBUG ${DIR_FUZZ_IN} + DOCKER_EXEC test/fuzz/test_runner.py ${FUZZ_TESTS_CONFIG} -l DEBUG ${DIR_FUZZ_IN} END_FOLD fi diff --git a/doc/build-osx.md b/doc/build-osx.md index 86b5c5b602..7b76117c8b 100644 --- a/doc/build-osx.md +++ b/doc/build-osx.md @@ -22,6 +22,7 @@ Then install [Homebrew](https://brew.sh). brew install automake berkeley-db4 libtool boost miniupnpc pkg-config python qt libevent qrencode ``` +If you run into issues, check [Homebrew's troubleshooting page](https://docs.brew.sh/Troubleshooting). See [dependencies.md](dependencies.md) for a complete overview. If you want to build the disk image with `make deploy` (.dmg / optional), you need RSVG: diff --git a/doc/developer-notes.md b/doc/developer-notes.md index a82ecee7d8..d106aab3e4 100644 --- a/doc/developer-notes.md +++ b/doc/developer-notes.md @@ -1089,7 +1089,8 @@ A few guidelines for introducing and reviewing new RPC interfaces: new RPC is replacing a deprecated RPC, to avoid both RPCs confusingly showing up in the command list. -- Use *invalid* bech32 addresses for `RPCExamples` help documentation. +- Use *invalid* bech32 addresses (e.g. the constant `EXAMPLE_ADDRESS`) for + `RPCExamples` help documentation. - *Rationale*: Prevent accidental transactions by users and encourage the use of bech32 addresses by default. diff --git a/src/rpc/misc.cpp b/src/rpc/misc.cpp index 2b4ee62c71..c8711f44d4 100644 --- a/src/rpc/misc.cpp +++ b/src/rpc/misc.cpp @@ -44,8 +44,8 @@ static UniValue validateaddress(const JSONRPCRequest& request) "}\n" }, RPCExamples{ - HelpExampleCli("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") - + HelpExampleRpc("validateaddress", "\"1PSSGeFHDnKNxiEyFrD1wcEaHr9hrQDDWc\"") + HelpExampleCli("validateaddress", EXAMPLE_ADDRESS) + + HelpExampleRpc("validateaddress", EXAMPLE_ADDRESS) }, }.Check(request); diff --git a/src/rpc/util.cpp b/src/rpc/util.cpp index 78586c22f9..7cefb2db96 100644 --- a/src/rpc/util.cpp +++ b/src/rpc/util.cpp @@ -14,6 +14,7 @@ #include <tuple> const std::string UNIX_EPOCH_TIME = "UNIX epoch time"; +const std::string EXAMPLE_ADDRESS = "\"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl\""; void RPCTypeCheck(const UniValue& params, const std::list<UniValueType>& typesExpected, diff --git a/src/rpc/util.h b/src/rpc/util.h index 065a992a88..f5edf69713 100644 --- a/src/rpc/util.h +++ b/src/rpc/util.h @@ -28,6 +28,12 @@ */ extern const std::string UNIX_EPOCH_TIME; +/** + * Example bech32 address used in multiple RPCExamples. The address is intentionally + * invalid to prevent accidental transactions by users. + */ +extern const std::string EXAMPLE_ADDRESS; + class FillableSigningProvider; class CPubKey; class CScript; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index bc4ec77e31..e8905e781c 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -3724,8 +3724,6 @@ UniValue getaddressinfo(const JSONRPCRequest& request) return NullUniValue; } - const std::string example_address = "\"bc1q09vm5lfy0j5reeulh4x5752q25uqqvz34hufdl\""; - RPCHelpMan{"getaddressinfo", "\nReturn information about the given bitcoin address.\n" "Some of the information will only be present if the address is in the active wallet.\n", @@ -3778,8 +3776,8 @@ UniValue getaddressinfo(const JSONRPCRequest& request) "}\n" }, RPCExamples{ - HelpExampleCli("getaddressinfo", example_address) + - HelpExampleRpc("getaddressinfo", example_address) + HelpExampleCli("getaddressinfo", EXAMPLE_ADDRESS) + + HelpExampleRpc("getaddressinfo", EXAMPLE_ADDRESS) }, }.Check(request); diff --git a/test/fuzz/test_runner.py b/test/fuzz/test_runner.py index 61c3e700c5..a56651cca5 100755 --- a/test/fuzz/test_runner.py +++ b/test/fuzz/test_runner.py @@ -47,6 +47,7 @@ FUZZERS_MISSING_CORPORA = [ "tx_out", ] + def main(): parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter) parser.add_argument( @@ -64,7 +65,12 @@ def main(): parser.add_argument( '--valgrind', action='store_true', - help='If true, run fuzzing binaries under the valgrind memory error detector. Valgrind 3.14 or later required.', + help='If true, run fuzzing binaries under the valgrind memory error detector', + ) + parser.add_argument( + '-x', + '--exclude', + help="A comma-separated list of targets to exclude", ) parser.add_argument( 'seed_dir', @@ -100,7 +106,7 @@ def main(): logging.error("No fuzz targets found") sys.exit(1) - logging.info("Fuzz targets found: {}".format(test_list_all)) + logging.debug("{} fuzz target(s) found: {}".format(len(test_list_all), " ".join(sorted(test_list_all)))) args.target = args.target or test_list_all # By default run all test_list_error = list(set(args.target).difference(set(test_list_all))) @@ -109,7 +115,15 @@ def main(): test_list_selection = list(set(test_list_all).intersection(set(args.target))) if not test_list_selection: logging.error("No fuzz targets selected") - logging.info("Fuzz targets selected: {}".format(test_list_selection)) + if args.exclude: + for excluded_target in args.exclude.split(","): + if excluded_target not in test_list_selection: + logging.error("Target \"{}\" not found in current target list.".format(excluded_target)) + continue + test_list_selection.remove(excluded_target) + test_list_selection.sort() + + logging.info("{} of {} detected fuzz target(s) selected: {}".format(len(test_list_selection), len(test_list_all), " ".join(test_list_selection))) try: help_output = subprocess.run( @@ -146,16 +160,23 @@ def run_once(*, corpus, test_list, build_dir, export_coverage, use_valgrind): args = [ os.path.join(build_dir, 'src', 'test', 'fuzz', t), '-runs=1', - '-detect_leaks=0', corpus_path, ] if use_valgrind: - args = ['valgrind', '--quiet', '--error-exitcode=1', '--exit-on-first-error=yes'] + args + args = ['valgrind', '--quiet', '--error-exitcode=1'] + args logging.debug('Run {} with args {}'.format(t, args)) result = subprocess.run(args, stderr=subprocess.PIPE, universal_newlines=True) output = result.stderr logging.debug('Output: {}'.format(output)) - result.check_returncode() + try: + result.check_returncode() + except subprocess.CalledProcessError as e: + if e.stdout: + logging.info(e.stdout) + if e.stderr: + logging.info(e.stderr) + logging.info("Target \"{}\" failed with exit code {}: {}".format(t, e.returncode, " ".join(args))) + sys.exit(1) if not export_coverage: continue for l in output.splitlines(): |