diff options
Diffstat (limited to 'test/threadstest.c')
-rw-r--r-- | test/threadstest.c | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/test/threadstest.c b/test/threadstest.c index faa9e2728c..3d7324cf6c 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -1014,6 +1014,45 @@ static int test_multi_shared_pkey(void) return test_multi_shared_pkey_common(&thread_shared_evp_pkey); } +static void thread_release_shared_pkey(void) +{ + OSSL_sleep(0); + EVP_PKEY_free(shared_evp_pkey); +} + +static int test_multi_shared_pkey_release(void) +{ + int testresult = 0; + size_t i = 1; + + multi_intialise(); + shared_evp_pkey = NULL; + if (!thread_setup_libctx(1, do_fips ? fips_and_default_providers + : default_provider) + || !TEST_ptr(shared_evp_pkey = load_pkey_pem(privkey, multi_libctx))) + goto err; + for (; i < 10; ++i) { + if (!TEST_true(EVP_PKEY_up_ref(shared_evp_pkey))) + goto err; + } + + if (!start_threads(10, &thread_release_shared_pkey)) + goto err; + i = 0; + + if (!teardown_threads() + || !TEST_true(multi_success)) + goto err; + testresult = 1; + err: + while (i > 0) { + EVP_PKEY_free(shared_evp_pkey); + --i; + } + thead_teardown_libctx(); + return testresult; +} + static int test_multi_load_unload_provider(void) { EVP_MD *sha256 = NULL; @@ -1306,6 +1345,7 @@ int setup_tests(void) #ifndef OPENSSL_NO_DEPRECATED_3_0 ADD_TEST(test_multi_downgrade_shared_pkey); #endif + ADD_TEST(test_multi_shared_pkey_release); ADD_TEST(test_multi_load_unload_provider); ADD_TEST(test_obj_add); #if !defined(OPENSSL_NO_DGRAM) && !defined(OPENSSL_NO_SOCK) |