xref: /netbsd-src/crypto/external/bsd/openssl.old/dist/util/perl/OpenSSL/Test/Simple.pm (revision 4724848cf0da353df257f730694b7882798e5daf)
1*4724848cSchristos# Copyright 2016 The OpenSSL Project Authors. All Rights Reserved.
2*4724848cSchristos#
3*4724848cSchristos# Licensed under the OpenSSL license (the "License").  You may not use
4*4724848cSchristos# this file except in compliance with the License.  You can obtain a copy
5*4724848cSchristos# in the file LICENSE in the source distribution or at
6*4724848cSchristos# https://www.openssl.org/source/license.html
7*4724848cSchristos
8*4724848cSchristospackage OpenSSL::Test::Simple;
9*4724848cSchristos
10*4724848cSchristosuse strict;
11*4724848cSchristosuse warnings;
12*4724848cSchristos
13*4724848cSchristosuse Exporter;
14*4724848cSchristosuse vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
15*4724848cSchristos$VERSION = "0.2";
16*4724848cSchristos@ISA = qw(Exporter);
17*4724848cSchristos@EXPORT = qw(simple_test);
18*4724848cSchristos
19*4724848cSchristos=head1 NAME
20*4724848cSchristos
21*4724848cSchristosOpenSSL::Test::Simple - a few very simple test functions
22*4724848cSchristos
23*4724848cSchristos=head1 SYNOPSIS
24*4724848cSchristos
25*4724848cSchristos  use OpenSSL::Test::Simple;
26*4724848cSchristos
27*4724848cSchristos  simple_test("my_test_name", "destest", "des");
28*4724848cSchristos
29*4724848cSchristos=head1 DESCRIPTION
30*4724848cSchristos
31*4724848cSchristosSometimes, the functions in L<OpenSSL::Test> are quite tedious for some
32*4724848cSchristosrepetitive tasks.  This module provides functions to make life easier.
33*4724848cSchristosYou could call them hacks if you wish.
34*4724848cSchristos
35*4724848cSchristos=cut
36*4724848cSchristos
37*4724848cSchristosuse OpenSSL::Test;
38*4724848cSchristosuse OpenSSL::Test::Utils;
39*4724848cSchristos
40*4724848cSchristos=over 4
41*4724848cSchristos
42*4724848cSchristos=item B<simple_test NAME, PROGRAM, ALGORITHM>
43*4724848cSchristos
44*4724848cSchristosRuns a test named NAME, running the program PROGRAM with no arguments,
45*4724848cSchristosto test the algorithm ALGORITHM.
46*4724848cSchristos
47*4724848cSchristosA complete recipe looks like this:
48*4724848cSchristos
49*4724848cSchristos  use OpenSSL::Test::Simple;
50*4724848cSchristos
51*4724848cSchristos  simple_test("test_bf", "bftest", "bf");
52*4724848cSchristos
53*4724848cSchristos=back
54*4724848cSchristos
55*4724848cSchristos=cut
56*4724848cSchristos
57*4724848cSchristos# args:
58*4724848cSchristos#  name			(used with setup())
59*4724848cSchristos#  algorithm		(used to check if it's at all supported)
60*4724848cSchristos#  name of binary	(the program that does the actual test)
61*4724848cSchristossub simple_test {
62*4724848cSchristos    my ($name, $prgr, @algos) = @_;
63*4724848cSchristos
64*4724848cSchristos    setup($name);
65*4724848cSchristos
66*4724848cSchristos    if (scalar(disabled(@algos))) {
67*4724848cSchristos	if (scalar(@algos) == 1) {
68*4724848cSchristos	    plan skip_all => $algos[0]." is not supported by this OpenSSL build";
69*4724848cSchristos	} else {
70*4724848cSchristos	    my $last = pop @algos;
71*4724848cSchristos	    plan skip_all => join(", ", @algos)." and $last are not supported by this OpenSSL build";
72*4724848cSchristos	}
73*4724848cSchristos    }
74*4724848cSchristos
75*4724848cSchristos    plan tests => 1;
76*4724848cSchristos
77*4724848cSchristos    ok(run(test([$prgr])), "running $prgr");
78*4724848cSchristos}
79*4724848cSchristos
80*4724848cSchristos=head1 SEE ALSO
81*4724848cSchristos
82*4724848cSchristosL<OpenSSL::Test>
83*4724848cSchristos
84*4724848cSchristos=head1 AUTHORS
85*4724848cSchristos
86*4724848cSchristosRichard Levitte E<lt>levitte@openssl.orgE<gt> with inspiration
87*4724848cSchristosfrom Rich Salz E<lt>rsalz@openssl.orgE<gt>.
88*4724848cSchristos
89*4724848cSchristos=cut
90*4724848cSchristos
91*4724848cSchristos1;
92