Fix rpath-related Linux "test_shlibload" failure.
[openssl.git] / test / ecstresstest.c
index 5ea8f8477e62cef2851099b5b3f200c6351b5e12..4f05d237ba5d3e7d9d1e43b1075207510b579900 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2017-2018 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL licenses, (the "License");
  * you may not use this file except in compliance with the License.
@@ -8,7 +8,7 @@
  * or in the file LICENSE in the source distribution.
  */
 
-#include "e_os.h"
+#include "internal/nelem.h"
 #include "testutil.h"
 
 #include <stdio.h>
@@ -45,16 +45,15 @@ static BIGNUM *walk_curve(const EC_GROUP *group, EC_POINT *point, int64_t num)
     int64_t i;
 
     if (!TEST_ptr(scalar = BN_new())
-            || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point,
-                                                              scalar,
-                                                              NULL, NULL)))
+            || !TEST_true(EC_POINT_get_affine_coordinates(group, point, scalar,
+                                                          NULL, NULL)))
         goto err;
 
     for (i = 0; i < num; i++) {
         if (!TEST_true(EC_POINT_mul(group, point, NULL, point, scalar, NULL))
-                || !TEST_true(EC_POINT_get_affine_coordinates_GFp(group, point,
-                                                                  scalar,
-                                                                  NULL, NULL)))
+                || !TEST_true(EC_POINT_get_affine_coordinates(group, point,
+                                                              scalar,
+                                                              NULL, NULL)))
             goto err;
     }
     return scalar;
@@ -64,7 +63,7 @@ err:
     return NULL;
 }
 
-static int test_curve()
+static int test_curve(void)
 {
     EC_GROUP *group = NULL;
     EC_POINT *point = NULL;
@@ -109,7 +108,7 @@ static int atoi64(const char *in, int64_t *result)
     for ( ; *in != '\0'; in++) {
         char c = *in;
 
-        if (!isdigit(c))
+        if (!isdigit((unsigned char)c))
             return 0;
         ret *= 10;
         ret += (c - '0');
@@ -123,39 +122,28 @@ static int atoi64(const char *in, int64_t *result)
  * |num| times and prints the resulting X-coordinate. Otherwise runs the test
  * the default number of times and compares against the expected result.
  */
-int test_main(int argc, char *argv[])
+int setup_tests(void)
 {
-    const char *argv0 = argv[0];
+    const char *p;
 
     if (!atoi64(NUM_REPEATS, &num_repeats)) {
         TEST_error("Cannot parse " NUM_REPEATS);
-        return EXIT_FAILURE;
+        return 0;
     }
     /*
      * TODO(openssl-team): code under test/ should be able to reuse the option
      * parsing framework currently in apps/.
      */
-    argc--;
-    argv++;
-    while (argc >= 1) {
-        if (strcmp(*argv, "-num") == 0) {
-            if (--argc < 1
-                    || !atoi64(*++argv, &num_repeats)
-                    || num_repeats < 0) {
-                TEST_error("Bad -num argument\n");
-                return EXIT_FAILURE;
-            }
-            print_mode = 1;
-        } else {
-            TEST_error("Unknown option %s\n", *argv);
-            return EXIT_FAILURE;
-        }
-        argc--;
-        argv++;
+    p = test_get_option_argument("-num");
+    if (p != NULL) {
+        if (!atoi64(p, &num_repeats)
+                || num_repeats < 0)
+            return 0;
+        print_mode = 1;
     }
 
 #ifndef OPENSSL_NO_EC
     ADD_TEST(test_curve);
 #endif
-    return run_tests(argv0);
+    return 1;
 }