diff --git a/contrib/seeds/test-seeds.sh b/contrib/seeds/test-seeds.sh index 29eaae0242..bc89ff2759 100755 --- a/contrib/seeds/test-seeds.sh +++ b/contrib/seeds/test-seeds.sh @@ -1,130 +1,133 @@ #!/usr/bin/env bash # Copyright (c) 2019 The Bitcoin 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 set -u TOPLEVEL=$(git rev-parse --show-toplevel) DEFAULT_BUILD_DIR="${TOPLEVEL}/build" +DEFAULT_RPC_PORT=18832 help_message() { echo "Test connecting to seed nodes. Outputs the seeds that were successfully connected to." echo "" echo "Example usages:" echo "Mainnet: $0 < nodes_main.txt" echo "Testnet: $0 --testnet < nodes_test.txt" echo "" echo "Options:" echo "-t, --testnet Connect to testnet seeds (mainnet is default)." echo "-h, --help Display this help message." echo "" echo "Environment Variables:" echo "BUILD_DIR Default: ${DEFAULT_BUILD_DIR}" + echo "RPC_PORT Default: ${DEFAULT_RPC_PORT}" exit 0 } : "${BUILD_DIR:=${DEFAULT_BUILD_DIR}}" OPTION_TESTNET="" # Parse command line arguments while [[ $# -gt 0 ]]; do case $1 in -t|--testnet) OPTION_TESTNET="--testnet" shift # shift past argument ;; -h|--help) help_message shift # shift past argument ;; *) echo "Unknown argument: $1" help_message shift # shift past argument ;; esac done BITCOIND="${BUILD_DIR}/src/bitcoind" BITCOIN_CLI="${BUILD_DIR}/src/bitcoin-cli" if [ ! -x "${BITCOIND}" ]; then echo "${BITCOIND} does not exist or has incorrect permissions." exit 10 fi if [ ! -x "${BITCOIN_CLI}" ]; then echo "${BITCOIN_CLI} does not exist or has incorrect permissions." exit 11 fi TEMP_DATADIR=$(mktemp -d) -BITCOIND="${BITCOIND} -datadir=${TEMP_DATADIR} ${OPTION_TESTNET} -rpcport=18832 -connect=0 -daemon" -BITCOIN_CLI="${BITCOIN_CLI} -datadir=${TEMP_DATADIR} ${OPTION_TESTNET} -rpcport=18832" +: "${RPC_PORT:=${DEFAULT_RPC_PORT}}" +BITCOIND="${BITCOIND} -datadir=${TEMP_DATADIR} ${OPTION_TESTNET} -rpcport=${RPC_PORT} -connect=0 -daemon" +BITCOIN_CLI="${BITCOIN_CLI} -datadir=${TEMP_DATADIR} ${OPTION_TESTNET} -rpcport=${RPC_PORT}" >&2 echo "Spinning up bitcoind..." ${BITCOIND} || { echo "Error starting bitcoind. Stopping script." exit 12 } cleanup() { # Cleanup background processes spawned by this script. >&2 echo "Cleaning up bitcoin daemon..." ${BITCOIN_CLI} stop rm -rf "${TEMP_DATADIR}" } trap "cleanup" EXIT # Short sleep to make sure the RPC server is available sleep 0.1 # Wait until bitcoind is fully spun up WARMUP_TIMEOUT=60 for _ in $(seq 1 ${WARMUP_TIMEOUT}); do ${BITCOIN_CLI} getconnectioncount &> /dev/null RPC_READY=$? if [ "${RPC_READY}" -ne 0 ]; then >&2 printf "." sleep 1 else break fi done >&2 echo "" if [ "${RPC_READY}" -ne 0 ]; then >&2 echo "RPC was not ready after ${WARMUP_TIMEOUT} seconds." exit 20 fi while read -r SEED; do >&2 echo "Testing seed '${SEED}'..." # Immediately connect to the seed peer ${BITCOIN_CLI} addnode "${SEED}" onetry # Fetch peer's connection status CONNECTION_COUNT=$(${BITCOIN_CLI} getconnectioncount) if [ "${CONNECTION_COUNT}" -eq 1 ]; then # Cleanup peer connection ${BITCOIN_CLI} disconnectnode "${SEED}" # Wait for peer to be disconnected CONNECTED_TIMEOUT=5 for _ in $(seq 1 ${CONNECTED_TIMEOUT}); do CONNECTION_COUNT=$(${BITCOIN_CLI} getconnectioncount) if [ "${CONNECTION_COUNT}" -eq 0 ]; then break fi sleep 0.1 done if [ "${CONNECTION_COUNT}" -ne 0 ]; then >&2 echo "Seed failed to disconnect. Something else could be wrong (check logs)." exit 30 fi echo "${SEED}" else >&2 echo "Failed to connect to '${SEED}'" fi done diff --git a/contrib/teamcity/build-configurations.sh b/contrib/teamcity/build-configurations.sh index 306afbc3a7..44c922fb27 100755 --- a/contrib/teamcity/build-configurations.sh +++ b/contrib/teamcity/build-configurations.sh @@ -1,265 +1,267 @@ #!/usr/bin/env bash export LC_ALL=C.UTF-8 set -euxo pipefail : "${ABC_BUILD_NAME:=""}" if [ -z "$ABC_BUILD_NAME" ]; then echo "Error: Environment variable ABC_BUILD_NAME must be set" exit 1 fi echo "Running build configuration '${ABC_BUILD_NAME}'..." TOPLEVEL=$(git rev-parse --show-toplevel) export TOPLEVEL setup() { : "${BUILD_DIR:=${TOPLEVEL}/build}" mkdir -p "${BUILD_DIR}" BUILD_DIR=$(cd "${BUILD_DIR}"; pwd) export BUILD_DIR cd "${BUILD_DIR}" # Determine the number of build threads THREADS=$(nproc || sysctl -n hw.ncpu) export THREADS # Base directories for sanitizer related files SAN_SUPP_DIR="${TOPLEVEL}/test/sanitizer_suppressions" SAN_LOG_DIR="/tmp/sanitizer_logs" # Create the log directory if it doesn't exist and clear it mkdir -p "${SAN_LOG_DIR}" rm -rf "${SAN_LOG_DIR:?}"/* # Sanitizers options, not used if sanitizers are not enabled export ASAN_OPTIONS="malloc_context_size=0:log_path=${SAN_LOG_DIR}/asan.log" export LSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/lsan:log_path=${SAN_LOG_DIR}/lsan.log" export TSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/tsan:log_path=${SAN_LOG_DIR}/tsan.log" export UBSAN_OPTIONS="suppressions=${SAN_SUPP_DIR}/ubsan:print_stacktrace=1:halt_on_error=1:log_path=${SAN_LOG_DIR}/ubsan.log" # Unit test logger parameters UNIT_TESTS_JUNIT_LOG_LEVEL=message } run_test_bitcoin() { # Usage: run_test_bitcoin "Context as string" [arguments...] ninja test_bitcoin TEST_BITCOIN_JUNIT="junit_results_unit_tests${1:+_${1// /_}}.xml" TEST_BITCOIN_SUITE_NAME="Bitcoin ABC unit tests${1:+ $1}" ./src/test/test_bitcoin \ --logger=HRF:JUNIT,${UNIT_TESTS_JUNIT_LOG_LEVEL},${TEST_BITCOIN_JUNIT} \ -- \ -testsuitename="${TEST_BITCOIN_SUITE_NAME}" \ "${@:2}" } # Facility to print out sanitizer log outputs to the build log console print_sanitizers_log() { for log in "${SAN_LOG_DIR}"/*.log.* do echo "*** Output of ${log} ***" cat "${log}" done } trap "print_sanitizers_log" ERR CI_SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" setup case "$ABC_BUILD_NAME" in build-asan) # Build with the address sanitizer, then run unit tests and functional tests. CMAKE_FLAGS=( "-DCMAKE_CXX_FLAGS=-DARENA_DEBUG" "-DCMAKE_BUILD_TYPE=Debug" # ASAN does not support assembly code: https://github.com/google/sanitizers/issues/192 # This will trigger a segfault if the SSE4 implementation is selected for SHA256. # Disabling the assembly works around the issue. "-DCRYPTO_USE_ASM=OFF" "-DENABLE_SANITIZERS=address" "-DCCACHE=OFF" "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh run_test_bitcoin "with address sanitizer" # Libs and utils tests ninja \ check-bitcoin-qt \ check-bitcoin-seeder \ check-bitcoin-util \ ninja check-functional ;; build-ubsan) # Build with the undefined sanitizer, then run unit tests and functional tests. CMAKE_FLAGS=( "-DCMAKE_BUILD_TYPE=Debug" "-DENABLE_SANITIZERS=undefined" "-DCCACHE=OFF" "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh run_test_bitcoin "with undefined sanitizer" # Libs and utils tests ninja \ check-bitcoin-qt \ check-bitcoin-seeder \ check-bitcoin-util \ ninja check-functional ;; build-tsan) # Build with the thread sanitizer, then run unit tests and functional tests. CMAKE_FLAGS=( "-DCMAKE_BUILD_TYPE=Debug" "-DENABLE_SANITIZERS=thread" "-DCCACHE=OFF" "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh run_test_bitcoin "with thread sanitizer" # Libs and utils tests ninja \ check-bitcoin-qt \ check-bitcoin-seeder \ check-bitcoin-util \ ninja check-functional ;; build-diff) # Build, run unit tests and functional tests. CMAKE_FLAGS=( "-DSECP256K1_ENABLE_MODULE_ECDH=ON" "-DSECP256K1_ENABLE_JNI=ON" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh # Unit tests run_test_bitcoin run_test_bitcoin "with next upgrade activated" -phononactivationtime=1575158400 # Libs and tools tests ninja \ check-bitcoin-qt \ check-bitcoin-seeder \ check-bitcoin-util \ check-devtools \ check-leveldb \ check-rpcauth \ check-secp256k1 \ check-univalue \ # Functional tests ninja check-functional ninja check-functional-upgrade-activated ;; build-master) # Build, run unit tests and extended functional tests. CMAKE_FLAGS=( "-DSECP256K1_ENABLE_MODULE_ECDH=ON" "-DSECP256K1_ENABLE_JNI=ON" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh # Unit tests run_test_bitcoin run_test_bitcoin "with next upgrade activated" -phononactivationtime=1575158400 # Libs and tools tests ninja \ check-bitcoin-qt \ check-bitcoin-seeder \ check-bitcoin-util \ check-devtools \ check-leveldb \ check-rpcauth \ check-secp256k1 \ check-univalue \ # Functional tests ninja check-functional-extended ninja check-functional-upgrade-activated-extended ;; build-without-wallet) # Build without wallet and run the unit tests. CMAKE_FLAGS=( "-DBUILD_BITCOIN_WALLET=OFF" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh ninja check-bitcoin-qt ninja check-functional run_test_bitcoin "without wallet" ;; build-ibd) "${CI_SCRIPTS_DIR}"/build_cmake.sh "${CI_SCRIPTS_DIR}"/ibd.sh -disablewallet -debug=net ;; build-ibd-no-assumevalid-checkpoint) "${CI_SCRIPTS_DIR}"/build_cmake.sh "${CI_SCRIPTS_DIR}"/ibd.sh -disablewallet -assumevalid=0 -checkpoints=0 -debug=net ;; build-werror) # Build with variable-length-array and thread-safety-analysis treated as errors CMAKE_FLAGS=( "-DENABLE_WERROR=ON" "-DCMAKE_C_COMPILER=clang" "-DCMAKE_CXX_COMPILER=clang++" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh ;; build-autotools) # Ensure that the build using autotools is not broken "${CI_SCRIPTS_DIR}"/build_autotools.sh make -j "${THREADS}" check ;; build-bench) # Build and run the benchmarks. CMAKE_FLAGS=( "-DBUILD_BITCOIN_WALLET=ON" "-DSECP256K1_ENABLE_MODULE_ECDH=ON" "-DSECP256K1_ENABLE_MODULE_MULTISET=ON" "-DSECP256K1_ENABLE_MODULE_RECOVERY=ON" ) CMAKE_FLAGS="${CMAKE_FLAGS[*]}" "${CI_SCRIPTS_DIR}"/build_cmake.sh ninja bench-bitcoin ninja bench-secp256k1 ;; check-seeds) "${CI_SCRIPTS_DIR}"/build_cmake.sh - "${CI_SCRIPTS_DIR}"/check-seeds.sh main 80 - "${CI_SCRIPTS_DIR}"/check-seeds.sh test 70 + # Run on different ports to avoid a race where the rpc port used in the + # first run may not be closed in time for the second to start. + RPC_PORT=18832 "${CI_SCRIPTS_DIR}"/check-seeds.sh main 80 + RPC_PORT=18833 "${CI_SCRIPTS_DIR}"/check-seeds.sh test 70 ;; *) echo "Error: Invalid build name '${ABC_BUILD_NAME}'" exit 2 ;; esac