Skip to content

Commit

Permalink
[CMAKE] Move the upgrade activated tests out of the TestSuite module
Browse files Browse the repository at this point in the history
Summary:
The TestSuite module is shared code and should not contain project
dependent behavior; e.g. it makes no sense to have this code be part of
the secp256k1 library.

There is no change in behavior.

Depends on D5312.

Test Plan:
  ninja check check-upgrade-activated

Reviewers: #bitcoin_abc, jasonbcox

Reviewed By: #bitcoin_abc, jasonbcox

Differential Revision: https://reviews.bitcoinabc.org/D5313
  • Loading branch information
Fabcien authored and ftrader committed Jun 7, 2020
1 parent a8461ec commit 7a64e55
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 21 deletions.
24 changes: 3 additions & 21 deletions cmake/modules/TestSuite.cmake
Expand Up @@ -33,7 +33,7 @@ macro(create_test_suite NAME)
endmacro()

set(TEST_RUNNER_TEMPLATE "${CMAKE_CURRENT_LIST_DIR}/../templates/TestRunner.cmake.in")
function(_add_test_runner SUITE NAME COMMAND)
function(add_test_runner SUITE NAME COMMAND)
get_target_from_suite(${SUITE} SUITE_TARGET)
set(TARGET "${SUITE_TARGET}-${NAME}")

Expand All @@ -58,7 +58,7 @@ endfunction()

function(add_test_to_suite SUITE NAME)
add_executable(${NAME} EXCLUDE_FROM_ALL ${ARGN})
_add_test_runner(${SUITE} ${NAME} ${NAME})
add_test_runner(${SUITE} ${NAME} ${NAME})

get_target_from_suite(${SUITE} TARGET)
set_property(
Expand All @@ -82,7 +82,7 @@ function(add_boost_unit_tests_to_suite 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(
add_test_runner(
${SUITE}
${_test_name}
${NAME} -t "${_test_name}" -l test_suite
Expand All @@ -91,24 +91,6 @@ function(add_boost_unit_tests_to_suite SUITE NAME)
TARGET ${SUITE_TARGET}
APPEND PROPERTY UNIT_TESTS ${_test_name}
)

set(SUITE_UPGRADE_ACTIVATED "${SUITE}-upgrade-activated")
get_target_from_suite(${SUITE_UPGRADE_ACTIVATED} TARGET_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)
Expand Down
29 changes: 29 additions & 0 deletions src/test/CMakeLists.txt
Expand Up @@ -203,6 +203,35 @@ if(ENABLE_PROPERTY_BASED_TESTS)
target_link_libraries(test_bitcoin Rapidcheck::rapidcheck)
endif()

function(add_boost_test_runners_with_upgrade_activated SUITE EXECUTABLE)
set(SUITE_UPGRADE_ACTIVATED "${SUITE}-upgrade-activated")
get_target_from_suite(${SUITE_UPGRADE_ACTIVATED} TARGET_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} ${EXECUTABLE})
endif()

get_target_from_suite(${SUITE} SUITE_TARGET)
get_target_property(BOOST_TESTS ${SUITE_TARGET} UNIT_TESTS)

foreach(_test_name ${BOOST_TESTS})
add_test_runner(
${SUITE_UPGRADE_ACTIVATED}
"${_test_name}"
${EXECUTABLE} -t "${_test_name}"
# Dec. 1st, 2019 at 00:00:00
-- -phononactivationtime=1575158400
)
endforeach()
endfunction()

add_boost_test_runners_with_upgrade_activated(bitcoin test_bitcoin)

target_link_libraries(test_bitcoin rpcclient server)
if(TARGET bitcoinconsensus-shared)
target_link_libraries(test_bitcoin bitcoinconsensus-shared)
Expand Down

0 comments on commit 7a64e55

Please sign in to comment.