Skip to content

Commit

Permalink
cmake, test: Introduce SECP256K1_TESTNAME_PREFIX variable
Browse files Browse the repository at this point in the history
This change enables downstream projects to add a custom prefix to the
libsecp256k1 tests, facilitating the use of `ctest` regex matching
options.
  • Loading branch information
hebasto committed Aug 12, 2024
1 parent 3fdf146 commit 051af4c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ function(add_example name)
$<$<PLATFORM_ID:Windows>:bcrypt>
)
set(test_name ${name}_example)
add_test(NAME ${test_name} COMMAND ${target_name})
add_test(NAME ${SECP256K1_TESTNAME_PREFIX}${test_name} COMMAND ${target_name})
if(BUILD_SHARED_LIBS AND MSVC)
# The DLL must reside either in the same folder where the executable is
# or somewhere in PATH. Using the latter option.
Expand Down
6 changes: 3 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -87,12 +87,12 @@ endif()
if(SECP256K1_BUILD_TESTS)
add_executable(noverify_tests tests.c)
target_link_libraries(noverify_tests secp256k1_precomputed secp256k1_asm)
add_test(NAME noverify_tests COMMAND noverify_tests)
add_test(NAME ${SECP256K1_TESTNAME_PREFIX}noverify_tests COMMAND noverify_tests)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
add_executable(tests tests.c)
target_compile_definitions(tests PRIVATE VERIFY)
target_link_libraries(tests secp256k1_precomputed secp256k1_asm)
add_test(NAME tests COMMAND tests)
add_test(NAME ${SECP256K1_TESTNAME_PREFIX}tests COMMAND tests)
endif()
endif()

Expand All @@ -101,7 +101,7 @@ if(SECP256K1_BUILD_EXHAUSTIVE_TESTS)
add_executable(exhaustive_tests tests_exhaustive.c)
target_link_libraries(exhaustive_tests secp256k1_asm)
target_compile_definitions(exhaustive_tests PRIVATE $<$<NOT:$<CONFIG:Coverage>>:VERIFY>)
add_test(NAME exhaustive_tests COMMAND exhaustive_tests)
add_test(NAME ${SECP256K1_TESTNAME_PREFIX}exhaustive_tests COMMAND exhaustive_tests)
endif()

if(SECP256K1_BUILD_CTIME_TESTS)
Expand Down

0 comments on commit 051af4c

Please sign in to comment.