From: Matt Caswell Date: Mon, 13 May 2024 09:45:24 +0000 (+0100) Subject: Suppress a spurious error from the sysdefault test X-Git-Tag: openssl-3.4.0-alpha1~546 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=50153ad2bb767a6e79e5c0c569f136f723a32700;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/24384) --- diff --git a/test/recipes/90-test_sysdefault.t b/test/recipes/90-test_sysdefault.t index 6984bc10673..8ed323c74e4 100644 --- a/test/recipes/90-test_sysdefault.t +++ b/test/recipes/90-test_sysdefault.t @@ -24,7 +24,7 @@ ok(run(test(["sysdefaulttest"])), "sysdefaulttest"); $ENV{OPENSSL_CONF} = data_file("sysdefault-bad.cnf"); -ok(!run(test(["sysdefaulttest"])), "sysdefaulttest"); +ok(run(test(["sysdefaulttest", "-f"])), "sysdefaulttest"); $ENV{OPENSSL_CONF} = data_file("sysdefault-ignore.cnf"); diff --git a/test/sysdefaulttest.c b/test/sysdefaulttest.c index 5cd09bd08c8..0a46fc2d94e 100644 --- a/test/sysdefaulttest.c +++ b/test/sysdefaulttest.c @@ -16,19 +16,28 @@ #include #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; }