-
Notifications
You must be signed in to change notification settings - Fork 1.1k
cmake: Split test cases to improve parallelism #1760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
hebasto
wants to merge
3
commits into
bitcoin-core:master
Choose a base branch
from
hebasto:251016-ctest-opt
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 1 commit
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -144,16 +144,42 @@ if(SECP256K1_BUILD_TESTS) | |
| list(APPEND TEST_DEFINITIONS SUPPORTS_CONCURRENCY=1) | ||
| endif() | ||
|
|
||
| function(add_executable_and_tests exe_name verify_definition) | ||
| 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) | ||
| 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}) | ||
| add_test(NAME secp256k1_${exe_name} COMMAND ${exe_name}) | ||
| 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 | ||
| SKIP_REGULAR_EXPRESSION "module disabled" | ||
| ) | ||
| endforeach() | ||
| endfunction() | ||
|
|
||
| add_executable_and_tests(noverify_tests "") | ||
| add_executable_and_tests(noverify_tests "" secp256k1_noverify) | ||
| if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage") | ||
| add_executable_and_tests(tests VERIFY) | ||
| add_executable_and_tests(tests VERIFY secp256k1_verify) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The target name |
||
| endif() | ||
| unset(TEST_DEFINITIONS) | ||
| endif() | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I take @real-or-random's question as a proof that procedural logic in
CMakeLists.txtis hard to reason about and should be avoided.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we switch to automated test discovery in a follow-up, we will no longer have the ability to combine test cases. Maybe we should keep them separated so that the follow-up will not change the number of tests again?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good, let's keep it simple.
For test ordering, we could perhaps simply make sure that automated discovery runs the tests in the order they are listed by
tests -l.