From ff5a272e605633b9cba30ee9440cf05b90e903d9 Mon Sep 17 00:00:00 2001 From: Matt Caswell Date: Tue, 1 Apr 2025 10:32:00 +0100 Subject: [PATCH] Detect segfault in the pkeyutl test Some tests are expected to fail in the pkeyutl test. However, if a segfault occurs then that counts as a failure and the test passes. A segfault should never be a "pass". Reviewed-by: Dmitry Belyavskiy Reviewed-by: Paul Dale Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/27228) --- test/recipes/20-test_pkeyutl.t | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/test/recipes/20-test_pkeyutl.t b/test/recipes/20-test_pkeyutl.t index 2dc22e0c6e9..31e46c6d99b 100644 --- a/test/recipes/20-test_pkeyutl.t +++ b/test/recipes/20-test_pkeyutl.t @@ -11,7 +11,7 @@ use warnings; use File::Spec; use File::Basename; -use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips/; +use OpenSSL::Test qw/:DEFAULT srctop_file ok_nofips with/; use OpenSSL::Test::Utils; use File::Compare qw/compare_text compare/; @@ -68,9 +68,13 @@ SKIP: { '-inkey', srctop_file('test', 'certs', 'server-ed25519-cert.pem'), '-sigfile', 'Ed25519.sig']))), "Verify an Ed25519 signature against a piece of data"); - ok(!run(app(([ 'openssl', 'pkeyutl', '-verifyrecover', '-in', 'Ed25519.sig', - '-inkey', srctop_file('test', 'certs', 'server-ed25519-key.pem')]))), - "Cannot use -verifyrecover with EdDSA"); + #Check for failure return code + with({ exit_checker => sub { return shift == 1; } }, + sub { + ok(run(app(([ 'openssl', 'pkeyutl', '-verifyrecover', '-in', 'Ed25519.sig', + '-inkey', srctop_file('test', 'certs', 'server-ed25519-key.pem')]))), + "Cannot use -verifyrecover with EdDSA"); + }); # Ed448 ok(run(app(([ 'openssl', 'pkeyutl', '-sign', '-in', @@ -123,8 +127,12 @@ sub tsignverify { '-out', $sigfile, '-in', $data_to_sign); push(@args, @extraopts); - ok(!run(app([@args])), - $testtext.": Checking that mismatching keyform fails"); + #Check for failure return code + with({ exit_checker => sub { return shift == 1; } }, + sub { + ok(run(app([@args])), + $testtext.": Checking that mismatching keyform fails"); + }); @args = ('openssl', 'pkeyutl', '-verify', '-inkey', $privkey, @@ -148,8 +156,12 @@ sub tsignverify { '-sigfile', $sigfile, '-in', $other_data); push(@args, @extraopts); - ok(!run(app([@args])), - $testtext.": Expect failure verifying mismatching data"); + #Check for failure return code + with({ exit_checker => sub { return shift == 1; } }, + sub { + ok(run(app([@args])), + $testtext.": Expect failure verifying mismatching data"); + }); } SKIP: { -- 2.47.2