From: Richard Levitte Date: Tue, 9 Jun 2020 10:29:27 +0000 (+0200) Subject: TEST: Add TODO segments in test/recipes/15-test_genec.t X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c65b1d02528cef3e819a02a60a616dba9d28adca;p=oweals%2Fopenssl.git TEST: Add TODO segments in test/recipes/15-test_genec.t There currently do not support 'ec_param_enc:explicit' with provider side key generation. Reflect that by encoding the expected failure with a Test::More TODO section for those particular tests. Because the tests in this recipe are data driven, we implement this mechanism with two functions, one for stuff that's supported and one for stuff that isn't. Reviewed-by: Nicola Tuveri (Merged from https://github.com/openssl/openssl/pull/12080) --- diff --git a/test/recipes/15-test_genec.t b/test/recipes/15-test_genec.t index b778d6f536..d4547e5849 100644 --- a/test/recipes/15-test_genec.t +++ b/test/recipes/15-test_genec.t @@ -14,6 +14,31 @@ use File::Spec; use OpenSSL::Test qw/:DEFAULT srctop_file/; use OpenSSL::Test::Utils; +# 'supported' and 'unsupported' reflect the current state of things. In +# Test::More terms, 'supported' works exactly like ok(run(whatever)), while +# 'unsupported' wraps that in a TODO: { } block. +# +# The first argument is the test name (this becomes the last argument to +# 'ok') +# The remaining argument are passed unchecked to 'run'. + +# 1: the result of app() or similar, i.e. something you can pass to +sub supported { + my $str = shift; + + ok(run(@_), $str); +} + +sub unsupported { + my $str = shift; + TODO: { + local $TODO = "Currently not supported"; + + ok(run(@_), $str); + } +} + + setup("test_genec"); plan skip_all => "This test is unsupported in a no-ec build" @@ -137,35 +162,40 @@ push(@curve_list, @binary_curves) push(@curve_list, @other_curves); push(@curve_list, @curve_aliases); -my @params_encodings = ('named_curve', 'explicit'); +my %params_encodings = + ( + 'named_curve' => \&supported, + 'explicit' => \&unsupported + ); my @output_formats = ('PEM', 'DER'); -plan tests => scalar(@curve_list) * scalar(@params_encodings) +plan tests => scalar(@curve_list) * scalar(keys %params_encodings) * (1 + scalar(@output_formats)) # Try listed @output_formats and text output + 1 # Checking that with no curve it fails + 1 # Checking that with unknown curve it fails ; foreach my $curvename (@curve_list) { - foreach my $paramenc (@params_encodings) { - ok(run(app([ 'openssl', 'genpkey', - '-algorithm', 'EC', - '-pkeyopt', 'ec_paramgen_curve:'.$curvename, - '-pkeyopt', 'ec_param_enc:'.$paramenc, - '-text'])), - "genpkey EC params ${curvename} with ec_param_enc:'${paramenc}' (text)"); + foreach my $paramenc (sort keys %params_encodings) { + my $fn = $params_encodings{$paramenc}; + $fn->("genpkey EC params ${curvename} with ec_param_enc:'${paramenc}' (text)", + app([ 'openssl', 'genpkey', + '-algorithm', 'EC', + '-pkeyopt', 'ec_paramgen_curve:'.$curvename, + '-pkeyopt', 'ec_param_enc:'.$paramenc, + '-text'])); foreach my $outform (@output_formats) { my $outfile = "ecgen.${curvename}.${paramenc}." . lc $outform; - ok(run(app([ 'openssl', 'genpkey', '-genparam', - '-algorithm', 'EC', - '-pkeyopt', 'ec_paramgen_curve:'.$curvename, - '-pkeyopt', 'ec_param_enc:'.$paramenc, - '-outform', $outform, - '-out', $outfile])), - "genpkey EC params ${curvename} with ec_param_enc:'${paramenc}' (${outform})"); - } + $fn->("genpkey EC params ${curvename} with ec_param_enc:'${paramenc}' (${outform})", + app([ 'openssl', 'genpkey', '-genparam', + '-algorithm', 'EC', + '-pkeyopt', 'ec_paramgen_curve:'.$curvename, + '-pkeyopt', 'ec_param_enc:'.$paramenc, + '-outform', $outform, + '-out', $outfile])); + } } }