diff options
author | Neil Horman <nhorman@openssl.org> | 2024-04-03 15:18:33 -0400 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-04-18 18:39:48 +0200 |
commit | a15b30ec0bd7bcc9503ef1d201fdbc55332bf80e (patch) | |
tree | c49bb793def290d290b24e4a467c022b2c13fb9d /test/prov_config_test.c | |
parent | bad44bae8b9e7e853db96c6785633b21bf4e3e83 (diff) |
Add test for OSSL_PROVIDER_load with module path set
Ensure that, with the modulepath setting set in a config field, that we
are able to load a provider from the path relative to OPENSSL_MODULES
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24025)
(cherry picked from commit 91a77cbf66c575345cf1eab31717e8edafcd1633)
Diffstat (limited to 'test/prov_config_test.c')
-rw-r--r-- | test/prov_config_test.c | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/test/prov_config_test.c b/test/prov_config_test.c index b44ec78d8d..d59a954667 100644 --- a/test/prov_config_test.c +++ b/test/prov_config_test.c @@ -13,6 +13,7 @@ static char *configfile = NULL; static char *recurseconfigfile = NULL; +static char *pathedconfig = NULL; /* * Test to make sure there are no leaks or failures from loading the config @@ -70,6 +71,34 @@ static int test_recursive_config(void) return testresult; } +#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACOSX) && !defined(NO_PROVIDER_MODULE) +static int test_path_config(void) +{ + OSSL_LIB_CTX *ctx = OSSL_LIB_CTX_new(); + OSSL_PROVIDER *prov; + int testresult = 0; + + if (!TEST_ptr(pathedconfig)) + return 0; + if (!TEST_ptr(ctx)) + return 0; + + if (!TEST_true(OSSL_LIB_CTX_load_config(ctx, pathedconfig))) + goto err; + + /* attempt to manually load the test provider */ + if (!TEST_ptr(prov = OSSL_PROVIDER_load(ctx, "test"))) + goto err; + + OSSL_PROVIDER_unload(prov); + + testresult = 1; + err: + OSSL_LIB_CTX_free(ctx); + return testresult; +} +#endif + OPT_TEST_DECLARE_USAGE("configfile\n") int setup_tests(void) @@ -85,7 +114,20 @@ int setup_tests(void) if (!TEST_ptr(recurseconfigfile = test_get_argument(1))) return 0; + if (!TEST_ptr(pathedconfig = test_get_argument(2))) + return 0; + ADD_TEST(test_recursive_config); ADD_TEST(test_double_config); +#if !defined(OPENSSL_SYS_WINDOWS) && !defined(OPENSSL_SYS_MACOSX) && !defined(NO_PROVIDER_MODULE) + /* + * This test has to specify a module path to a file + * Which is setup as ../test/p_test.so + * Since windows/macos doesn't build with that extension + * just skip the test here + * Additionally skip it if we're not building provider modules + */ + ADD_TEST(test_path_config); +#endif return 1; } |