[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Tue Jan 26 08:54:46 UTC 2016


The branch master has been updated
       via  90d48e5ea006c759888f7302ccc94fede3ca224a (commit)
       via  96d2d7bc71a8413f23ff9fc88f600acc4c340a9b (commit)
      from  36b82b346454b4d0d0c4c19e0e9ca9e888f23a3e (commit)


- Log -----------------------------------------------------------------
commit 90d48e5ea006c759888f7302ccc94fede3ca224a
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Jan 26 02:11:55 2016 +0100

    Use the new OpenSSL::Test::Utils routines.
    
    Reviewed-by: Viktor Dukhovni <viktor at openssl.org>

commit 96d2d7bc71a8413f23ff9fc88f600acc4c340a9b
Author: Richard Levitte <levitte at openssl.org>
Date:   Tue Jan 26 02:09:33 2016 +0100

    Use Configure's @disablables and %disabled through configdata.pm
    
    Enhances the routines in OpenSSL::Test::Utils for checking disabled
    stuff to get their information directly from Configure instead of
    'openssl list -disabled'.
    
    Reviewed-by: Viktor Dukhovni <viktor at openssl.org>

-----------------------------------------------------------------------

Summary of changes:
 Configure                             |  15 +++++
 test/recipes/70-test_sslcertstatus.t  |   2 +-
 test/recipes/70-test_sslextension.t   |   2 +-
 test/recipes/70-test_sslsessiontick.t |   2 +-
 test/recipes/70-test_sslskewith0p.t   |   2 +-
 test/recipes/70-test_sslvertol.t      |   2 +-
 test/recipes/70-test_tlsextms.t       |   2 +-
 test/recipes/80-test_ssl.t            |  10 +--
 test/testlib/OpenSSL/Test/Utils.pm    | 121 ++++++++++++++++++++++++----------
 9 files changed, 113 insertions(+), 45 deletions(-)

diff --git a/Configure b/Configure
index 0a07174..9dc6343 100755
--- a/Configure
+++ b/Configure
@@ -1311,6 +1311,21 @@ print OUT <<"EOF";
 );
 
 EOF
