From: Pauli Date: Wed, 30 Jun 2021 01:13:35 +0000 (+1000) Subject: test: fix test ordering in threads test X-Git-Tag: openssl-3.0.0-beta2~147 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=b9bc8eb0546b22d7b23b25dc62eb5a459f745b98;p=thirdparty%2Fopenssl.git test: fix test ordering in threads test Fixes #15953 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/15954) --- diff --git a/test/threadstest.c b/test/threadstest.c index ce31738189c..3160d9e334c 100644 --- a/test/threadstest.c +++ b/test/threadstest.c @@ -25,6 +25,7 @@ static int do_fips = 0; static char *privkey; static char *config_file = NULL; +static int multidefault_run = 0; static int test_lock(void) { @@ -477,26 +478,19 @@ static void test_multi_load_worker(void) (void)TEST_true(OSSL_PROVIDER_unload(prov)); } -static int test_multi_load(void) -{ - thread_t threads[MULTI_LOAD_THREADS]; - int i; - - for (i = 0; i < MULTI_LOAD_THREADS; i++) - (void)TEST_true(run_thread(&threads[i], test_multi_load_worker)); - - for (i = 0; i < MULTI_LOAD_THREADS; i++) - (void)TEST_true(wait_for_thread(threads[i])); - - return 1; -} - static int test_multi_default(void) { thread_t thread1, thread2; int testresult = 0; OSSL_PROVIDER *prov = NULL; + /* Avoid running this test twice */ + if (multidefault_run) { + TEST_skip("multi default test already run"); + return 1; + } + multidefault_run = 1; + multi_success = 1; multi_libctx = NULL; prov = OSSL_PROVIDER_load(multi_libctx, "default"); @@ -521,6 +515,26 @@ static int test_multi_default(void) return testresult; } +static int test_multi_load(void) +{ + thread_t threads[MULTI_LOAD_THREADS]; + int i, res = 1; + + /* The multidefault test must run prior to this test */ + if (!multidefault_run) { + TEST_info("Running multi default test first"); + res = test_multi_default(); + } + + for (i = 0; i < MULTI_LOAD_THREADS; i++) + (void)TEST_true(run_thread(&threads[i], test_multi_load_worker)); + + for (i = 0; i < MULTI_LOAD_THREADS; i++) + (void)TEST_true(wait_for_thread(threads[i])); + + return res; +} + typedef enum OPTION_choice { OPT_ERR = -1, OPT_EOF = 0,