summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPauli <pauli@openssl.org>2021-05-13 02:34:42 +0200
committerPauli <pauli@openssl.org>2021-05-13 06:22:20 +0200
commit9a633a1c97e387157560641c4f7043efe52dba6b (patch)
tree71b07cbe70d2b12161dbee2a69b892da5c401cc3
parentEVP_PKEY-X25519.pod: Correct EVP_PKEY_Q_keygen function name in example (diff)
downloadopenssl-9a633a1c97e387157560641c4f7043efe52dba6b.tar.xz
openssl-9a633a1c97e387157560641c4f7043efe52dba6b.zip
test: fix thread test config file problem
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)
-rw-r--r--test/recipes/90-test_threads.t10
-rw-r--r--test/threadstest.c15
2 files changed, 17 insertions, 8 deletions
diff --git a/test/recipes/90-test_threads.t b/test/recipes/90-test_threads.t
index 53883ee629..a841a4b2f5 100644
--- a/test/recipes/90-test_threads.t
+++ b/test/recipes/90-test_threads.t
@@ -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");
}
diff --git a/test/threadstest.c b/test/threadstest.c
index 9d15a23d96..359b330024 100644
--- a/test/threadstest.c
+++ b/test/threadstest.c
@@ -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: