2 * Copyright 2021-2022 The OpenSSL Project Authors. All Rights Reserved.
4 * Licensed under the Apache License 2.0 (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
13 #include "crypto/asn1.h"
15 #define binname "ca_internals_test"
17 char *default_config_file = NULL;
19 static int test_do_updatedb(void)
24 size_t argc = test_get_argument_count();
32 TEST_error("Usage: %s: do_updatedb dbfile testdate need64bit\n", binname);
33 TEST_error(" testdate format: ASN1-String\n");
38 * if the test will only work with 64bit time_t and
39 * the build only supports 32, assume the test as success
41 need64bit = (int)strtol(test_get_argument(3), NULL, 0);
42 have64bit = sizeof(time_t) > sizeof(uint32_t);
43 if (need64bit && !have64bit) {
44 BIO_printf(bio_out, "skipping test (need64bit: %i, have64bit: %i)",
45 need64bit, have64bit);
49 testdate = test_get_argument(2);
50 testdateutc = ossl_asn1_string_to_time_t(testdate);
51 if (TEST_time_t_lt(testdateutc, 0)) {
55 indexfile = test_get_argument(1);
56 db = load_index(indexfile, NULL);
57 if (TEST_ptr_null(db)) {
63 rv = do_updatedb(db, &testdateutc);
67 if (!TEST_true(save_index(indexfile, "new", db)))
70 if (!TEST_true(rotate_index(indexfile, "new", "old")))
80 char *command = test_get_argument(0);
82 if (test_get_argument_count() < 1) {
83 TEST_error("%s: no command specified for testing\n", binname);
87 if (strcmp(command, "do_updatedb") == 0)
88 return test_do_updatedb();
90 TEST_error("%s: command '%s' is not supported for testing\n", binname, command);