+print OUT "our \%available_protocols = (\n";
+print OUT "  tls => [ ", join(", ", map { quotify("perl", $_) } @tls), " ],\n";
+print OUT "  dtls => [ ", join(", ", map { quotify("perl", $_) } @dtls), " ],\n";
+print OUT <<"EOF";
+);
+
+EOF
+print OUT "our \%disabled = (\n";
+foreach (sort keys %disabled) {
+    print OUT "  ", quotify("perl", $_), " => ", quotify("perl", $disabled{$_}), ",\n";
+}
+print OUT <<"EOF";
+);
+
+EOF
 print OUT "our %withargs = (\n";
 foreach (sort keys %withargs) {
     if (ref($withargs{$_}) eq "ARRAY") {
diff --git a/test/recipes/70-test_sslcertstatus.t b/test/recipes/70-test_sslcertstatus.t
index f7c6363..814ca0a 100755
--- a/test/recipes/70-test_sslcertstatus.t
+++ b/test/recipes/70-test_sslcertstatus.t
@@ -67,7 +67,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
     if disabled("engine");
 
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
-    if config("no_shared");
+    if disabled("shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
diff --git a/test/recipes/70-test_sslextension.t b/test/recipes/70-test_sslextension.t
index 31632a7..3c9caad 100755
--- a/test/recipes/70-test_sslextension.t
+++ b/test/recipes/70-test_sslextension.t
@@ -67,7 +67,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
     if disabled("engine");
 
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
-    if config("no_shared");
+    if disabled("shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
diff --git a/test/recipes/70-test_sslsessiontick.t b/test/recipes/70-test_sslsessiontick.t
index 84ab661..7e5ccad 100755
--- a/test/recipes/70-test_sslsessiontick.t
+++ b/test/recipes/70-test_sslsessiontick.t
@@ -68,7 +68,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
     if disabled("engine");
 
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
-    if config("no_shared");
+    if disabled("shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
diff --git a/test/recipes/70-test_sslskewith0p.t b/test/recipes/70-test_sslskewith0p.t
index 39c0409..8261238 100755
--- a/test/recipes/70-test_sslskewith0p.t
+++ b/test/recipes/70-test_sslskewith0p.t
@@ -67,7 +67,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
     if disabled("engine");
 
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
-    if config("no_shared");
+    if disabled("shared");
 
 plan skip_all => "dh is not supported by this OpenSSL build"
     if disabled("dh");
diff --git a/test/recipes/70-test_sslvertol.t b/test/recipes/70-test_sslvertol.t
index c711d86..e5eef31 100755
--- a/test/recipes/70-test_sslvertol.t
+++ b/test/recipes/70-test_sslvertol.t
@@ -67,7 +67,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
     if disabled("engine");
 
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
-    if config("no_shared");
+    if disabled("shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
diff --git a/test/recipes/70-test_tlsextms.t b/test/recipes/70-test_tlsextms.t
index a861064..8e3b414 100644
--- a/test/recipes/70-test_tlsextms.t
+++ b/test/recipes/70-test_tlsextms.t
@@ -68,7 +68,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
     if disabled("engine");
 
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
-    if config("no_shared");
+    if disabled("shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
diff --git a/test/recipes/80-test_ssl.t b/test/recipes/80-test_ssl.t
index 54259e1..e7472a2 100644
--- a/test/recipes/80-test_ssl.t
+++ b/test/recipes/80-test_ssl.t
@@ -14,11 +14,11 @@ setup("test_ssl");
 my ($no_rsa, $no_dsa, $no_dh, $no_ec, $no_srp, $no_psk,
     $no_ssl3, $no_tls1, $no_tls1_1, $no_tls1_2,
     $no_dtls, $no_dtls1, $no_dtls1_2) =
-    disabled qw/rsa dsa dh ec srp psk
-                ssl3 tls1 tls1_1 tls1_2
-                dtls dtls1 dtls1_2/;
-my $no_anytls = $no_ssl3 && $no_tls1 && $no_tls1_1 && $no_tls1_2;
-my $no_anydtls = $no_dtls && $no_dtls1 && $no_dtls1_2;
+    anydisabled qw/rsa dsa dh ec srp psk
+                   ssl3 tls1 tls1_1 tls1_2
+                   dtls dtls1 dtls1_2/;
+my $no_anytls = alldisabled(available_protocols("tls"));
+my $no_anydtls = alldisabled(available_protocols("dtls"));
 
 plan skip_all => "No SSL/TLS/DTLS protocol is support by this OpenSSL build"
     if $no_anytls && $no_anydtls;
diff --git a/test/testlib/OpenSSL/Test/Utils.pm b/test/testlib/OpenSSL/Test/Utils.pm
index eed4424..c024832 100644
--- a/test/testlib/OpenSSL/Test/Utils.pm
+++ b/test/testlib/OpenSSL/Test/Utils.pm
@@ -7,7 +7,7 @@ use Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 $VERSION = "0.1";
 @ISA = qw(Exporter);
- at EXPORT = qw(disabled config);
+ at EXPORT = qw(alldisabled anydisabled disabled config available_protocols);
 
 =head1 NAME
 
@@ -17,9 +17,12 @@ OpenSSL::Test::Utils - test utility functions
 
   use OpenSSL::Test::Utils;
 
-  disabled("dh");
+  my @tls = available_protocols("tls");
+  my @dtls = available_protocols("dtls");
+  alldisabled("dh", "dsa");
+  anydisabled("dh", "dsa");
 
-  config("no_shared");
+  config("fips");
 
 =head1 DESCRIPTION
 
@@ -31,13 +34,23 @@ use OpenSSL::Test qw/:DEFAULT top_file/;
 
 =over 4
 
-=item B<disabled ARRAY>
+=item B<available_protocols STRING>
 
-In a scalar context returns 1 if any of the features in ARRAY is disabled.
+Returns a list of strings for all the available SSL/TLS versions if
+STRING is "tls", or for all the available DTLS versions if STRING is
+"dtls".  Otherwise, it returns the empty list.  The strings in the
+returned list can be used with B<alldisabled> and B<anydisabled>.
+
+=item B<alldisabled ARRAY>
+=item B<anydisabled ARRAY>
 
 In an array context returns an array with each element set to 1 if the
 corresponding feature is disabled and 0 otherwise.
 
+In a scalar context, alldisabled returns 1 if all of the features in
+ARRAY are disabled, while anydisabled returns 1 if any of them are
+disabled.
+
 =item B<config STRING>
 
 Returns an item from the %config hash in \$TOP/configdata.pm.
@@ -46,45 +59,85 @@ Returns an item from the %config hash in \$TOP/configdata.pm.
 
 =cut
 
+our %available_protocols;
 our %disabled;
-my $disabled_set = 0;
+our %config;
+my $configdata_loaded = 0;
+
+sub load_configdata {
+    # We eval it so it doesn't run at compile time of this file.
+    # The latter would have top_dir() complain that setup() hasn't
+    # been run yet.
+    my $configdata = top_file("configdata.pm");
+    eval { require $configdata;
+	   %available_protocols = %configdata::available_protocols;
+	   %disabled = %configdata::disabled;
+	   %config = %configdata::config;
+    };
+    $configdata_loaded = 1;
+}
+
+# args
+#  list of 1s and 0s, coming from check_disabled()
+sub anyof {
+    my $x = 0;
+    foreach (@_) { $x += $_ }
+    return $x > 0;
+}
 
+# args
+#  list of 1s and 0s, coming from check_disabled()
+sub allof {
+    my $x = 1;
+    foreach (@_) { $x *= $_ }
+    return $x > 0;
+}
+
+# args
+#  list of strings, all of them should be names of features
+#  that can be disabled.
+# returns a list of 1s (if the corresponding feature is disabled)
+#  and 0s (if it isn't)
 sub check_disabled {
-#print STDERR "Running check_disabled\n";
-    foreach (run(app(["openssl", "list", "-disabled"]), capture => 1)) {
-        s/\R//;         # chomp;
-        next if /:/;    # skip header
-        $disabled{lc $_} = 1;
-    }
-    $disabled_set = 1;
+    return map { exists $disabled{lc $_} ? 1 : 0 } @_;
+}
+
+# Exported functions #################################################
+
+# args:
+#  list of features to check
+sub anydisabled {
+    load_configdata() unless $configdata_loaded;
+    my @ret = check_disabled(@_);
+    return @ret if wantarray;
+    return anyof(@ret);
 }
 
 # args:
 #  list of features to check
+sub alldisabled {
+    load_configdata() unless $configdata_loaded;
+    my @ret = check_disabled(@_);
+    return @ret if wantarray;
+    return allof(@ret);
+}
+
+#!!! Kept for backward compatibility
+# args:
+#  single string
 sub disabled {
-    check_disabled() unless $disabled_set;
-    if (wantarray) {
-        my @ret;
-        foreach (@_) {
-            push @ret, exists $disabled{lc $_} ? 1 : 0;
-        }
-        return @ret;
-    }
-    foreach (@_) {
-        return 1 if exists $disabled{lc $_};
+    anydisabled(@_);
+}
+
+sub available_protocols {
+    my $protocol_class = shift;
+    if (exists $available_protocols{lc $protocol_class}) {
+	return @{$available_protocols{lc $protocol_class}}
     }
-    return 0;
+    return ();
 }
 
-our %config;
 sub config {
-    if (!%config) {
-	# We eval it so it doesn't run at compile time of this file.
-	# The latter would have top_dir() complain that setup() hasn't
-	# been run yet.
-	my $configdata = top_file("configdata.pm");
-	eval { require $configdata; %config = %configdata::config };
-    }
     return $config{$_[0]};
 }
 
@@ -94,8 +147,8 @@ L<OpenSSL::Test>
 
 =head1 AUTHORS
 
-Stephen Henson E<lt>steve at openssl.orgE<gt> with inspiration
-from Richard Levitte E<lt>levitte at openssl.orgE<gt>
+Stephen Henson E<lt>steve at openssl.orgE<gt> and
+Richard Levitte E<lt>levitte at openssl.orgE<gt>
 
 =cut
 


More information about the openssl-commits mailing list