diff options
author | Matt Caswell <matt@openssl.org> | 2021-11-09 18:31:24 +0000 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2021-11-12 17:16:14 +0000 |
commit | 293e251e6f0367a9aa0d3d46037b19d1a6c91b20 (patch) | |
tree | 75fe203b89e0064ca35be817c6a46891463b6844 /test/threadstest.c | |
parent | addbd7c9d784e1cb630d43487b0572e867bfc86d (diff) |
Extend the test_multi_load() test
Run more threads and load the legacy provider (which uses a child lib ctx)
in order to hit more possible thread failures.
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/16980)
Diffstat (limited to 'test/threadstest.c')
-rw-r--r-- | test/threadstest.c | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/test/threadstest.c b/test/threadstest.c index f689676c54..cfd5991770 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -30,7 +30,7 @@ #include "threadstest.h" /* Limit the maximum number of threads */ -#define MAXIMUM_THREADS 3 +#define MAXIMUM_THREADS 10 /* Limit the maximum number of providers loaded into a library context */ #define MAXIMUM_PROVIDERS 4 @@ -558,6 +558,7 @@ static int test_multi_load_unload_provider(void) return testresult; } +static char *multi_load_provider = "legacy"; /* * This test attempts to load several providers at the same time, and if * run with a thread sanitizer, should crash if the core provider code @@ -567,7 +568,7 @@ static void test_multi_load_worker(void) { OSSL_PROVIDER *prov; - if (!TEST_ptr(prov = OSSL_PROVIDER_load(multi_libctx, "default")) + if (!TEST_ptr(prov = OSSL_PROVIDER_load(multi_libctx, multi_load_provider)) || !TEST_true(OSSL_PROVIDER_unload(prov))) multi_success = 0; } @@ -588,6 +589,7 @@ static int test_multi_default(void) static int test_multi_load(void) { int res = 1; + OSSL_PROVIDER *prov; /* The multidefault test must run prior to this test */ if (!multidefault_run) { @@ -595,7 +597,21 @@ static int test_multi_load(void) res = test_multi_default(); } - return thread_run_test(NULL, 3, &test_multi_load_worker, 0, NULL) && res; + /* + * We use the legacy provider in test_multi_load_worker because it uses a + * child libctx that might hit more codepaths that might be sensitive to + * threading issues. But in a no-legacy build that won't be loadable so + * we use the default provider instead. + */ + prov = OSSL_PROVIDER_load(NULL, "legacy"); + if (prov == NULL) { + TEST_info("Cannot load legacy provider - assuming this is a no-legacy build"); + multi_load_provider = "default"; + } + OSSL_PROVIDER_unload(prov); + + return thread_run_test(NULL, MAXIMUM_THREADS, &test_multi_load_worker, 0, + NULL) && res; } static void test_obj_create_one(void) |