summaryrefslogtreecommitdiffstats
path: root/test/property_test.c
diff options
context:
space:
mode:
authorPauli <ppzgs1@gmail.com>2021-03-13 10:34:49 +1000
committerPauli <ppzgs1@gmail.com>2021-03-16 09:19:20 +1000
commit1e08f3ba9ec495fbd4a4cd6a411dc4e052626eda (patch)
tree5f63db4a780d59bb20bb60a78fd221cf7a880e4e /test/property_test.c
parentbd55a0be1b5696f643863718e7aa916feccafdf4 (diff)
property: default queries create the property values.
Without this, it is necessary to query an algorithm before setting the default property query. With this, the value will be created and the default will work. Fixes #14516 Reviewed-by: Shane Lontis <shane.lontis@oracle.com> (Merged from https://github.com/openssl/openssl/pull/14542)
Diffstat (limited to 'test/property_test.c')
-rw-r--r--test/property_test.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/test/property_test.c b/test/property_test.c
index ab61d01107..add16ea629 100644
--- a/test/property_test.c
+++ b/test/property_test.c
@@ -114,7 +114,7 @@ static int test_property_parse(int n)
&& add_property_names("sky", "groan", "cold", "today", "tomorrow", "n",
NULL)
&& TEST_ptr(p = ossl_parse_property(NULL, parser_tests[n].defn))
- && TEST_ptr(q = ossl_parse_query(NULL, parser_tests[n].query))
+ && TEST_ptr(q = ossl_parse_query(NULL, parser_tests[n].query, 0))
&& TEST_int_eq(ossl_property_match_count(q, p), parser_tests[n].e))
r = 1;
ossl_property_free(p);
@@ -123,6 +123,27 @@ static int test_property_parse(int n)
return r;
}
+static int test_property_query_value_create(void)
+{
+ OSSL_METHOD_STORE *store;
+ OSSL_PROPERTY_LIST *p = NULL, *q = NULL, *o = NULL;
+ int r = 0;
+
+ if (TEST_ptr(store = ossl_method_store_new(NULL))
+ && add_property_names("sky", NULL)
+ && TEST_ptr(p = ossl_parse_query(NULL, "sky=green", 0)) /* undefined */
+ && TEST_ptr(q = ossl_parse_query(NULL, "sky=green", 1)) /* creates */
+ && TEST_ptr(o = ossl_parse_query(NULL, "sky=green", 0)) /* defined */
+ && TEST_int_eq(ossl_property_match_count(q, p), -1)
+ && TEST_int_eq(ossl_property_match_count(q, o), 1))
+ r = 1;
+ ossl_property_free(o);
+ ossl_property_free(p);
+ ossl_property_free(q);
+ ossl_method_store_free(store);
+ return r;
+}
+
static const struct {
const char *q_global;
const char *q_local;
@@ -160,8 +181,9 @@ static int test_property_merge(int n)
&& add_property_names("colour", "urn", "clouds", "pot", "day", "night",
NULL)
&& TEST_ptr(prop = ossl_parse_property(NULL, merge_tests[n].prop))
- && TEST_ptr(q_global = ossl_parse_query(NULL, merge_tests[n].q_global))
- && TEST_ptr(q_local = ossl_parse_query(NULL, merge_tests[n].q_local))
+ && TEST_ptr(q_global = ossl_parse_query(NULL, merge_tests[n].q_global,
+ 0))
+ && TEST_ptr(q_local = ossl_parse_query(NULL, merge_tests[n].q_local, 0))
&& TEST_ptr(q_combined = ossl_property_merge(q_local, q_global))
&& TEST_int_ge(ossl_property_match_count(q_combined, prop), 0))
r = 1;
@@ -220,7 +242,7 @@ static int test_definition_compares(int n)
r = TEST_ptr(store = ossl_method_store_new(NULL))
&& add_property_names("alpha", "omega", NULL)
&& TEST_ptr(d = ossl_parse_property(NULL, definition_tests[n].defn))
- && TEST_ptr(q = ossl_parse_query(NULL, definition_tests[n].query))
+ && TEST_ptr(q = ossl_parse_query(NULL, definition_tests[n].query, 0))
&& TEST_int_eq(ossl_property_match_count(q, d), definition_tests[n].e);
ossl_property_free(d);
@@ -416,6 +438,7 @@ err:
int setup_tests(void)
{
ADD_TEST(test_property_string);
+ ADD_TEST(test_property_query_value_create);
ADD_ALL_TESTS(test_property_parse, OSSL_NELEM(parser_tests));
ADD_ALL_TESTS(test_property_merge, OSSL_NELEM(merge_tests));
ADD_TEST(test_property_defn_cache);