WIP: Convert ui,v3ext,verify_extra_test
[openssl.git] / test / v3ext.c
1 /*
2  * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
3  *
4  * Licensed under the OpenSSL license (the "License").  You may not use
5  * this file except in compliance with the License.  You can obtain a copy
6  * in the file LICENSE in the source distribution or at
7  * https://www.openssl.org/source/license.html
8  */
9
10 #include <stdio.h>
11 #include <openssl/x509.h>
12 #include <openssl/x509v3.h>
13 #include <openssl/pem.h>
14 #include <openssl/err.h>
15
16 #include "test_main_custom.h"
17 #include "testutil.h"
18
19 static const char *infile;
20
21 static int test_pathlen(void)
22 {
23     X509 *x = NULL;
24     BIO *b = NULL;
25     long pathlen;
26     int ret = 0;
27
28     if (!TEST_ptr(b = BIO_new_file(infile, "r"))
29             || !TEST_ptr(x = PEM_read_bio_X509(b, NULL, NULL, NULL))
30             || !TEST_int_eq(pathlen = X509_get_pathlen(x), 6))
31         goto end;
32
33     ret = 1;
34
35 end:
36     BIO_free(b);
37     X509_free(x);
38     return ret;
39 }
40
41 int test_main(int argc, char *argv[])
42 {
43     int ret;
44
45     if (argc != 2) {
46         TEST_error("Usage error");
47         return 0;
48     }
49     infile = argv[1];
50
51     ADD_TEST(test_pathlen);
52     ret = run_tests(argv[0]);
53     return ret;
54 }