Merge bitcoin-core/secp256k1#1734: Introduce (mini) unit test framework
2f4546ce56test: add --log option to display tests execution (furszy)95b9953ea4test: Add option to display all available tests (furszy)953f7b0088test: support running specific tests/modules targets (furszy)0302c1a3d7test: add --help for command-line options (furszy)9ec3bfe22dtest: adapt modules to the new test infrastructure (furszy)48789dafc2test: introduce (mini) unit test framework (furszy)9cce703863refactor: move 'gettime_i64()' to tests_common.h (furszy) Pull request description: Early Note: Don’t be scared by the PR’s line changes count — most of it’s just doc or part of the test framework API. Context: Currently, all tests run single-threaded sequentially and the library lacks the ability to specify which test (or group of tests) you would like to run. This is not only inconvenient as more tests are added but also time consuming during development and affects downstream projects that may want to parallelize the workload (such as Bitcoin-Core CI). PR Goal: Introduce a lightweight, extensible C89 unit test framework with no dynamic memory allocations, providing a structured way to register, execute, and report tests. The framework supports named command-line arguments in `-key=value` form, parallel test execution across multiple worker processes, granular test selection (selecting tests either by name or by module name), and time accumulation reports. The introduced framework supports: * `-help` or `-h`: display list of available commands along with their descriptions. * `-jobs=<num>`: distribute tests across multiple worker processes (default: sequential if 0). * `-target=<name>` or `-t=<name>`: run only specific tests by name; can be repeated to select multiple tests. * `-target=<module name>`, `-t=<module>` Run all tests within a specific module (can be provided multiple times) * `-seed=<hex>`: set a specific RNG seed (defaults to random if unspecified). * `-iterations=<n>`: specify the number of iterations. * `-list_tests`: display list of available tests and modules you can run. * `-log=<0|1>`: enable or disable test execution logging (default: 0 = disabled). Beyond these features, the idea is to also make future developments smoother, as adding new tests require only a single entry in the central test registry, and new command-line options can be introduced easily by extending the framework’s `parse_arg()` function. Compatibility Note: The framework continues accepting the two positional arguments previously supported (iterations and seed), ensuring existing workflows remain intact. Testing Notes: Have fun. You can quickly try it through `./tests -j=<workers_num>` for parallel execution or `./tests -t=<test_name>` to run a specific test (call `./tests -print_tests` to display all available tests and modules). Extra Note: I haven't checked the exhaustive tests file so far, but I will soon. For now, this only runs all tests declared in the `tests` binary. Testing Results: (Current master branch vs PR in seconds) * Raspberry Pi 5: master \~100 s → PR \~38 s (5 jobs) * MacBook Pro M1: master \~30 s → PR \~10 s (6 jobs) ACKs for top commit: theStack: re-ACK2f4546ce56real-or-random: ACK2f4546ce56hebasto: ACK2f4546ce56. Tree-SHA512: 85ca2cbb620b84b35b353d5d4cf093c388fc3851ca405eeb0e458f8fa72b60534bccd357c7edabf8fc9aa93d9ad0a6fbac3dd5c4d5f9dfdf4d8701a9834755b9
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#define SECP256K1_MODULE_ELLSWIFT_TESTS_H
|
||||
|
||||
#include "../../../include/secp256k1_ellswift.h"
|
||||
#include "../../unit_test.h"
|
||||
|
||||
struct ellswift_xswiftec_inv_test {
|
||||
int enc_bitmap;
|
||||
@@ -433,4 +434,10 @@ void run_ellswift_tests(void) {
|
||||
}
|
||||
}
|
||||
|
||||
/* --- Test registry --- */
|
||||
/* TODO: subdivide test in cases */
|
||||
static const struct tf_test_entry tests_ellswift[] = {
|
||||
CASE(ellswift_tests),
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user