]> git.ipfire.org Git - thirdparty/openssl.git/blame - test/recipes/20-test_enc.t
unified build scheme: adjust some scripts
[thirdparty/openssl.git] / test / recipes / 20-test_enc.t
CommitLineData
13350a0c
RL
1#! /usr/bin/perl
2
3use strict;
4use warnings;
5
6use File::Spec::Functions qw/catfile/;
7use File::Copy;
8use File::Compare qw/compare_text/;
9use File::Basename;
13350a0c
RL
10use OpenSSL::Test qw/:DEFAULT top_file/;
11
12setup("test_enc");
13
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.
17my $testsrc = top_file("test","recipes",basename($0));
18
19my $test = catfile(".", "p");
20
21my $cmd = "openssl";
22
23my @ciphers =
85833408 24 map { s/^\s+//; s/\s+$//; split /\s+/ }
13350a0c
RL
25 run(app([$cmd, "list", "-cipher-commands"]), capture => 1);
26
27plan tests => 1 + (scalar @ciphers)*2;
28
29my $init = ok(copy($testsrc,$test));
30
31if (!$init) {
32 diag("Trying to copy $testsrc to $test : $!");
33}
34
35 SKIP: {
36 skip "Not initialized, skipping...", 11 unless $init;
37
38 foreach my $c (@ciphers) {
39 my %variant = ("$c" => [],
40 "$c base64" => [ "-a" ]);
41
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" );
47 if ($c eq "cat") {
48 $cipherfile = "$test.cipher";
49 $clearfile = "$test.clear";
50 @e = ( "enc", @{$variant{$t}}, "-e" );
51 @d = ( "enc", @{$variant{$t}}, "-d" );
52 }
53
9b56815d
RL
54 ok(run(app([$cmd, @e, "-in", $test, "-out", $cipherfile]))
55 && run(app([$cmd, @d, "-in", $cipherfile, "-out", $clearfile]))
13350a0c
RL
56 && compare_text($test,$clearfile) == 0, $t);
57 unlink $cipherfile, $clearfile;
58 }
59 }
60}
61
62unlink $test;