1616#include "testrand_impl.h"
1717#include "checkmem.h"
1818#include "util.h"
19+ #include "cli_util.h"
1920
2021#include "../contrib/lax_der_parsing.c"
2122#include "../contrib/lax_der_privatekey_parsing.c"
2829
2930#define CONDITIONAL_TEST (cnt , nam ) if (COUNT < (cnt)) { printf("Skipping %s (iteration count too low)\n", nam); } else
3031
31- static int COUNT = 64 ;
32+ #define DEFAULT_COUNT 64
33+ static int COUNT = DEFAULT_COUNT ;
3234static secp256k1_context * CTX = NULL ;
3335static secp256k1_context * STATIC_CTX = NULL ;
3436
@@ -7428,6 +7430,21 @@ static void run_cmov_tests(void) {
74287430 ge_storage_cmov_test ();
74297431}
74307432
7433+ static void help (void ) {
7434+ printf ("The command ./tests runs a test suite on the code base.\n" );
7435+ printf ("\n" );
7436+ printf ("Some randomized tests are run for a certain number of iterations,\n" );
7437+ printf ("which is set to %d by default. This number can be altered by either\n" , DEFAULT_COUNT );
7438+ printf ("setting the environment variable SECP256K1_TEST_ITERS or by providing\n" );
7439+ printf ("the iteration count as a command line argument.\n" );
7440+ printf ("\n" );
7441+ printf ("Usage: ./tests [args]\n" );
7442+ printf ("Available arguments:\n" );
7443+ printf (" help : display this help message and exit\n" );
7444+ printf (" <count> : set the iteration count to <count>\n" );
7445+ printf ("\n" );
7446+ }
7447+
74317448int main (int argc , char * * argv ) {
74327449 /* Disable buffering for stdout to improve reliability of getting
74337450 * diagnostic information. Happens right at the start of main because
@@ -7437,6 +7454,15 @@ int main(int argc, char **argv) {
74377454 * unbuffered on all systems. */
74387455 setbuf (stderr , NULL );
74397456
7457+ if (argc > 1 ) {
7458+ if (have_flag (argc , argv , "-h" )
7459+ || have_flag (argc , argv , "--help" )
7460+ || have_flag (argc , argv , "help" )) {
7461+ help ();
7462+ return 0 ;
7463+ }
7464+ }
7465+
74407466 /* find iteration count */
74417467 if (argc > 1 ) {
74427468 COUNT = strtol (argv [1 ], NULL , 0 );
0 commit comments