summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-09 10:57:05 +1000
committerPauli <ppzgs1@gmail.com>2021-03-11 09:25:57 +1000
commit903a6558471812c8884a8ba279ad96dc29ccd4b0 (patch)
treec012d6966deb76f81bccffe63992bb0244b04941
parent925b5360f7ae234b5103effd1e0d713575906421 (diff)
downloadopenssl-new-903a6558471812c8884a8ba279ad96dc29ccd4b0.tar.gz
test: convert store test to use relative paths
Reviewed-by: Tomas Mraz <tomas@openssl.org> (Merged from https://github.com/openssl/openssl/pull/14419)
-rw-r--r--test/ossl_store_test.c34
-rw-r--r--test/recipes/66-test_ossl_store.t5
2 files changed, 31 insertions, 8 deletions
diff --git a/test/ossl_store_test.c b/test/ossl_store_test.c
index e06c0b55de..773c696fec 100644
--- a/test/ossl_store_test.c
+++ b/test/ossl_store_test.c
@@ -23,12 +23,16 @@
typedef enum OPTION_choice {
OPT_ERR = -1,
OPT_EOF = 0,
+ OPT_INPUTDIR,
OPT_INFILE,
+ OPT_SM2FILE,
OPT_DATADIR,
OPT_TEST_ENUM
} OPTION_CHOICE;
+static const char *inputdir = NULL;
static const char *infile = NULL;
+static const char *sm2file = NULL;
static const char *datadir = NULL;
static int test_store_open(void)
@@ -37,16 +41,19 @@ static int test_store_open(void)
OSSL_STORE_CTX *sctx = NULL;
OSSL_STORE_SEARCH *search = NULL;
UI_METHOD *ui_method = NULL;
+ char *input = test_mk_file_path(inputdir, infile);
- ret = TEST_ptr(search = OSSL_STORE_SEARCH_by_alias("nothing"))
+ ret = TEST_ptr(input)
+ && TEST_ptr(search = OSSL_STORE_SEARCH_by_alias("nothing"))
&& TEST_ptr(ui_method= UI_create_method("DummyUI"))
- && TEST_ptr(sctx = OSSL_STORE_open_ex(infile, NULL, NULL, ui_method,
+ && TEST_ptr(sctx = OSSL_STORE_open_ex(input, NULL, NULL, ui_method,
NULL, NULL, NULL))
&& TEST_false(OSSL_STORE_find(sctx, NULL))
&& TEST_true(OSSL_STORE_find(sctx, search));
UI_destroy_method(ui_method);
OSSL_STORE_SEARCH_free(search);
OSSL_STORE_close(sctx);
+ OPENSSL_free(input);
return ret;
}
@@ -159,6 +166,7 @@ static int test_store_attach_unregistered_scheme(void)
OSSL_STORE_close(store_ctx);
OSSL_PROVIDER_unload(provider);
OSSL_LIB_CTX_free(libctx);
+ OPENSSL_free(input);
return ret;
}
@@ -166,7 +174,9 @@ const OPTIONS *test_get_options(void)
{
static const OPTIONS test_options[] = {
OPT_TEST_OPTIONS_DEFAULT_USAGE,
- { "in", OPT_INFILE, '<', },
+ { "dir", OPT_INPUTDIR, '/' },
+ { "in", OPT_INFILE, '<' },
+ { "sm2", OPT_SM2FILE, '<' },
{ "data", OPT_DATADIR, 's' },
{ NULL }
};
@@ -179,9 +189,15 @@ int setup_tests(void)
while ((o = opt_next()) != OPT_EOF) {
switch (o) {
+ case OPT_INPUTDIR:
+ inputdir = opt_arg();
+ break;
case OPT_INFILE:
infile = opt_arg();
break;
+ case OPT_SM2FILE:
+ sm2file = opt_arg();
+ break;
case OPT_DATADIR:
datadir = opt_arg();
break;
@@ -194,13 +210,19 @@ int setup_tests(void)
}
if (datadir == NULL) {
- TEST_error("No datadir specified");
+ TEST_error("No data directory specified");
+ return 0;
+ }
+ if (inputdir == NULL) {
+ TEST_error("No input directory specified");
return 0;
}
- ADD_TEST(test_store_open);
+ if (infile != NULL)
+ ADD_TEST(test_store_open);
ADD_TEST(test_store_search_by_key_fingerprint_fail);
ADD_ALL_TESTS(test_store_get_params, 3);
- ADD_TEST(test_store_attach_unregistered_scheme);
+ if (sm2file != NULL)
+ ADD_TEST(test_store_attach_unregistered_scheme);
return 1;
}
diff --git a/test/recipes/66-test_ossl_store.t b/test/recipes/66-test_ossl_store.t
index 08d66977a5..0385e452b7 100644
--- a/test/recipes/66-test_ossl_store.t
+++ b/test/recipes/66-test_ossl_store.t
@@ -10,11 +10,12 @@ use strict;
use warnings;
use OpenSSL::Test::Simple;
-use OpenSSL::Test qw/:DEFAULT srctop_file data_dir/;
+use OpenSSL::Test qw/:DEFAULT srctop_dir data_dir/;
setup("test_ossl_store");
plan tests => 1;
-ok(run(test(["ossl_store_test", "-in", srctop_file("test", "testrsa.pem"),
+ok(run(test(["ossl_store_test", "-dir", srctop_dir("test"),
+ "-in", "testrsa.pem", "-sm2", "certs/sm2-root.crt",
"-data", data_dir()])));