]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Suppress a spurious error from the sysdefault test
authorMatt Caswell <matt@openssl.org>
Mon, 13 May 2024 09:45:24 +0000 (10:45 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 15 May 2024 10:14:24 +0000 (12:14 +0200)
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)

test/recipes/90-test_sysdefault.t
test/sysdefaulttest.c

index 6984bc10673eb0e0cab20e2eee1e17500e9a2d3c..8ed323c74e4a1797e5dca1dc4db291c0287b7114 100644 (file)
@@ -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");
 
index 5cd09bd08c84e2251b45267841c1aa2bc6124ee8..0a46fc2d94e76ea41e5c1e2e2b72b08a68b675f2 100644 (file)
 #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;
 }