6 use File::Compare qw/compare_text/;
10 use OpenSSL::Test qw/:DEFAULT top_file/;
12 my %conversionforms = (
14 x509 => [ "d", "n", "p" ],
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",
57 stdout => "$testtype-f.$to")), "p -> $to");
60 foreach my $to (@conversionforms) {
61 foreach my $from (@conversionforms) {
63 "-in", "$testtype-f.$from",
66 stdout => "$testtype-ff.$from$to")), "$from -> $to");
70 if ($testtype ne "p7d") {
71 is(compare_text("$testtype-fff.p", "$testtype-f.p"), 0,
72 'comparing orig to p');
75 foreach my $to (@conversionforms) {
77 foreach my $from (@conversionforms) {
78 is(compare_text("$testtype-f.$to", "$testtype-ff.$from$to"), 0,
79 "comparing $to to $from$to");
83 unlink glob "$testtype-f.*";
84 unlink glob "$testtype-ff.*";
85 unlink glob "$testtype-fff.*";