Make tests use configdata.pm rather than parsing Makefile
authorRichard Levitte <richard@levitte.org>
Mon, 25 Jan 2016 14:48:35 +0000 (15:48 +0100)
committerRichard Levitte <richard@levitte.org>
Mon, 25 Jan 2016 16:53:55 +0000 (17:53 +0100)
Reviewed-by: Rich Salz <rsalz@openssl.org>
Configure
test/recipes/70-test_sslcertstatus.t
test/recipes/70-test_sslextension.t
test/recipes/70-test_sslsessiontick.t
test/recipes/70-test_sslskewith0p.t
test/recipes/70-test_sslvertol.t
test/recipes/70-test_tlsextms.t
test/testlib/OpenSSL/Test/Utils.pm

index 276a1438b8f9fc95ce455d35f9a4f6ee129b7c5c..e717eb3973d267734911fe83761873e307b40540 100755 (executable)
--- a/Configure
+++ b/Configure
@@ -187,7 +187,7 @@ my $nofipscanistercheck=0;
 my $baseaddr="0xFB00000";
 my $no_threads=0;
 my $threads=0;
-my $no_shared=0; # but "no-shared" is default
+$config{no_shared}=0; # but "no-shared" is default
 my $zlib=1;      # but "no-zlib" is default
 my $no_rfc3779=0;
 my $no_asm=0;
@@ -705,7 +705,7 @@ foreach (sort (keys %disabled))
        elsif (/^threads$/)
                { $no_threads = 1; }
        elsif (/^shared$/)
-               { $no_shared = 1; }
+               { $config{no_shared} = 1; }
        elsif (/^zlib$/)
                { $zlib = 0; }
        elsif (/^static-engine$/)
@@ -949,10 +949,10 @@ if (defined($disabled{"deprecated"})) {
 my $shared_mark = "";
 if ($target{shared_target} eq "")
        {
-       $no_shared_warn = 1 if !$no_shared && !$fips;
-       $no_shared = 1;
+       $no_shared_warn = 1 if !$config{no_shared} && !$fips;
+       $config{no_shared} = 1;
        }
-if (!$no_shared)
+if (!$config{no_shared})
        {
        if ($target{shared_cflag} ne "")
                {
@@ -963,7 +963,7 @@ if (!$no_shared)
 if ($target{build_scheme}->[0] ne "mk1mf")
        {
        # add {no-}static-engine to options to allow mkdef.pl to work without extra arguments
-       if ($no_shared)
+       if ($config{no_shared})
                {
                push @{$config{openssl_other_defines}}, "OPENSSL_NO_DYNAMIC_ENGINE";
                $config{options}.=" static-engine";
@@ -1067,7 +1067,7 @@ if (!$no_asm) {
     if ($target{md5_obj} =~ /\.o$/) {
        $cflags.=" -DMD5_ASM";
     }
-    $target{cast_obj}=$table{BASE}->{cast_obj} if (!$no_shared); # CAST assembler is not PIC
+    $target{cast_obj}=$table{BASE}->{cast_obj} if (!$config{no_shared}); # CAST assembler is not PIC
     if ($target{rmd160_obj} =~ /\.o$/) {
        $cflags.=" -DRMD160_ASM";
     }
@@ -1361,7 +1361,7 @@ while (<IN>)
        s/^BASEADDR=.*/BASEADDR=$baseaddr/;
        s/^SHLIB_TARGET=.*/SHLIB_TARGET=$target{shared_target}/;
        s/^SHLIB_MARK=.*/SHLIB_MARK=$shared_mark/;
-       s/^SHARED_LIBS=.*/SHARED_LIBS=\$(SHARED_CRYPTO) \$(SHARED_SSL)/ if (!$no_shared);
+       s/^SHARED_LIBS=.*/SHARED_LIBS=\$(SHARED_CRYPTO) \$(SHARED_SSL)/ if (!$config{no_shared});
        if ($target{shared_extension} ne "" && $target{shared_extension} =~ /^\.s([ol])\.[^\.]*$/)
                {
                my $sotmp = $1;
index 65a5ec1f22d999997f78284ea4bc7d5d1e8cddcb..f7c6363cbba4cf34a8ee311910686aaf6a0bc0b3 100755 (executable)
@@ -67,9 +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"
-    unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ }
-        grep { /^SHARED_LIBS=/ }
-        do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+    if config("no_shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
index 29cff45ee075e01beed246b82c7621cd37325aaf..31632a717a6bc27b267711c814e7257bda1b0e63 100755 (executable)
@@ -67,9 +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"
-    unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ }
-           grep { /^SHARED_LIBS=/ }
-           do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+    if config("no_shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
index 84fc4df7fd5810ebb22cad40dd82d464d7e503fb..84ab66199da6972db7a23e8335f4b07b5bca5eb4 100755 (executable)
@@ -68,9 +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"
-    unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ }
-           grep { /^SHARED_LIBS=/ }
-           do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+    if config("no_shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
index c31ea0ddfd0e79e025c8662543a06cdb1a79e9ea..39c0409427833d0bc0cef3b2bb31961536f9ad68 100755 (executable)
@@ -67,9 +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"
-    unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ }
-           grep { /^SHARED_LIBS=/ }
-           do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+    if config("no_shared");
 
 plan skip_all => "dh is not supported by this OpenSSL build"
     if disabled("dh");
index d626763575d967824a8298024c43b602cee6cf29..c711d86fb5d1b6a67aff3f33079f1a18ffd7aecf 100755 (executable)
@@ -67,9 +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"
-    unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ }
-           grep { /^SHARED_LIBS=/ }
-           do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+    if config("no_shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
index b6ff47e84043c520a893d54da9a1a6f5a889942c..a861064ee155dd9ad9c5dca2435be7c5fe635ec5 100644 (file)
@@ -68,9 +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"
-    unless (map { s/\R//; s/^SHARED_LIBS=\s*//; $_ }
-        grep { /^SHARED_LIBS=/ }
-        do { local @ARGV = ( top_file("Makefile") ); <> })[0] ne "";
+    if config("no_shared");
 
 $ENV{OPENSSL_ENGINES} = top_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
index 5312c205a09287720ddf4d8a39ee00a161f32aa1..eed44244b8cca283a35dd46da0204e6568eab8da 100644 (file)
@@ -7,7 +7,7 @@ use Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
 $VERSION = "0.1";
 @ISA = qw(Exporter);
-@EXPORT = qw(disabled);
+@EXPORT = qw(disabled config);
 
 =head1 NAME
 
@@ -19,13 +19,15 @@ OpenSSL::Test::Utils - test utility functions
 
   disabled("dh");
 
+  config("no_shared");
+
 =head1 DESCRIPTION
 
 This module provides utility functions for the testing framework.
 
 =cut
 
-use OpenSSL::Test;
+use OpenSSL::Test qw/:DEFAULT top_file/;
 
 =over 4
 
@@ -36,6 +38,10 @@ In a scalar context returns 1 if any of the features in ARRAY is disabled.
 In an array context returns an array with each element set to 1 if the
 corresponding feature is disabled and 0 otherwise.
 
+=item B<config STRING>
+
+Returns an item from the %config hash in \$TOP/configdata.pm.
+
 =back
 
 =cut
@@ -70,6 +76,18 @@ sub disabled {
     return 0;
 }
 
+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]};
+}
+
 =head1 SEE ALSO
 
 L<OpenSSL::Test>