diff options
author | Pauli <pauli@openssl.org> | 2021-04-27 07:29:16 +0200 |
---|---|---|
committer | Pauli <pauli@openssl.org> | 2021-05-07 15:53:18 +0200 |
commit | ced7df26382e7b1713ac6662958933d31151b4b8 (patch) | |
tree | 8cc39afae510d85cd256019d4307af871b6b2630 /test/provider_internal_test.c | |
parent | provider: flush the store cache when providers are loaded/unloaded. (diff) | |
download | openssl-ced7df26382e7b1713ac6662958933d31151b4b8.tar.xz openssl-ced7df26382e7b1713ac6662958933d31151b4b8.zip |
test: add a provider load/unload cache flush test.
Reviewed-by: Matt Caswell <matt@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15042)
Diffstat (limited to '')
-rw-r--r-- | test/provider_internal_test.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/provider_internal_test.c b/test/provider_internal_test.c index aeb38339fa..7bf2b8e272 100644 --- a/test/provider_internal_test.c +++ b/test/provider_internal_test.c @@ -85,6 +85,43 @@ static int test_configured_provider(void) } #endif +static int test_cache_flushes(void) +{ + OSSL_LIB_CTX *ctx; + OSSL_PROVIDER *prov = NULL; + EVP_MD *md = NULL; + int ret = 0; + + if (!TEST_ptr(ctx = OSSL_LIB_CTX_new()) + || !TEST_ptr(prov = OSSL_PROVIDER_load(ctx, "default")) + || !TEST_true(OSSL_PROVIDER_available(ctx, "default")) + || !TEST_ptr(md = EVP_MD_fetch(ctx, "SHA256", NULL))) + goto err; + EVP_MD_free(md); + md = NULL; + OSSL_PROVIDER_unload(prov); + prov = NULL; + + if (!TEST_false(OSSL_PROVIDER_available(ctx, "default"))) + goto err; + + if (!TEST_ptr_null(md = EVP_MD_fetch(ctx, "SHA256", NULL))) { + const char *provname = OSSL_PROVIDER_name(EVP_MD_provider(md)); + + if (OSSL_PROVIDER_available(NULL, provname)) + TEST_info("%s provider is available\n", provname); + else + TEST_info("%s provider is not available\n", provname); + } + + ret = 1; + err: + OSSL_PROVIDER_unload(prov); + EVP_MD_free(md); + OSSL_LIB_CTX_free(ctx); + return ret; +} + int setup_tests(void) { ADD_TEST(test_builtin_provider); @@ -92,6 +129,7 @@ int setup_tests(void) ADD_TEST(test_loaded_provider); ADD_TEST(test_configured_provider); #endif + ADD_TEST(test_cache_flushes); return 1; } |