Fix rpath-related Linux "test_shlibload" failure.
[openssl.git] / test / v3ext.c
index 1c1f788a7314f71617c97a78f440cf74447454d1..14ae49969d07bc0442bda18d438897885cda0d2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
+ * Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
  *
  * Licensed under the OpenSSL license (the "License").  You may not use
  * this file except in compliance with the License.  You can obtain a copy
 #include <openssl/pem.h>
 #include <openssl/err.h>
 
-int main(int ac, char **av)
+#include "testutil.h"
+
+static const char *infile;
+
+static int test_pathlen(void)
 {
     X509 *x = NULL;
     BIO *b = NULL;
     long pathlen;
-    int ret = 1;
+    int ret = 0;
 
-    if (ac != 2) {
-        fprintf(stderr, "Usage error\n");
-        goto end;
-    }
-    b = BIO_new_file(av[1], "r");
-    if (b == NULL)
+    if (!TEST_ptr(b = BIO_new_file(infile, "r"))
+            || !TEST_ptr(x = PEM_read_bio_X509(b, NULL, NULL, NULL))
+            || !TEST_int_eq(pathlen = X509_get_pathlen(x), 6))
         goto end;
-    x = PEM_read_bio_X509(b, NULL, NULL, NULL);
-    if (x == NULL)
-        goto end;
-    pathlen = X509_get_pathlen(x);
-    if (pathlen == 6)
-        ret = 0;
+
+    ret = 1;
 
 end:
-    ERR_print_errors_fp(stderr);
     BIO_free(b);
     X509_free(x);
     return ret;
 }
+
+int setup_tests(void)
+{
+    if (!TEST_ptr(infile = test_get_argument(0)))
+        return 0;
+
+    ADD_TEST(test_pathlen);
+    return 1;
+}