cmake, refactor: Deduplicate test-related code
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
This commit is contained in:
@@ -144,15 +144,16 @@ if(SECP256K1_BUILD_TESTS)
|
|||||||
list(APPEND TEST_DEFINITIONS SUPPORTS_CONCURRENCY=1)
|
list(APPEND TEST_DEFINITIONS SUPPORTS_CONCURRENCY=1)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(noverify_tests tests.c)
|
function(add_executable_and_tests exe_name verify_definition)
|
||||||
target_link_libraries(noverify_tests secp256k1_precomputed secp256k1_asm)
|
add_executable(${exe_name} tests.c)
|
||||||
target_compile_definitions(noverify_tests PRIVATE ${TEST_DEFINITIONS})
|
target_link_libraries(${exe_name} secp256k1_precomputed secp256k1_asm)
|
||||||
add_test(NAME secp256k1_noverify_tests COMMAND noverify_tests)
|
target_compile_definitions(${exe_name} PRIVATE ${verify_definition} ${TEST_DEFINITIONS})
|
||||||
|
add_test(NAME secp256k1_${exe_name} COMMAND ${exe_name})
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
add_executable_and_tests(noverify_tests "")
|
||||||
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
|
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
|
||||||
add_executable(tests tests.c)
|
add_executable_and_tests(tests VERIFY)
|
||||||
target_compile_definitions(tests PRIVATE VERIFY ${TEST_DEFINITIONS})
|
|
||||||
target_link_libraries(tests secp256k1_precomputed secp256k1_asm)
|
|
||||||
add_test(NAME secp256k1_tests COMMAND tests)
|
|
||||||
endif()
|
endif()
|
||||||
unset(TEST_DEFINITIONS)
|
unset(TEST_DEFINITIONS)
|
||||||
endif()
|
endif()
|
||||||
|
|||||||
Reference in New Issue
Block a user