Skip to content

Commit

Permalink
[SECP256K1] make test count iteration configurable by environment var…
Browse files Browse the repository at this point in the history
…iable

Summary:
```
You can set the test iteration count by command-line parameter but it is
very hard to control the iteration count used by make check and even
harder to control the count when this is run through Bitcoin Core's
build system. Using an environment var solves both problems.
```

Backport of [[bitcoin-core/secp256k1#851 | secp256k1#851]]

Test Plan:
  SECP256K1_TEST_ITERS=16 ninja check-secp256k1
Should succeed but:
  SECP256K1_TEST_ITERS=0 ninja check-secp256k1
Should fail with error `An iteration count of 0 or less is not allowed.`

Reviewers: #bitcoin_abc, PiRK

Reviewed By: #bitcoin_abc, PiRK

Differential Revision: https://reviews.bitcoinabc.org/D9375
  • Loading branch information
apoelstra authored and Fabcien committed Apr 8, 2021
1 parent 543f9c5 commit bd3ec0d
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/secp256k1/src/tests.c
Expand Up @@ -5635,6 +5635,15 @@ int main(int argc, char **argv) {
/* find iteration count */
if (argc > 1) {
count = strtol(argv[1], NULL, 0);
} else {
const char* env = getenv("SECP256K1_TEST_ITERS");
if (env) {
count = strtol(env, NULL, 0);
}
}
if (count <= 0) {
fputs("An iteration count of 0 or less is not allowed.\n", stderr);
return EXIT_FAILURE;
}
printf("test count = %i\n", count);

Expand Down

0 comments on commit bd3ec0d

Please sign in to comment.