]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/testlib/OpenSSL/Test/Utils.pm
1 package OpenSSL
::Test
::Utils
;
7 use vars
qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
10 @EXPORT = qw(alldisabled anydisabled disabled config available_protocols);
14 OpenSSL::Test::Utils - test utility functions
18 use OpenSSL::Test::Utils;
20 my @tls = available_protocols("tls");
21 my @dtls = available_protocols("dtls");
22 alldisabled("dh", "dsa");
23 anydisabled("dh", "dsa");
29 This module provides utility functions for the testing framework.
33 use OpenSSL
::Test qw
/:DEFAULT top_file/;
37 =item B<available_protocols STRING>
39 Returns a list of strings for all the available SSL/TLS versions if
40 STRING is "tls", or for all the available DTLS versions if STRING is
41 "dtls". Otherwise, it returns the empty list. The strings in the
42 returned list can be used with B<alldisabled> and B<anydisabled>.
44 =item B<alldisabled ARRAY>
45 =item B<anydisabled ARRAY>
47 In an array context returns an array with each element set to 1 if the
48 corresponding feature is disabled and 0 otherwise.
50 In a scalar context, alldisabled returns 1 if all of the features in
51 ARRAY are disabled, while anydisabled returns 1 if any of them are
54 =item B<config STRING>
56 Returns an item from the %config hash in \$TOP/configdata.pm.
62 our %available_protocols;
65 my $configdata_loaded = 0;
68 # We eval it so it doesn't run at compile time of this file.
69 # The latter would have top_dir() complain that setup() hasn't
71 my $configdata = top_file
("configdata.pm");
72 eval { require $configdata;
73 %available_protocols = %configdata::available_protocols
;
74 %disabled = %configdata::disabled
;
75 %config = %configdata::config
;
77 $configdata_loaded = 1;
81 # list of 1s and 0s, coming from check_disabled()
84 foreach (@_) { $x += $_ }
89 # list of 1s and 0s, coming from check_disabled()
92 foreach (@_) { $x *= $_ }
97 # list of strings, all of them should be names of features
98 # that can be disabled.
99 # returns a list of 1s (if the corresponding feature is disabled)
100 # and 0s (if it isn't)
102 return map { exists $disabled{lc $_} ?
1 : 0 } @_;
105 # Exported functions #################################################
108 # list of features to check
110 load_configdata
() unless $configdata_loaded;
111 my @ret = check_disabled
(@_);
112 return @ret if wantarray;
117 # list of features to check
119 load_configdata
() unless $configdata_loaded;
120 my @ret = check_disabled
(@_);
121 return @ret if wantarray;
125 #!!! Kept for backward compatibility
132 sub available_protocols
{
133 my $protocol_class = shift;
134 if (exists $available_protocols{lc $protocol_class}) {
135 return @
{$available_protocols{lc $protocol_class}}
141 return $config{$_[0]};
150 Stephen Henson E<lt>steve@openssl.orgE<gt> and
151 Richard Levitte E<lt>levitte@openssl.orgE<gt>