6 use File::Spec::Functions qw/catfile/;
8 use File::Compare qw/compare_text/;
11 use OpenSSL::Test qw/:DEFAULT top_file/;
15 # We do it this way, because setup() may have moved us around,
16 # so the directory portion of $0 might not be correct any more.
17 # However, the name hasn't changed.
18 my $testsrc = top_file("test","recipes",basename($0));
20 my $test = catfile(".", "p");
25 map { chomp; s/^\s+//; s/\s+$//; split /\s+/ }
26 run(app([$cmd, "list", "-cipher-commands"]), capture => 1);
28 plan tests => 1 + (scalar @ciphers)*2;
30 my $init = ok(copy($testsrc,$test));
33 diag("Trying to copy $testsrc to $test : $!");
37 skip "Not initialized, skipping...", 11 unless $init;
39 foreach my $c (@ciphers) {
40 my %variant = ("$c" => [],
41 "$c base64" => [ "-a" ]);
43 foreach my $t (sort keys %variant) {
44 my $cipherfile = "$test.$c.cipher";
45 my $clearfile = "$test.$c.clear";
46 my @e = ( "$c", "-bufsize", "113", @{$variant{$t}}, "-e", "-k", "test" );
47 my @d = ( "$c", "-bufsize", "157", @{$variant{$t}}, "-d", "-k", "test" );
49 $cipherfile = "$test.cipher";
50 $clearfile = "$test.clear";
51 @e = ( "enc", @{$variant{$t}}, "-e" );
52 @d = ( "enc", @{$variant{$t}}, "-d" );
55 ok(run(app([$cmd, @e],
56 stdin => $test, stdout => $cipherfile))
57 && run(app([$cmd, @d],
58 stdin => $cipherfile, stdout => $clearfile))
59 && compare_text($test,$clearfile) == 0, $t);
60 unlink $cipherfile, $clearfile;