X-Git-Url: https://git.openssl.org/gitweb/?p=openssl.git;a=blobdiff_plain;f=test%2Frecipes%2F15-test_genec.t;h=d4547e5849695ab6f34b4ed222be00a08d9326f7;hp=b778d6f536237321dd1d7bcf86a9716f359e980c;hb=c65b1d02528cef3e819a02a60a616dba9d28adca;hpb=0c2bddb76a6aa7cad1f3689586040af074ad7e2b 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])); + } } }