VirtualBox

source: vbox/trunk/src/libs/openssl-3.3.2/test/ca_internals_test.c@ 108358

最後變更 在這個檔案從108358是 108206,由 vboxsync 提交於 5 週 前

openssl-3.3.2: Exported all files to OSE and removed .scm-settings ​bugref:10757

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 2.3 KB
 
1/*
2 * Copyright 2021-2022 The OpenSSL Project Authors. All Rights Reserved.
3 *
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
8 */
9
10#include <string.h>
11#include "apps.h"
12#include "testutil.h"
13#include "crypto/asn1.h"
14
15#define binname "ca_internals_test"
16
17char *default_config_file = NULL;
18
19static int test_do_updatedb(void)
20{
21 CA_DB *db = NULL;
22 time_t testdateutc;
23 int rv;
24 size_t argc = test_get_argument_count();
25 BIO *bio_tmp;
26 char *testdate;
27 char *indexfile;
28 int need64bit;
29 int have64bit;
30
31 if (argc != 4) {
32 TEST_error("Usage: %s: do_updatedb dbfile testdate need64bit\n", binname);
33 TEST_error(" testdate format: ASN1-String\n");
34 return 0;
35 }
36
37 /*
38 * if the test will only work with 64bit time_t and
39 * the build only supports 32, assume the test as success
40 */
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);
46 return 1;
47 }
48
49 testdate = test_get_argument(2);
50 testdateutc = ossl_asn1_string_to_time_t(testdate);
51 if (TEST_time_t_lt(testdateutc, 0)) {
52 return 0;
53 }
54
55 indexfile = test_get_argument(1);
56 db = load_index(indexfile, NULL);
57 if (TEST_ptr_null(db)) {
58 return 0;
59 }
60
61 bio_tmp = bio_err;
62 bio_err = bio_out;
63 rv = do_updatedb(db, &testdateutc);
64 bio_err = bio_tmp;
65
66 if (rv > 0) {
67 if (!TEST_true(save_index(indexfile, "new", db)))
68 goto end;
69
70 if (!TEST_true(rotate_index(indexfile, "new", "old")))
71 goto end;
72 }
73end:
74 free_index(db);
75 return 1;
76}
77
78int setup_tests(void)
79{
80 char *command = test_get_argument(0);
81
82 if (test_get_argument_count() < 1) {
83 TEST_error("%s: no command specified for testing\n", binname);
84 return 0;
85 }
86
87 if (strcmp(command, "do_updatedb") == 0)
88 return test_do_updatedb();
89
90 TEST_error("%s: command '%s' is not supported for testing\n", binname, command);
91 return 0;
92}
93
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette