]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: fix test ordering in threads test
authorPauli <pauli@openssl.org>
Wed, 30 Jun 2021 01:13:35 +0000 (11:13 +1000)
committerPauli <pauli@openssl.org>
Wed, 30 Jun 2021 07:54:45 +0000 (17:54 +1000)
Fixes #15953

Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/15954)

test/threadstest.c

index ce31738189cbf5eef5c148bf4bcf495e71186fc5..3160d9e334c603f63e8dff7b372776f135d7f8af 100644 (file)
@@ -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,