cmake: Integrate DiscoverTests and normalize test names
What changed, and why it matters
This commit is a routine build-system cleanup. It changes how CMake names and discovers test cases, switching from underscores to dots in test names and using a helper module to automatically find individual tests inside test executables. There is no change to the cryptographic code, no bug fix, and no security relevance.
No security action needed. Treat as a normal build-system maintenance commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch modifies two CMakeLists.txt files. In examples/CMakeLists.txt it renames the generated CTest entry from secp256k1_${name}_example to secp256k1.example.${name}. In src/CMakeLists.txt it replaces a direct add_test(NAME secp256k1_${exe_name} ...) call with a new discover_tests(...) invocation that parses the executable’s --list_tests output and registers each listed subtest as a separate CTest case named secp256k1.${exe_name}.<subtest> with arguments --target=<subtest> --log=1. The exhaustive test name is also normalized to dot-separated form. No source code, compiler flags, or runtime behavior of the library changes.
Changed components
examples/CMakeLists.txtsrc/CMakeLists.txtInspect captured patch +9 / −4
diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt
index c9da9de..86172f8 100644
--- a/examples/CMakeLists.txt
+++ b/examples/CMakeLists.txt
@@ -8,8 +8,7 @@ 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})
endfunction()
add_example(ecdsa)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 10f96c3..6186369 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -148,7 +148,13 @@ if(SECP256K1_BUILD_TESTS)
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})
+ include(DiscoverTests)
+ discover_tests(${exe_name}
+ DISCOVERY_ARGS "--list_tests"
+ DISCOVERY_MATCH "^\\t\\\\[ *[0-9]+\\\\] ([^ ].*)$"
+ TEST_NAME_REPLACEMENT "secp256k1.${exe_name}.\\\\1"
+ TEST_ARGS_REPLACEMENT "--target=\\\\1 --log=1"
+ )
endfunction()
add_executable_and_tests(noverify_tests "")
@@ -163,7 +169,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 secp256k1_exhaustive_tests COMMAND exhaustive_tests)
+ add_test(NAME secp256k1.exhaustive_tests COMMAND exhaustive_tests)
endif()
if(SECP256K1_BUILD_CTIME_TESTS)
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.