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)
71 /**********************************************************************
79 SIMPLE_FIXTURE (*setup)(const char *const test_case_name);
80 int (*execute)(SIMPLE_FIXTURE);
81 void (*teardown)(SIMPLE_FIXTURE);
83 {"standard_exts", setup_standard_exts, execute_standard_exts,
84 teardown_standard_exts},
87 static int drive_tests(int idx)
89 SETUP_TEST_FIXTURE(SIMPLE_FIXTURE, tests[idx].setup);
90 fixture.test_section = tests[idx].section;
91 EXECUTE_TEST(tests[idx].execute, tests[idx].teardown);
94 int main(int argc, char **argv)
96 ADD_ALL_TESTS(drive_tests, OSSL_NELEM(tests));
98 return run_tests(argv[0]);