aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMatt Caswell <matt@openssl.org>2024-05-13 10:45:24 +0100
committerTomas Mraz <tomas@openssl.org>2024-05-15 12:14:24 +0200
commit50153ad2bb767a6e79e5c0c569f136f723a32700 (patch)
tree157fac8b69c44a4e1809aea3cc637383b8b55f20 /test
parentad3f28c5fbd5dcbc763a650313fd666b0e339cca (diff)
downloadopenssl-50153ad2bb767a6e79e5c0c569f136f723a32700.zip
openssl-50153ad2bb767a6e79e5c0c569f136f723a32700.tar.gz
openssl-50153ad2bb767a6e79e5c0c569f136f723a32700.tar.bz2
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')
-rw-r--r--test/recipes/90-test_sysdefault.t2
-rw-r--r--test/sysdefaulttest.c54
2 files changed, 48 insertions, 8 deletions
diff --git a/test/recipes/90-test_sysdefault.t b/test/recipes/90-test_sysdefault.t
index 6984bc1..8ed323c 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 5cd09bd..0a46fc2 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;
}