]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
test: fix thread test config file problem
authorPauli <pauli@openssl.org>
Thu, 13 May 2021 00:34:42 +0000 (10:34 +1000)
committerPauli <pauli@openssl.org>
Thu, 13 May 2021 04:22:20 +0000 (14:22 +1000)
Force the thread test to use the configuration file via a command line arg.
Use the test library support for libctx creation.

Fixes #15243

Reviewed-by: Shane Lontis <shane.lontis@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/15256)

test/recipes/90-test_threads.t
test/threadstest.c

index 53883ee629fd558af72ad7559bbcaf9b8e0d333b..a841a4b2f5930f8d0e598e1fb2c4c38cf5b1fa3d 100644 (file)
@@ -20,13 +20,15 @@ use lib srctop_dir('Configurations');
 use lib bldtop_dir('.');
 
 my $no_fips = disabled('fips') || ($ENV{NO_FIPS} // 0);
+my $config_path = abs_path(srctop_file("test", $no_fips ? "default.cnf"
+                                                        : "default-and-fips.cnf"));
 
 plan tests => 1;
 
 if ($no_fips) {
-    $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "default.cnf"));
-    ok(run(test(["threadstest", data_dir()])), "running test_threads");
+    ok(run(test(["threadstest", "-config", $config_path, data_dir()])),
+       "running test_threads");
 } else {
-    $ENV{OPENSSL_CONF} = abs_path(srctop_file("test", "default-and-fips.cnf"));
-    ok(run(test(["threadstest", "-fips", data_dir()])), "running test_threads");
+    ok(run(test(["threadstest", "-fips", "-config", $config_path, data_dir()])),
+       "running test_threads with FIPS");
 }
index 9d15a23d9608e82b17097485421ad7ab38fff9bb..359b330024a8f8ecbe6e2eee93d95c7e42965cde 100644 (file)
@@ -23,6 +23,7 @@
 
 static int do_fips = 0;
 static char *privkey;
+static char *config_file = NULL;
 
 #if !defined(OPENSSL_THREADS) || defined(CRYPTO_TDEBUG)
 
@@ -450,9 +451,10 @@ static int test_multi(int idx)
 #endif
 
     multi_success = 1;
-    multi_libctx = OSSL_LIB_CTX_new();
-    if (!TEST_ptr(multi_libctx))
-        goto err;
+    if (!TEST_true(test_get_libctx(&multi_libctx, NULL, config_file,
+                                   NULL, NULL)))
+        return 0;
+
     prov = OSSL_PROVIDER_load(multi_libctx, (idx == 1) ? "fips" : "default");
     if (!TEST_ptr(prov))
         goto err;
@@ -583,7 +585,7 @@ static int test_multi_default(void)
 typedef enum OPTION_choice {
     OPT_ERR = -1,
     OPT_EOF = 0,
-    OPT_FIPS,
+    OPT_FIPS, OPT_CONFIG_FILE,
     OPT_TEST_ENUM
 } OPTION_CHOICE;
 
@@ -592,6 +594,8 @@ const OPTIONS *test_get_options(void)
     static const OPTIONS options[] = {
         OPT_TEST_OPTIONS_DEFAULT_USAGE,
         { "fips", OPT_FIPS, '-', "Test the FIPS provider" },
+        { "config", OPT_CONFIG_FILE, '<',
+          "The configuration file to use for the libctx" },
         { NULL }
     };
     return options;
@@ -607,6 +611,9 @@ int setup_tests(void)
         case OPT_FIPS:
             do_fips = 1;
             break;
+        case OPT_CONFIG_FILE:
+            config_file = opt_arg();
+            break;
         case OPT_TEST_CASES:
             break;
         default: