Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,10 @@ function(add_example name)
secp256k1
$<$<PLATFORM_ID:Windows>:bcrypt>
)
set(test_name ${name}_example)
add_test(NAME secp256k1_${test_name} COMMAND ${target_name})
add_test(NAME secp256k1_example::${name} COMMAND ${target_name})
set_tests_properties(secp256k1_example::${name} PROPERTIES
LABELS secp256k1_example
)
endfunction()

add_example(ecdsa)
Expand Down
49 changes: 40 additions & 9 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,43 @@ if(SECP256K1_BUILD_TESTS)
list(APPEND TEST_DEFINITIONS SUPPORTS_CONCURRENCY=1)
endif()

add_executable(noverify_tests tests.c)
target_link_libraries(noverify_tests secp256k1_precomputed secp256k1_asm)
target_compile_definitions(noverify_tests PRIVATE ${TEST_DEFINITIONS})
add_test(NAME secp256k1_noverify_tests COMMAND noverify_tests)
set(test_targets "")
set(test_names "")
# Start with the longest-running tests.
list(APPEND test_targets ellswift)
list(APPEND test_names ellswift)
list(APPEND test_targets ecmult_constants)
list(APPEND test_names ecmult_constants)
list(APPEND test_targets "ecmult_pre_g wnaf point_times_order ecmult_near_split_bound ecmult_chain ecmult_gen_blind ecmult_const_tests ecmult_multi_tests ec_combine")
list(APPEND test_names ecmult)
# Continue with the remaining tests.
list(APPEND test_targets integer scalar field group ec ecdh ecdsa recovery extrakeys schnorrsig musig)
Comment on lines +154 to +157
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason why you have quotation marks in the first line here but not in the last?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first line has quotes to combine the quoted test cases into a single ctest's test "ecmult".

In the last line, all mentioned test cases and modules are wrapped as its own ctest's tests.

list(APPEND test_names integer scalar field group ec ecdh ecdsa recovery extrakeys schnorrsig musig)
# Combine short, trivial tests for log brevity.
list(APPEND test_targets "general hash utils")
list(APPEND test_names "general,hash,utils")

function(add_executable_and_tests exe_name verify_definition label)
add_executable(${exe_name} tests.c)
target_link_libraries(${exe_name} secp256k1_precomputed secp256k1_asm)
target_compile_definitions(${exe_name} PRIVATE ${verify_definition} ${TEST_DEFINITIONS})
foreach(test_target test_name IN ZIP_LISTS test_targets test_names)
string(REPLACE " " ";" test_target "${test_target}")
list(TRANSFORM test_target PREPEND "--target=")
add_test(NAME ${label}::${test_name}
COMMAND ${exe_name} ${test_target} --log=1
COMMAND_EXPAND_LISTS
)
set_tests_properties(${label}::${test_name} PROPERTIES
LABELS ${label}
SKIP_REGULAR_EXPRESSION "module disabled"
)
endforeach()
endfunction()

add_executable_and_tests(noverify_tests "" secp256k1_noverify)
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
add_executable(tests tests.c)
target_compile_definitions(tests PRIVATE VERIFY ${TEST_DEFINITIONS})
target_link_libraries(tests secp256k1_precomputed secp256k1_asm)
add_test(NAME secp256k1_tests COMMAND tests)
add_executable_and_tests(tests VERIFY secp256k1_verify)
endif()
unset(TEST_DEFINITIONS)
endif()
Expand All @@ -162,7 +190,10 @@ 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 secp256k1_exhaustive_tests COMMAND exhaustive_tests)
add_test(NAME secp256k1_exhaustive COMMAND exhaustive_tests)
set_tests_properties(secp256k1_exhaustive PROPERTIES
LABELS secp256k1_exhaustive
)
endif()

if(SECP256K1_BUILD_CTIME_TESTS)
Expand Down