VirtualBox

source: vbox/trunk/src/libs/openssl-3.3.2/test/provider_default_search_path_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
檔案大小: 1.9 KB
 
1/*
2 * Copyright 2020-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 <stddef.h>
11#include <openssl/provider.h>
12#include "testutil.h"
13
14static int test_default_libctx(void)
15{
16 OSSL_LIB_CTX *ctx = NULL;
17 char *path = "./some/path";
18 const char *retrieved_path = NULL;
19 int ok;
20
21 ok = TEST_true(OSSL_PROVIDER_set_default_search_path(ctx, path))
22 && TEST_ptr(retrieved_path = OSSL_PROVIDER_get0_default_search_path(ctx))
23 && TEST_str_eq(path, retrieved_path);
24
25 return ok;
26}
27
28static int test_explicit_libctx(void)
29{
30 OSSL_LIB_CTX *ctx = NULL;
31 char *def_libctx_path = "./some/path";
32 char *path = "./another/location";
33 const char *retrieved_defctx_path = NULL;
34 const char *retrieved_path = NULL;
35 int ok;
36
37 /* Set search path for default context, then create a new context and set
38 another path for it. Finally, get both paths and make sure they are
39 still what we set and are separate. */
40 ok = TEST_true(OSSL_PROVIDER_set_default_search_path(NULL, def_libctx_path))
41 && TEST_ptr(ctx = OSSL_LIB_CTX_new())
42 && TEST_true(OSSL_PROVIDER_set_default_search_path(ctx, path))
43 && TEST_ptr(retrieved_defctx_path = OSSL_PROVIDER_get0_default_search_path(NULL))
44 && TEST_str_eq(def_libctx_path, retrieved_defctx_path)
45 && TEST_ptr(retrieved_path = OSSL_PROVIDER_get0_default_search_path(ctx))
46 && TEST_str_eq(path, retrieved_path)
47 && TEST_str_ne(retrieved_path, retrieved_defctx_path);
48
49 OSSL_LIB_CTX_free(ctx);
50 return ok;
51}
52
53int setup_tests(void)
54{
55 ADD_TEST(test_default_libctx);
56 ADD_TEST(test_explicit_libctx);
57 return 1;
58}
59
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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