Document OpenSSL::Test and OpenSSL::Test::Simple
[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", "des", "destest");
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
32 =over 4
33
34 =item B<simple_test NAME, PROGRAM, ALGORITHM>
35
36 Runs a test named NAME, running the program PROGRAM with no arguments,
37 to test the algorithm ALGORITHM.
38
39 A complete recipe looks like this:
40
41   use OpenSSL::Test::Simple;
42
43   simple_test("test_bf", "bftest", "bf");
44
45 =back
46
47 =cut
48
49 # args:
50 #  name                 (used with setup())
51 #  algorithm            (used to check if it's at all supported)
52 #  name of binary       (the program that does the actual test)
53 sub simple_test {
54     my ($name, $prgr, $algo, @rest) = @_;
55
56     setup($name);
57
58     plan tests => 1;
59   SKIP: {
60       skip "$algo is not supported by this OpenSSL build, skipping this test...", 1
61           if $algo && run(app(["openssl", "no-$algo"]));
62
63       ok(run(test([$prgr])), "running $prgr");
64     }
65 }
66
67 =head1 SEE ALSO
68
69 L<OpenSSL::Test>
70
71 =head1 AUTHORS
72
73 Richard Levitte E<lt>levitte@openssl.orgE<gt> with inspiration
74 from Rich Salz E<lt>rsalz@openssl.org<gt>.
75
76 =cut
77
78 1;