2 * Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
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
10 /* Internal tests for the x509 and x509v3 modules */
15 #include <openssl/x509.h>
16 #include <openssl/x509v3.h>
21 const char *test_case_name;
22 const char *test_section;
25 /**********************************************************************
31 static SIMPLE_FIXTURE setup_standard_exts(const char *const test_case_name)
33 SIMPLE_FIXTURE fixture;
34 fixture.test_case_name = test_case_name;
38 #include "../crypto/x509v3/ext_dat.h"
39 #include "../crypto/x509v3/standard_exts.h"
41 static int execute_standard_exts(SIMPLE_FIXTURE fixture)
44 int prev = -1, good = 1;
45 const X509V3_EXT_METHOD **tmp;
48 for (i = 0; i < OSSL_NELEM(standard_exts); i++, tmp++) {
49 if ((*tmp)->ext_nid < prev)
51 prev = (*tmp)->ext_nid;
56 fprintf(stderr, "Extensions out of order!\n");
57 for (i = 0; i < STANDARD_EXTENSION_COUNT; i++, tmp++)
58 fprintf(stderr, "%d : %s\n", (*tmp)->ext_nid,
59 OBJ_nid2sn((*tmp)->ext_nid));
61 fprintf(stderr, "Order OK\n");
67 static void teardown_standard_exts(SIMPLE_FIXTURE fixture)
69 ERR_print_errors_fp(stderr);
72 /**********************************************************************
80 SIMPLE_FIXTURE (*setup)(const char *const test_case_name);
81 int (*execute)(SIMPLE_FIXTURE);
82 void (*teardown)(SIMPLE_FIXTURE);
84 {"standard_exts", setup_standard_exts, execute_standard_exts,
85 teardown_standard_exts},
88 static int drive_tests(int idx)
90 SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, tests[idx].setup);
91 fixture.test_section = tests[idx].section;
92 EXECUTE_TEST(tests[idx].execute, tests[idx].teardown);
95 int main(int argc, char **argv)
97 ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
99 return run_tests(argv[0]);