]>
Commit | Line | Data |
---|---|---|
e417070c | 1 | /* |
33388b44 | 2 | * Copyright 2016-2020 The OpenSSL Project Authors. All Rights Reserved. |
e417070c | 3 | * |
909f1a2e | 4 | * Licensed under the Apache License 2.0 (the "License"). You may not use |
e417070c RS |
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 | ||
4afc6060 RS |
16 | #include "testutil.h" |
17 | ||
18 | static const char *infile; | |
19 | ||
20 | static int test_pathlen(void) | |
e417070c RS |
21 | { |
22 | X509 *x = NULL; | |
23 | BIO *b = NULL; | |
24 | long pathlen; | |
4afc6060 | 25 | int ret = 0; |
e417070c | 26 | |
4afc6060 RS |
27 | if (!TEST_ptr(b = BIO_new_file(infile, "r")) |
28 | || !TEST_ptr(x = PEM_read_bio_X509(b, NULL, NULL, NULL)) | |
29 | || !TEST_int_eq(pathlen = X509_get_pathlen(x), 6)) | |
e417070c | 30 | goto end; |
4afc6060 RS |
31 | |
32 | ret = 1; | |
e417070c RS |
33 | |
34 | end: | |
e417070c RS |
35 | BIO_free(b); |
36 | X509_free(x); | |
37 | return ret; | |
38 | } | |
4afc6060 | 39 | |
a43ce58f SL |
40 | OPT_TEST_DECLARE_USAGE("cert.pem\n") |
41 | ||
ad887416 | 42 | int setup_tests(void) |
4afc6060 | 43 | { |
8d242823 MC |
44 | if (!test_skip_common_options()) { |
45 | TEST_error("Error parsing test options\n"); | |
46 | return 0; | |
47 | } | |
48 | ||
ad887416 | 49 | if (!TEST_ptr(infile = test_get_argument(0))) |
4afc6060 | 50 | return 0; |
4afc6060 RS |
51 | |
52 | ADD_TEST(test_pathlen); | |
ad887416 | 53 | return 1; |
4afc6060 | 54 | } |