X-Git-Url: https://git.openssl.org/?p=openssl.git;a=blobdiff_plain;f=test%2Fv3ext.c;h=14ae49969d07bc0442bda18d438897885cda0d2c;hp=1c1f788a7314f71617c97a78f440cf74447454d1;hb=c6d38183d6754b0a7b90527d085a500680e7d2ea;hpb=e417070c9f2162594e8289aed93bd5801e70e60d diff --git a/test/v3ext.c b/test/v3ext.c index 1c1f788a73..14ae49969d 100644 --- a/test/v3ext.c +++ b/test/v3ext.c @@ -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 @@ -13,30 +13,35 @@ #include #include -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; +}