diff options
author | Matt Caswell <matt@openssl.org> | 2024-05-13 11:45:24 +0200 |
---|---|---|
committer | Tomas Mraz <tomas@openssl.org> | 2024-05-15 12:14:24 +0200 |
commit | 50153ad2bb767a6e79e5c0c569f136f723a32700 (patch) | |
tree | 157fac8b69c44a4e1809aea3cc637383b8b55f20 /test/sysdefaulttest.c | |
parent | Document that SHAKE-128 and SHAKE-256 have no default digest length (diff) | |
download | openssl-50153ad2bb767a6e79e5c0c569f136f723a32700.tar.xz openssl-50153ad2bb767a6e79e5c0c569f136f723a32700.zip |
Suppress a spurious error from the sysdefault test
Running the sysdefault test results in spurious error output - even
though the test has actually passed
Fixes #24383
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/24384)
Diffstat (limited to 'test/sysdefaulttest.c')
-rw-r--r-- | test/sysdefaulttest.c | 54 |
1 files changed, 47 insertions, 7 deletions
diff --git a/test/sysdefaulttest.c b/test/sysdefaulttest.c index 5cd09bd08c..0a46fc2d94 100644 --- a/test/sysdefaulttest.c +++ b/test/sysdefaulttest.c @@ -16,19 +16,28 @@ #include <openssl/tls1.h> #include "testutil.h" +static int expect_failure = 0; static int test_func(void) { - int ret = 1; + int ret = 0; SSL_CTX *ctx; - if (!TEST_ptr(ctx = SSL_CTX_new(TLS_method()))) - return 0; - if (!TEST_int_eq(SSL_CTX_get_min_proto_version(ctx), TLS1_2_VERSION) - && !TEST_int_eq(SSL_CTX_get_max_proto_version(ctx), TLS1_2_VERSION)) { - TEST_info("min/max version setting incorrect"); - ret = 0; + ctx = SSL_CTX_new(TLS_method()); + if (expect_failure) { + if (!TEST_ptr_null(ctx)) + goto err; + } else { + if (!TEST_ptr(ctx)) + return 0; + if (!TEST_int_eq(SSL_CTX_get_min_proto_version(ctx), TLS1_2_VERSION) + && !TEST_int_eq(SSL_CTX_get_max_proto_version(ctx), TLS1_2_VERSION)) { + TEST_info("min/max version setting incorrect"); + goto err; + } } + ret = 1; + err: SSL_CTX_free(ctx); return ret; } @@ -41,8 +50,39 @@ int global_init(void) return 1; } +typedef enum OPTION_choice { + OPT_ERR = -1, + OPT_EOF = 0, + OPT_FAIL, + OPT_TEST_ENUM +} OPTION_CHOICE; + +const OPTIONS *test_get_options(void) +{ + static const OPTIONS test_options[] = { + OPT_TEST_OPTIONS_DEFAULT_USAGE, + { "f", OPT_FAIL, '-', "A failure is expected" }, + { NULL } + }; + return test_options; +} + int setup_tests(void) { + OPTION_CHOICE o; + + while ((o = opt_next()) != OPT_EOF) { + switch (o) { + case OPT_FAIL: + expect_failure = 1; + break; + case OPT_TEST_CASES: + break; + default: + return 0; + } + } + ADD_TEST(test_func); return 1; } |