-
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
base: master
Are you sure you want to change the base?
Conversation
The output is nice for sure, but wouldn't it be much simpler to just invoke the test binaries with My concern is about the list of tests here. It will require maintenance work, and it's easy to forget a test. |
I don't think that's desirable, because it lacks the ability to share the granularity with other test targets. Specifically, I'm thinking in the context of the Bitcoin Core build, which has tons of test cases of its own. The ideal scenario is that you have a single process pool (controlled by the In contrast, if you push the task scheduling down to libsecp256k1's own test binary, you at best end up with a situation where you first run all Bitcoin Core tests, wait for those to complete (temporarily running out of tasks in the process), and then run libsecp256k1's tests with |
Regarding the maintenance topic, wouldn't be better to call I experimented a bit with this idea and was able to dynamically generate a file containing all the tests names. See https://github.com/furszy/secp256k1/tree/2025_ci_concurrent_tests (just need to run the |
src/CMakeLists.txt
Outdated
function(add_executable_and_tests verify) | ||
if(verify) | ||
set(verify_definition VERIFY) | ||
set(exe_name tests) | ||
else() | ||
set(verify_definition "") | ||
set(exe_name noverify_tests) | ||
endif() | ||
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}) | ||
endfunction() | ||
|
||
add_executable_and_tests(NO) | ||
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(YES) |
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.
Could write this shorter as:
function(add_executable_and_tests bin_name verify_definition)
add_executable(${bin_name} tests.c)
target_link_libraries(${bin_name} secp256k1_precomputed secp256k1_asm)
target_compile_definitions(${bin_name} PRIVATE ${verify_definition} ${TEST_DEFINITIONS})
add_test(NAME secp256k1_${bin_name} COMMAND ${bin_name})
endfunction()
add_executable_and_tests(noverify_tests "")
if(NOT CMAKE_BUILD_TYPE STREQUAL "Coverage")
add_executable_and_tests(tests VERIFY)
endif()
Also, probably the target_link_libraries
should be PRIVATE too.
See 00f20f6 (I applied it on top of your first commit - could directly squash it there)
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.
Also, probably the
target_link_libraries
should be PRIVATE too.
All target_link_libraries
commands should use the same signature. I think this change should be made in a separate PR.
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.
Could write this shorter as: ...
Thanks! Reworked.
I share the same perspective. |
@purpleKarrot's approach could be applied as a follow-up. |
Co-authored-by: furszy <matiasfurszyfer@protonmail.com>
c08bb65
to
2d8da55
Compare
Feedback from @furszy has been addressed. |
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) |
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?
This PR implements the approach suggested in #1734 (review).
Here is an example of the
ctest
output: