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