@@ -7430,6 +7430,32 @@ static void run_cmov_tests(void) {
7430
7430
ge_storage_cmov_test ();
7431
7431
}
7432
7432
7433
+ static int process_args (int argc , char * * argv ) {
7434
+ int is_count_arg_set = 0 ;
7435
+ const char * env = getenv ("SECP256K1_TEST_ITERS" );
7436
+
7437
+ if (argc > 1 ) {
7438
+ int count_arg = strtol (argv [1 ], NULL , 0 );
7439
+ if (count_arg > 0 ) {
7440
+ is_count_arg_set = 1 ;
7441
+ COUNT = count_arg ;
7442
+ }
7443
+ }
7444
+
7445
+ if (env && strlen (env ) > 0 ) {
7446
+ COUNT = strtol (env , NULL , 0 );
7447
+ if (is_count_arg_set ) {
7448
+ fputs ("Environment variable SECP256K1_TEST_ITERS and command line argument both try to set the iteration count.\n" , stderr );
7449
+ return 0 ;
7450
+ }
7451
+ if (COUNT <= 0 ) {
7452
+ fputs ("An iteration count of 0 or less is not allowed.\n" , stderr );
7453
+ return 0 ;
7454
+ }
7455
+ }
7456
+ return 1 ;
7457
+ }
7458
+
7433
7459
static void help (void ) {
7434
7460
printf ("The command ./tests runs a test suite on the code base.\n" );
7435
7461
printf ("\n" );
@@ -7463,17 +7489,8 @@ int main(int argc, char **argv) {
7463
7489
}
7464
7490
}
7465
7491
7466
- /* find iteration count */
7467
- if (argc > 1 ) {
7468
- COUNT = strtol (argv [1 ], NULL , 0 );
7469
- } else {
7470
- const char * env = getenv ("SECP256K1_TEST_ITERS" );
7471
- if (env && strlen (env ) > 0 ) {
7472
- COUNT = strtol (env , NULL , 0 );
7473
- }
7474
- }
7475
- if (COUNT <= 0 ) {
7476
- fputs ("An iteration count of 0 or less is not allowed.\n" , stderr );
7492
+ if (!process_args (argc , argv )) {
7493
+ help ();
7477
7494
return EXIT_FAILURE ;
7478
7495
}
7479
7496
printf ("test count = %i\n" , COUNT );
0 commit comments