summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2021-03-30 12:27:44 +1000
committerPauli <pauli@openssl.org>2021-04-08 17:46:35 +1000
commita135dea4e024ea6750be25859c1d613789a4d575 (patch)
treec32c72cae5da843bb19ce9979cd42b9845c2f4ca
parent860ecfd70022fa5700c7fb129845129b4c674ecd (diff)
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)
-rw-r--r--test/threadstest.c36
1 files changed, 35 insertions, 1 deletions
diff --git a/test/threadstest.c b/test/threadstest.c
index 17b348b80c..83a3f978f9 100644
--- a/test/threadstest.c
+++ b/test/threadstest.c
@@ -348,7 +348,7 @@ static void thread_general_worker(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)
EVP_MD_free(md);
@@ -501,6 +501,7 @@ static int test_multi(int idx)
OSSL_LIB_CTX_free(multi_libctx);
EVP_PKEY_free(shared_evp_pkey);
shared_evp_pkey = NULL;
+ multi_libctx = NULL;
return testresult;
}
@@ -532,6 +533,36 @@ static int test_multi_load(void)
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 {
OPT_ERR = -1,
OPT_EOF = 0,
@@ -573,6 +604,9 @@ int setup_tests(void)
if (!TEST_ptr(privkey))
return 0;
+ /* Keep first to validate auto creation of default library context */
+ ADD_TEST(test_multi_default);
+
ADD_TEST(test_lock);
ADD_TEST(test_once);
ADD_TEST(test_thread_local);