diff --git a/CMakeLists.txt b/CMakeLists.txt index 1eb4e1fd1..8f2030342 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,86 +1,87 @@ # Copyright (c) 2017 The Bitcoin developers cmake_minimum_required(VERSION 3.12) set(CMAKE_USER_MAKE_RULES_OVERRIDE "${CMAKE_SOURCE_DIR}/cmake/modules/OverrideInitFlags.cmake" ) project(bitcoin-abc VERSION 0.20.11 DESCRIPTION "Bitcoin ABC is a full node implementation of the Bitcoin Cash protocol." HOMEPAGE_URL "https://www.bitcoinabc.org" ) # Package information set(PACKAGE_NAME "Bitcoin ABC") # Copyright set(COPYRIGHT_YEAR 2019) set(COPYRIGHT_HOLDERS "The %s developers") set(COPYRIGHT_HOLDERS_SUBSTITUTION Bitcoin) string(REPLACE "%s" ${COPYRIGHT_HOLDERS_SUBSTITUTION} COPYRIGHT_HOLDERS_FINAL ${COPYRIGHT_HOLDERS}) # Add path for custom modules list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules) # Make contrib script accessible. set(CONTRIB_PATH ${CMAKE_CURRENT_SOURCE_DIR}/contrib) # If ccache is available, then use it. find_program(CCACHE ccache) if(CCACHE) message(STATUS "Using ccache: ${CCACHE}") set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE ${CCACHE}) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ${CCACHE}) endif(CCACHE) # Default to RelWithDebInfo configuration if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "Select the configuration for the build" FORCE) endif() # Find the python interpreter. This is required for several targets. find_package(PythonInterp 3.5 REQUIRED) # Add the magic targets `check-*` add_custom_target(check-all) add_custom_target(check) add_custom_target(check-extended) add_custom_target(check-upgrade-activated) +add_custom_target(check-upgrade-activated-extended) add_custom_target(check-symbols) add_custom_target(check-security) include(PackageHelper) exclude_git_ignored_files_from_source_package() # Ignore hidden files and directories (starting with a '.') set_property(GLOBAL APPEND PROPERTY SOURCE_PACKAGE_IGNORE_FILES "/\\\\.") # If the build is out-of-tree, then the build directory can be ignored. if(NOT CMAKE_BINARY_DIR STREQUAL CMAKE_SOURCE_DIR) set_property(GLOBAL APPEND PROPERTY SOURCE_PACKAGE_IGNORE_FILES "${CMAKE_BINARY_DIR}/" ) endif() exclude_from_source_package( # Subdirectories "arcanist/" "depends/" # Files "[^.]+[.]md$" "Dockerfile-doxygen" ) add_subdirectory(src) add_subdirectory(test) add_subdirectory(contrib) add_subdirectory(doc) include(PackageOptions) get_property(CPACK_SOURCE_IGNORE_FILES GLOBAL PROPERTY SOURCE_PACKAGE_IGNORE_FILES) include(CPack) diff --git a/cmake/modules/TestSuite.cmake b/cmake/modules/TestSuite.cmake index 3a18250ca..3e5aff6b2 100644 --- a/cmake/modules/TestSuite.cmake +++ b/cmake/modules/TestSuite.cmake @@ -1,103 +1,104 @@ # Allow to easily build test suites function(create_test_suite_with_parent_targets NAME) set(TARGET "check-${NAME}") add_custom_target(${TARGET} COMMENT "Running ${NAME} test suite" COMMAND cmake -E echo "PASSED: ${NAME} test suite" ) foreach(PARENT_TARGET ${ARGN}) if(TARGET ${PARENT_TARGET}) add_dependencies(${PARENT_TARGET} ${TARGET}) endif() endforeach() endfunction() macro(create_test_suite NAME) create_test_suite_with_parent_targets(${NAME} check-all check-extended) endmacro() set(TEST_RUNNER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/../templates/TestRunner.cmake.in") function(_add_test_runner SUITE NAME COMMAND) set(TARGET "check-${SUITE}-${NAME}") set(LOG "${NAME}.log") set(RUNNER "${CMAKE_CURRENT_BINARY_DIR}/run-${NAME}.sh") list(JOIN ARGN " " ARGS) configure_file( "${TEST_RUNNER_TEMPLATE}" "${RUNNER}" ) add_custom_target(${TARGET} COMMAND ${RUNNER} COMMENT "${SUITE}: testing ${NAME}" DEPENDS ${COMMAND} ${RUNNER} ) add_dependencies("check-${SUITE}" ${TARGET}) endfunction() function(add_test_to_suite SUITE NAME) add_executable(${NAME} EXCLUDE_FROM_ALL ${ARGN}) _add_test_runner(${SUITE} ${NAME} ${NAME}) endfunction(add_test_to_suite) function(add_boost_unit_tests_to_suite SUITE NAME) cmake_parse_arguments(ARG "" "" "TESTS" ${ARGN} ) add_executable(${NAME} EXCLUDE_FROM_ALL ${ARG_UNPARSED_ARGUMENTS}) add_dependencies("check-${SUITE}" ${NAME}) foreach(_test_source ${ARG_TESTS}) target_sources(${NAME} PRIVATE "${_test_source}") get_filename_component(_test_name "${_test_source}" NAME_WE) _add_test_runner( ${SUITE} ${_test_name} ${NAME} -t "${_test_name}" ) set(SUITE_UPGRADE_ACTIVATED "${SUITE}-upgrade-activated") set(TARGET_UPGRADE_ACTIVATED "check-${SUITE_UPGRADE_ACTIVATED}") if(NOT TARGET ${TARGET_UPGRADE_ACTIVATED}) create_test_suite_with_parent_targets( ${SUITE_UPGRADE_ACTIVATED} check-upgrade-activated + check-upgrade-activated-extended ) add_dependencies(${TARGET_UPGRADE_ACTIVATED} ${NAME}) endif() _add_test_runner( ${SUITE_UPGRADE_ACTIVATED} "${_test_name}" ${NAME} -t "${_test_name}" # Dec. 1st, 2019 at 00:00:00 -- -phononactivationtime=1575158400 ) endforeach() find_package(Boost 1.58 REQUIRED unit_test_framework) target_link_libraries(${NAME} Boost::unit_test_framework) # We need to detect if the BOOST_TEST_DYN_LINK flag is required include(CheckCXXSourceCompiles) set(CMAKE_REQUIRED_LIBRARIES Boost::unit_test_framework) check_cxx_source_compiles(" #define BOOST_TEST_DYN_LINK #define BOOST_TEST_MAIN #include " BOOST_TEST_DYN_LINK) if(BOOST_TEST_DYN_LINK) target_compile_definitions(${NAME} PRIVATE BOOST_TEST_DYN_LINK) endif(BOOST_TEST_DYN_LINK) endfunction(add_boost_unit_tests_to_suite) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index c003a799a..2068e05f5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,118 +1,119 @@ ### # Create config.ini file for tests ### set(abs_top_srcdir ${CMAKE_SOURCE_DIR}) set(abs_top_builddir ${CMAKE_BINARY_DIR}) if(CMAKE_SYSTEM_NAME MATCHES "Windows") set(EXEEXT ".exe") endif() if(NOT BUILD_BITCOIN_WALLET) set(ENABLE_WALLET_TRUE "#") endif() if(NOT BUILD_BITCOIN_TX OR NOT BUILD_BITCOIN_TX) set(BUILD_BITCOIN_UTILS_TRUE "#") endif() if(NOT BUILD_BITCOIN_ZMQ) set(ENABLE_ZMQ_TRUE "#") endif() # Create build ini file configure_file(config.ini.in config.ini @ONLY) ### # Setup symlinks for testing ### include(SanitizeHelper) function(make_link file) set(src "${CMAKE_CURRENT_SOURCE_DIR}/${file}") set(dest "${CMAKE_CURRENT_BINARY_DIR}/${file}") add_custom_command( OUTPUT "${dest}" COMMAND ${CMAKE_COMMAND} -E create_symlink "${src}" "${dest}" COMMENT "link ${file}" MAIN_DEPENDENCY "${src}" ) # Add a phony target to make sure the files are linked by default. sanitize_target_name("link-" "${file}" NAME) add_custom_target(${NAME} ALL DEPENDS "${dest}") endfunction() file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/functional/) file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/util/) make_link(functional/test_runner.py) make_link(util/bitcoin-util-test.py) make_link(util/rpcauth-test.py) macro(add_functional_test_check TARGET COMMENT) add_custom_target(${TARGET} COMMENT "${COMMENT}" COMMAND "${PYTHON_EXECUTABLE}" ./functional/test_runner.py ${ARGN} DEPENDS ../src/bitcoind ../src/bitcoin-cli ${CMAKE_CURRENT_BINARY_DIR}/functional/test_runner.py USES_TERMINAL ) endmacro() add_functional_test_check(check-functional "Run the functional tests" ) add_dependencies(check-all check-functional) add_functional_test_check(check-functional-extended "Run the extended functional tests" --extended ) add_dependencies(check-extended check-functional-extended) add_functional_test_check(check-functional-upgrade-activated "Run the functional tests with the upgrade activated" --with-phononactivation ) add_dependencies(check-upgrade-activated check-functional-upgrade-activated) -add_functional_test_check(check-functional-extended-upgrade-activated +add_functional_test_check(check-functional-upgrade-activated-extended "Run the extended functional tests with the upgrade activated" --extended --with-phononactivation ) +add_dependencies(check-upgrade-activated-extended check-functional-upgrade-activated-extended) if(BUILD_BITCOIN_TX) add_custom_target(check-bitcoin-util COMMENT "Test Bitcoin utilities..." COMMAND "${PYTHON_EXECUTABLE}" ./util/bitcoin-util-test.py DEPENDS ../src/bitcoin-tx ${CMAKE_CURRENT_BINARY_DIR}/util/bitcoin-util-test.py ) add_dependencies(check check-bitcoin-util) endif() add_custom_target(check-rpcauth COMMENT "Test Bitcoin RPC authentication..." COMMAND "${PYTHON_EXECUTABLE}" ./util/rpcauth-test.py DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/util/rpcauth-test.py ) add_dependencies(check check-rpcauth) include(PackageHelper) exclude_from_source_package( # Subdirectories "cache/" "lint/" "sanitizer_suppressions/" )