VirtualBox

source: vbox/trunk/src/libs/openssl-3.1.7/test/context_internal_test.c@ 106165

最後變更 在這個檔案從106165是 104078,由 vboxsync 提交於 8 月 前

openssl-3.1.5: Applied and adjusted our OpenSSL changes to 3.1.4. bugref:10638

檔案大小: 1.5 KB
 
1/*
2 * Copyright 2019-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/* Internal tests for the OpenSSL library context */
11
12#include "internal/cryptlib.h"
13#include "testutil.h"
14
15static int test_set0_default(void)
16{
17 OSSL_LIB_CTX *global = OSSL_LIB_CTX_get0_global_default();
18 OSSL_LIB_CTX *local = OSSL_LIB_CTX_new();
19 OSSL_LIB_CTX *prev;
20 int testresult = 0;
21
22 if (!TEST_ptr(global)
23 || !TEST_ptr(local)
24 || !TEST_ptr_eq(global, OSSL_LIB_CTX_set0_default(NULL)))
25 goto err;
26
27 /* Check we can change the local default context */
28 if (!TEST_ptr(prev = OSSL_LIB_CTX_set0_default(local))
29 || !TEST_ptr_eq(global, prev))
30 goto err;
31
32 /* Calling OSSL_LIB_CTX_set0_default() with a NULL should be a no-op */
33 if (!TEST_ptr_eq(local, OSSL_LIB_CTX_set0_default(NULL)))
34 goto err;
35
36 /* Global default should be unchanged */
37 if (!TEST_ptr_eq(global, OSSL_LIB_CTX_get0_global_default()))
38 goto err;
39
40 /* Check we can swap back to the global default */
41 if (!TEST_ptr(prev = OSSL_LIB_CTX_set0_default(global))
42 || !TEST_ptr_eq(local, prev))
43 goto err;
44
45 testresult = 1;
46 err:
47 OSSL_LIB_CTX_free(local);
48 return testresult;
49}
50
51int setup_tests(void)
52{
53 ADD_TEST(test_set0_default);
54 return 1;
55}
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

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