mirror of
https://github.com/openssl/openssl.git
synced 2025-02-17 14:32:04 +08:00
test: fix problem with threads test using default library context.
Also add a new test that deliberately tests the default library context. Fixes #14720 Reviewed-by: Matt Caswell <matt@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14773)
This commit is contained in:
parent
860ecfd700
commit
a135dea4e0
@ -348,7 +348,7 @@ static void thread_general_worker(void)
|
|||||||
|
|
||||||
static void thread_multi_simple_fetch(void)
|
static void thread_multi_simple_fetch(void)
|
||||||
{
|
{
|
||||||
EVP_MD *md = EVP_MD_fetch(NULL, "SHA2-256", NULL);
|
EVP_MD *md = EVP_MD_fetch(multi_libctx, "SHA2-256", NULL);
|
||||||
|
|
||||||
if (md != NULL)
|
if (md != NULL)
|
||||||
EVP_MD_free(md);
|
EVP_MD_free(md);
|
||||||
@ -501,6 +501,7 @@ static int test_multi(int idx)
|
|||||||
OSSL_LIB_CTX_free(multi_libctx);
|
OSSL_LIB_CTX_free(multi_libctx);
|
||||||
EVP_PKEY_free(shared_evp_pkey);
|
EVP_PKEY_free(shared_evp_pkey);
|
||||||
shared_evp_pkey = NULL;
|
shared_evp_pkey = NULL;
|
||||||
|
multi_libctx = NULL;
|
||||||
return testresult;
|
return testresult;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -532,6 +533,36 @@ static int test_multi_load(void)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int test_multi_default(void)
|
||||||
|
{
|
||||||
|
thread_t thread1, thread2;
|
||||||
|
int testresult = 0;
|
||||||
|
OSSL_PROVIDER *prov = NULL;
|
||||||
|
|
||||||
|
multi_success = 1;
|
||||||
|
multi_libctx = NULL;
|
||||||
|
prov = OSSL_PROVIDER_load(multi_libctx, "default");
|
||||||
|
if (!TEST_ptr(prov))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
if (!TEST_true(run_thread(&thread1, thread_multi_simple_fetch))
|
||||||
|
|| !TEST_true(run_thread(&thread2, thread_multi_simple_fetch)))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
thread_multi_simple_fetch();
|
||||||
|
|
||||||
|
if (!TEST_true(wait_for_thread(thread1))
|
||||||
|
|| !TEST_true(wait_for_thread(thread2))
|
||||||
|
|| !TEST_true(multi_success))
|
||||||
|
goto err;
|
||||||
|
|
||||||
|
testresult = 1;
|
||||||
|
|
||||||
|
err:
|
||||||
|
OSSL_PROVIDER_unload(prov);
|
||||||
|
return testresult;
|
||||||
|
}
|
||||||
|
|
||||||
typedef enum OPTION_choice {
|
typedef enum OPTION_choice {
|
||||||
OPT_ERR = -1,
|
OPT_ERR = -1,
|
||||||
OPT_EOF = 0,
|
OPT_EOF = 0,
|
||||||
@ -573,6 +604,9 @@ int setup_tests(void)
|
|||||||
if (!TEST_ptr(privkey))
|
if (!TEST_ptr(privkey))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
/* Keep first to validate auto creation of default library context */
|
||||||
|
ADD_TEST(test_multi_default);
|
||||||
|
|
||||||
ADD_TEST(test_lock);
|
ADD_TEST(test_lock);
|
||||||
ADD_TEST(test_once);
|
ADD_TEST(test_once);
|
||||||
ADD_TEST(test_thread_local);
|
ADD_TEST(test_thread_local);
|
||||||
|
Loading…
Reference in New Issue
Block a user