6 use File::Compare qw/compare_text/;
9 use OpenSSL::Test qw/:DEFAULT/;
11 my %conversionforms = (
12 # Default conversion forms. Other series may be added with
13 # specific test types as key.
20 defined($conversionforms{$testtype}) ?
21 @{$conversionforms{$testtype}} :
22 @{$conversionforms{"*"}};
23 my @openssl_args = @_;
24 if (!@openssl_args) { @openssl_args = ($testtype); }
26 my $n = scalar @conversionforms;
29 + $n # initial conversions from p to all forms (A)
30 + $n*$n # conversion from result of A to all forms (B)
31 + 1 # comparing original test file to p form of A
32 + $n*($n-1); # comparing first conversion to each fom in A with B
33 $totaltests-- if ($testtype eq "p7d"); # no comparison of original test file
34 plan tests => $totaltests;
36 my @cmd = ("openssl", @openssl_args);
39 if (scalar @openssl_args > 0 && $openssl_args[0] eq "pkey") {
40 $init = ok(run(app([@cmd, "-in", $t, "-out", "$testtype-fff.p"])),
43 $init = ok(copy($t, "$testtype-fff.p"), 'initializing');
46 diag("Trying to copy $t to $testtype-fff.p : $!");
50 skip "Not initialized, skipping...", 22 unless $init;
52 foreach my $to (@conversionforms) {
54 "-in", "$testtype-fff.p",
56 "-out", "$testtype-f.$to",
61 foreach my $to (@conversionforms) {
62 foreach my $from (@conversionforms) {
64 "-in", "$testtype-f.$from",
66 "-out", "$testtype-ff.$from$to",
72 if ($testtype ne "p7d") {
73 is(cmp_text("$testtype-fff.p", "$testtype-f.p"), 0,
74 'comparing orig to p');
77 foreach my $to (@conversionforms) {
79 foreach my $from (@conversionforms) {
80 is(cmp_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0,
81 "comparing $to to $from$to");
85 unlink glob "$testtype-f.*";
86 unlink glob "$testtype-ff.*";
87 unlink glob "$testtype-fff.*";
91 return compare_text(@_, sub {
94 return $_[0] ne $_[1];