Fix OpenSSL::Test::Simple to take more than one algorithm
[openssl.git] / test / testlib / OpenSSL / Test / Simple.pm
1 package OpenSSL::Test::Simple;
2
3 use strict;
4 use warnings;
5
6 use Exporter;
7 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
8 $VERSION = "0.2";
9 @ISA = qw(Exporter);
10 @EXPORT = qw(simple_test);
11
12 =head1 NAME
13
14 OpenSSL::Test::Simple - a few very simple test functions
15
16 =head1 SYNOPSIS
17
18   use OpenSSL::Test::Simple;
19
20   simple_test("my_test_name", "destest", "des");
21
22 =head1 DESCRIPTION
23
24 Sometimes, the functions in L<OpenSSL::Test> are quite tedious for some
25 repetitive tasks.  This module provides functions to make life easier.
26 You could call them hacks if you wish.
27
28 =cut
29
30 use OpenSSL::Test;
31 use OpenSSL::Test::Utils;
32
33 =over 4
34
35 =item B<simple_test NAME, PROGRAM, ALGORITHM>
36
37 Runs a test named NAME, running the program PROGRAM with no arguments,
38 to test the algorithm ALGORITHM.
39
40 A complete recipe looks like this:
41
42   use OpenSSL::Test::Simple;
43
44   simple_test("test_bf", "bftest", "bf");
45
46 =back
47
48 =cut
49
50 # args:
51 #  name                 (used with setup())
52 #  algorithm            (used to check if it's at all supported)
53 #  name of binary       (the program that does the actual test)
54 sub simple_test {
55     my ($name, $prgr, @algos) = @_;
56
57     setup($name);
58
59     if (scalar(disabled(@algos))) {
60         if (scalar(@algos) == 1) {
61             plan skip_all => $algos[0]." is not supported by this OpenSSL build";
62         } else {
63             my $last = pop @algos;
64             plan skip_all => join(", ", @algos)." and $last are not supported by this OpenSSL build";
65         }
66     }
67
68     plan tests => 1;
69
70     ok(run(test([$prgr])), "running $prgr");
71 }
72
73 =head1 SEE ALSO
74
75 L<OpenSSL::Test>
76
77 =head1 AUTHORS
78
79 Richard Levitte E<lt>levitte@openssl.orgE<gt> with inspiration
80 from Rich Salz E<lt>rsalz@openssl.orgE<gt>.
81
82 =cut
83
84 1;