unified build scheme: adjust test framework for out of source build tree
authorRichard Levitte <levitte@openssl.org>
Sat, 30 Jan 2016 00:05:33 +0000 (01:05 +0100)
committerRichard Levitte <levitte@openssl.org>
Tue, 9 Feb 2016 10:43:20 +0000 (11:43 +0100)
To be able to run tests when we've built in a directory other than
the source tree, the testing framework needs a few adjustments.

test/testlib/OpenSSL/Test.pm needs to know where it can find
shlib_wrap.sh, and a number of other tests need to be told a different
place to find engines than what they may be able to figure out on
their own.  Relying to $TOP is not enough, $SRCTOP and $BLDTOP can be
used as an alternative.

As part of this change, top_file and top_dir are removed and
srctop_file, bldtop_file, srctop_dir and bldtop_dir take their place.

Reviewed-by: Ben Laurie <ben@openssl.org>
34 files changed:
test/recipes/00-check_testexes.t
test/recipes/01-test_ordinals.t
test/recipes/10-test_bn.t
test/recipes/15-test_dsa.t
test/recipes/15-test_ec.t
test/recipes/15-test_rsa.t
test/recipes/20-test_enc.t
test/recipes/25-test_crl.t
test/recipes/25-test_gen.t
test/recipes/25-test_pkcs7.t
test/recipes/25-test_req.t
test/recipes/25-test_sid.t
test/recipes/25-test_verify.t
test/recipes/25-test_x509.t
test/recipes/30-test_evp.t
test/recipes/40-test_rehash.t
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/recipes/70-test_verify_extra.t
test/recipes/80-test_ca.t
test/recipes/80-test_cms.t
test/recipes/80-test_dane.t
test/recipes/80-test_ocsp.t
test/recipes/80-test_ssl.t
test/recipes/80-test_tsa.t
test/recipes/90-test_networking.t
test/recipes/tconversion.pl
test/run_tests.pl
test/testlib/OpenSSL/Test.pm
test/testlib/OpenSSL/Test/Utils.pm

index c086f7f8cc8fe488eaf4a1e23834b8be512250fe..9da85f26af4a05d678fc0851fec06270b4c202b5 100644 (file)
@@ -4,19 +4,19 @@ use strict;
 
 use File::Spec::Functions;
 use File::Basename;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT bldtop_file/;
 
 setup("check_testexes");
 
 my $OpenSSL_ver = "";
-my $Makefile = top_file("Makefile");
+my $Makefile = bldtop_file("Makefile");
 if (open(FH, $Makefile)) {
     $OpenSSL_ver =
        (map { s/\R//; s/^VERSION=([^\s]*)\s*$//; $1 } grep { /^VERSION=/ } <FH>)[0];
     close FH;
 }
 
-my $MINFO = top_file("MINFO");
+my $MINFO = bldtop_file("MINFO");
 
 plan skip_all => "because MINFO not found. If you want this test to run, please do 'perl util/mkfiles.pl > MINFO'"
     unless open(FH,$MINFO);
@@ -50,7 +50,7 @@ my @expected_tests =
 plan tests => scalar @expected_tests;
 
 my @found_tests =
-    map { basename($_) } glob(top_file("test", "recipes", "*.t"));
+    map { basename($_) } glob(bldtop_file("test", "recipes", "*.t"));
 
 foreach my $test (sort @expected_tests) {
     ok(scalar(grep(/^[0-9][0-9]-test_$test\.t$/, @found_tests)),
index 6c5efff7df3a49182a5bc189fb3fcc957a408180..ffda0f705c86d4b6806a6b613e931e46fa18dd7a 100755 (executable)
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_ordinals");
 
 plan tests => 2;
 
-ok(testordinals(top_file("util", "libeay.num")), "Test libeay.num");
-ok(testordinals(top_file("util", "ssleay.num")), "Test ssleay.num");
+ok(testordinals(srctop_file("util", "libeay.num")), "Test libeay.num");
+ok(testordinals(srctop_file("util", "ssleay.num")), "Test ssleay.num");
 
 sub testordinals
 {
index a01d9bfef07effe5fba64ff08770f4a6f2c5cdeb..7e728f4e16847b4eb487ab937dadbb0b2880d68c 100644 (file)
@@ -5,13 +5,13 @@ use warnings;
 
 use Math::BigInt;
 
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_bn");
 
 plan tests => 3;
 
-require_ok(top_file("test","recipes","bc.pl"));
+require_ok(srctop_file("test","recipes","bc.pl"));
 
 my $testresults = "tmp.bntest";
 my $init = ok(run(test(["bntest"], stdout => $testresults)), 'initialize');
index 5a1917dcedd034c25c516d4a0c8ae59c992bd21f..22f971cebf1a15a85bb2a828ba5bfc42d98e372d 100644 (file)
@@ -4,14 +4,14 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 use OpenSSL::Test::Utils;
 
 setup("test_dsa");
 
 plan tests => 6;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 ok(run(test(["dsatest"])), "running dsatest");
 ok(run(test(["dsatest", "-app2_1"])), "running dsatest -app2_1");
@@ -21,13 +21,13 @@ ok(run(test(["dsatest", "-app2_1"])), "running dsatest -app2_1");
         if disabled("dsa");
 
      subtest 'dsa conversions -- private key' => sub {
-        tconversion("dsa", top_file("test","testdsa.pem"));
+        tconversion("dsa", srctop_file("test","testdsa.pem"));
      };
      subtest 'dsa conversions -- private key PKCS#8' => sub {
-        tconversion("dsa", top_file("test","testdsa.pem"), "pkey");
+        tconversion("dsa", srctop_file("test","testdsa.pem"), "pkey");
      };
      subtest 'dsa conversions -- public key' => sub {
-        tconversion("dsa", top_file("test","testdsapub.pem"), "dsa",
+        tconversion("dsa", srctop_file("test","testdsapub.pem"), "dsa",
                     "-pubin", "-pubout");
      };
 }
index 4701dc80dbaa9edaed94062a4009fc71eaa1e397..48b8ce8cda22d5615a2e9543cba02c15d79cb801 100644 (file)
@@ -4,14 +4,14 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 use OpenSSL::Test::Utils;
 
 setup("test_ec");
 
 plan tests => 5;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 ok(run(test(["ectest"])), "running ectest");
 
@@ -20,12 +20,12 @@ ok(run(test(["ectest"])), "running ectest");
         if disabled("ec");
 
      subtest 'ec conversions -- private key' => sub {
-        tconversion("ec", top_file("test","testec-p256.pem"));
+        tconversion("ec", srctop_file("test","testec-p256.pem"));
      };
      subtest 'ec conversions -- private key PKCS#8' => sub {
-        tconversion("ec", top_file("test","testec-p256.pem"), "pkey");
+        tconversion("ec", srctop_file("test","testec-p256.pem"), "pkey");
      };
      subtest 'ec conversions -- public key' => sub {
-        tconversion("ec", top_file("test","testecpub-p256.pem"), "ec", "-pubin", "-pubout");
+        tconversion("ec", srctop_file("test","testecpub-p256.pem"), "ec", "-pubin", "-pubout");
      };
 }
index 6418ff7edd10cedc24c57a9ca80dd325600031b5..42bba1d0baedf037c4d024cf35246834e146f18a 100644 (file)
@@ -4,14 +4,14 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 use OpenSSL::Test::Utils;
 
 setup("test_rsa");
 
 plan tests => 5;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 ok(run(test(["rsa_test"])), "running rsatest");
 
@@ -20,13 +20,13 @@ ok(run(test(["rsa_test"])), "running rsatest");
         if disabled("rsa");
 
      subtest 'rsa conversions -- private key' => sub {
-        tconversion("rsa", top_file("test","testrsa.pem"));
+        tconversion("rsa", srctop_file("test","testrsa.pem"));
      };
      subtest 'rsa conversions -- private key PKCS#8' => sub {
-        tconversion("rsa", top_file("test","testrsa.pem"), "pkey");
+        tconversion("rsa", srctop_file("test","testrsa.pem"), "pkey");
      };
      subtest 'rsa conversions -- public key' => sub {
-        tconversion("rsa", top_file("test","testrsapub.pem"), "rsa",
+        tconversion("rsa", srctop_file("test","testrsapub.pem"), "rsa",
                     "-pubin", "-pubout");
      };
 }
index 55f39421fea654fa9597b602e4f598ad28da064a..2efcf7002064edb62c6d1511cbb44a516cd6cc7c 100644 (file)
@@ -7,14 +7,14 @@ use File::Spec::Functions qw/catfile/;
 use File::Copy;
 use File::Compare qw/compare_text/;
 use File::Basename;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_enc");
 
 # We do it this way, because setup() may have moved us around,
 # so the directory portion of $0 might not be correct any more.
 # However, the name hasn't changed.
-my $testsrc = top_file("test","recipes",basename($0));
+my $testsrc = srctop_file("test","recipes",basename($0));
 
 my $test = catfile(".", "p");
 
index 6779a0b1af353a851aefe549fdf4bf958c55a050..8650bfc9f936e41c122d4ef8c85bf59c3c207080 100644 (file)
@@ -4,14 +4,14 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_crl");
 
 plan tests => 2;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 subtest 'crl conversions' => sub {
-    tconversion("crl", top_file("test","testcrl.pem"));
+    tconversion("crl", srctop_file("test","testcrl.pem"));
 };
index dc8ca6ac050751fe6bac2af09a281960d3c20448..ce4a5ee260171e4da3ff480b2eeefc93bf24f370 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 use OpenSSL::Test::Utils;
 
 setup("test_gen");
@@ -13,7 +13,7 @@ plan tests => 1;
 
 my $T = "testcert";
 my $KEY = 512;
-my $CA = top_file("certs", "testca.pem");
+my $CA = srctop_file("certs", "testca.pem");
 
 unlink "$T.1", "$T.2", "$T.key";
 open RND, ">>", ".rnd";
@@ -23,7 +23,7 @@ close RND;
 subtest "generating certificate requests" => sub {
     my @req_new;
     if (disabled("rsa")) {
-       @req_new = ("-newkey", "dsa:".top_file("apps", "dsa512.pem"));
+       @req_new = ("-newkey", "dsa:".srctop_file("apps", "dsa512.pem"));
     } else {
        @req_new = ("-new");
        note("There should be a 2 sequences of .'s and some +'s.");
@@ -34,11 +34,11 @@ subtest "generating certificate requests" => sub {
 
     plan tests => 2;
 
-    ok(run(app(["openssl", "req", "-config", top_file("test", "test.cnf"),
+    ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
                @req_new, "-out", "testreq.pem"])),
        "Generating request");
 
-    ok(run(app(["openssl", "req", "-config", top_file("test", "test.cnf"),
+    ok(run(app(["openssl", "req", "-config", srctop_file("test", "test.cnf"),
                "-verify", "-in", "testreq.pem", "-noout"])),
        "Verifying signature on request");
 };
index 3a4dbb47bd3f224fc8899b0800f8b8e89fa62e12..6e9b3971757674187b4d57b101b813e3e175082b 100644 (file)
@@ -4,17 +4,17 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_pkcs7");
 
 plan tests => 3;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 subtest 'pkcs7 conversions -- pkcs7' => sub {
-    tconversion("p7", top_file("test", "testp7.pem"), "pkcs7");
+    tconversion("p7", srctop_file("test", "testp7.pem"), "pkcs7");
 };
 subtest 'pkcs7 conversions -- pkcs7d' => sub {
-    tconversion("p7d", top_file("test", "pkcs7-1.pem"), "pkcs7");
+    tconversion("p7d", srctop_file("test", "pkcs7-1.pem"), "pkcs7");
 };
index ce1f869e2b781d512be14830684775a078ee7052..fac97719e6a93c538692aa2a420996abe410ac5e 100644 (file)
@@ -4,15 +4,15 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_req");
 
 plan tests => 3;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
-my @openssl_args = ("req", "-config", "../apps/openssl.cnf");
+my @openssl_args = ("req", "-config", srctop_file("apps", "openssl.cnf"));
 
 run_conversion('req conversions',
               "testreq.pem");
index b223c0dd4f31f8bfdbfcb1e20a009455aacfa7e2..84444b3b610d61e33f230f30e0dfff2baa00e6ec 100644 (file)
@@ -4,14 +4,14 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_sid");
 
 plan tests => 2;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 subtest 'sid conversions' => sub {
-    tconversion("sid", top_file("test","testsid.pem"), "sess_id");
+    tconversion("sid", srctop_file("test","testsid.pem"), "sess_id");
 };
index 444f69b6947eacf0b541d0700a65b048b07939b6..c1d222bb80a0d05328915545d95b8347476b98c7 100644 (file)
@@ -4,7 +4,7 @@ use strict;
 use warnings;
 
 use File::Spec::Functions qw/canonpath/;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_verify");
 
@@ -13,9 +13,9 @@ sub verify {
     my @args = qw(openssl verify -purpose);
     my @path = qw(test certs);
     push(@args, "$purpose", @opts);
-    for (@$trusted) { push(@args, "-trusted", top_file(@path, "$_.pem")) }
-    for (@$untrusted) { push(@args, "-untrusted", top_file(@path, "$_.pem")) }
-    push(@args, top_file(@path, "$cert.pem"));
+    for (@$trusted) { push(@args, "-trusted", srctop_file(@path, "$_.pem")) }
+    for (@$untrusted) { push(@args, "-untrusted", srctop_file(@path, "$_.pem")) }
+    push(@args, srctop_file(@path, "$cert.pem"));
     run(app([@args]));
 }
 
index e2d795a6c4281dab701dc0f7d2525d334067e935..1572a06d711b36821b05ddd2f3486ce2c869432f 100644 (file)
@@ -4,20 +4,20 @@ use strict;
 use warnings;
 
 use File::Spec;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_x509");
 
 plan tests => 4;
 
-require_ok(top_file('test','recipes','tconversion.pl'));
+require_ok(srctop_file('test','recipes','tconversion.pl'));
 
 subtest 'x509 -- x.509 v1 certificate' => sub {
-    tconversion("x509", top_file("test","testx509.pem"));
+    tconversion("x509", srctop_file("test","testx509.pem"));
 };
 subtest 'x509 -- first x.509 v3 certificate' => sub {
-    tconversion("x509", top_file("test","v3-cert1.pem"));
+    tconversion("x509", srctop_file("test","v3-cert1.pem"));
 };
 subtest 'x509 -- second x.509 v3 certificate' => sub {
-    tconversion("x509", top_file("test","v3-cert2.pem"));
+    tconversion("x509", srctop_file("test","v3-cert2.pem"));
 };
index 9d5ce6f187feeb9de5456ede76266f5dafb430b3..9ee24f46b453395dad7ccb7f422529ffb81e076c 100644 (file)
@@ -3,10 +3,10 @@
 use strict;
 use warnings;
 
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_evp");
 
 plan tests => 1;
-ok(run(test(["evp_test", top_file("test", "evptests.txt")])),
+ok(run(test(["evp_test", srctop_file("test", "evptests.txt")])),
    "running evp_test evptests.txt");
index c4c6abcd93e1e9c1f45a99a14ac82a48fd854425..f0a8faecd6fdb70ee8d27c8b5ef7a77fbcba8241 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use File::Spec::Functions;
 use File::Copy;
 use File::Basename;
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT bldtop_file/;
 
 setup("test_rehash");
 
@@ -51,7 +51,7 @@ indir "rehash.$$" => sub {
 
 sub prepare {
     my @sourcefiles =
-        sort map { glob(top_file('certs', 'demo', "*.$_")) } ('pem',
+        sort map { glob(bldtop_file('certs', 'demo', "*.$_")) } ('pem',
                                                               'crt',
                                                               'cer',
                                                               'crl');
index 814ca0abf15ae5433780fc910584097d178a71b8..a7f2d8a2b190452fbec9938b7d73a98674df1295 100755 (executable)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
 use OpenSSL::Test::Utils;
 use TLSProxy::Proxy;
 
@@ -69,12 +69,12 @@ plan skip_all => "$test_name needs the engine feature enabled"
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
     if disabled("shared");
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 my $proxy = TLSProxy::Proxy->new(
     \&certstatus_filter,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem")
+    srctop_file("apps", "server.pem")
 );
 
 plan tests => 1;
index 3c9caadb97c3751c0589428f8c5e0a4cad66986b..f7ac9f4d58634042cf969e7a2bfe8a5e42327118 100755 (executable)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
 use OpenSSL::Test::Utils;
 use TLSProxy::Proxy;
 
@@ -69,12 +69,12 @@ plan skip_all => "$test_name needs the engine feature enabled"
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
     if disabled("shared");
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 my $proxy = TLSProxy::Proxy->new(
     \&extension_filter,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem")
+    srctop_file("apps", "server.pem")
 );
 
 plan tests => 1;
index 7e5ccad5aa4cd7c65ff02c1149814a71919115fe..f2c00daece4e4c8e950383ada46f509b1607a9b9 100755 (executable)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
 use OpenSSL::Test::Utils;
 use TLSProxy::Proxy;
 use File::Temp qw(tempfile);
@@ -70,7 +70,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
     if disabled("shared");
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 
 sub checkmessages($$$$$$);
@@ -84,7 +84,7 @@ my $ticketseen = 0;
 my $proxy = TLSProxy::Proxy->new(
     undef,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem")
+    srctop_file("apps", "server.pem")
 );
 
 plan tests => 8;
index 8261238f00247f7b86866e40a3df37be6d73e249..0e6a780404ae4ffa3f62a7eb463b8800ecd679e8 100755 (executable)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
 use OpenSSL::Test::Utils;
 use TLSProxy::Proxy;
 
@@ -72,12 +72,12 @@ plan skip_all => "$test_name can only be performed with OpenSSL configured share
 plan skip_all => "dh is not supported by this OpenSSL build"
     if disabled("dh");
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 my $proxy = TLSProxy::Proxy->new(
     \&ske_0_p_filter,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem")
+    srctop_file("apps", "server.pem")
 );
 
 plan tests => 1;
index e5eef31bc47215681a7965835b8076e3eae90331..b12abee876ee69842fa854a00a54493897b548e1 100755 (executable)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
 use OpenSSL::Test::Utils;
 use TLSProxy::Proxy;
 
@@ -69,12 +69,12 @@ plan skip_all => "$test_name needs the engine feature enabled"
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
     if disabled("shared");
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 my $proxy = TLSProxy::Proxy->new(
     \&vers_tolerance_filter,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem")
+    srctop_file("apps", "server.pem")
 );
 
 plan tests => 2;
index 8e3b41434ec73b8c79ccc72019c4b71ca3670f23..a4419f5d24415625408cf04e6f9b481932d0c29e 100644 (file)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_dir/;
 use OpenSSL::Test::Utils;
 use TLSProxy::Proxy;
 use File::Temp qw(tempfile);
@@ -70,7 +70,7 @@ plan skip_all => "$test_name needs the engine feature enabled"
 plan skip_all => "$test_name can only be performed with OpenSSL configured shared"
     if disabled("shared");
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 
 sub checkmessages($$$$$);
@@ -86,7 +86,7 @@ my $fullhand = 0;
 my $proxy = TLSProxy::Proxy->new(
     \&extms_filter,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem"),
+    srctop_file("apps", "server.pem"),
     1
 );
 
index eec8904ca93454abff820ec254ff5a52485fc32a..8c213e8a2f67659d94d8578e50b6a9dbded39264 100644 (file)
@@ -1,12 +1,12 @@
 #! /usr/bin/perl
 
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 
 setup("test_verify_extra");
 
 plan tests => 1;
 
 ok(run(test(["verify_extra_test",
-             top_file("test", "certs", "roots.pem"),
-             top_file("test", "certs", "untrusted.pem"),
-             top_file("test", "certs", "bad.pem")])));
+             srctop_file("test", "certs", "roots.pem"),
+             srctop_file("test", "certs", "untrusted.pem"),
+             srctop_file("test", "certs", "bad.pem")])));
index e97a83fbc47cb045440628eba2f129ba12f7f2fd..97e44c8d995490d8e44bf388c71c0121dcaa3419 100644 (file)
@@ -5,24 +5,24 @@ use warnings;
 
 use POSIX;
 use File::Path 2.00 qw/remove_tree/;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file/;
 
 setup("test_ca");
 
 $ENV{OPENSSL} = cmdstr(app(["openssl"]));
-my $std_openssl_cnf = $^O eq "VMS"
-    ? top_file("apps", "openssl-vms.cnf") : top_file("apps", "openssl.cnf");
+my $std_openssl_cnf =
+    srctop_file("apps", $^O eq "VMS" ? "openssl-vms.cnf" : "openssl.cnf");
 
 remove_tree("demoCA", { safe => 0 });
 
 plan tests => 4;
  SKIP: {
-     $ENV{OPENSSL_CONFIG} = "-config ".top_file("test", "CAss.cnf");
+     $ENV{OPENSSL_CONFIG} = "-config ".srctop_file("test", "CAss.cnf");
      skip "failed creating CA structure", 3
         if !ok(run(perlapp(["CA.pl","-newca"], stdin => undef, stderr => undef)),
                'creating CA structure');
 
-     $ENV{OPENSSL_CONFIG} = "-config ".top_file("test", "Uss.cnf");
+     $ENV{OPENSSL_CONFIG} = "-config ".srctop_file("test", "Uss.cnf");
      skip "failed creating new certificate request", 2
         if !ok(run(perlapp(["CA.pl","-newreq"], stderr => undef)),
                'creating CA structure');
@@ -49,3 +49,4 @@ sub yes {
     close PIPE;
     return 0;
 }
+
index 5445311e6690f9f2cbcfeffce27c7d6137121a36..e3722719ec6a89ead70176b414ee7eb48ddfa3c0 100644 (file)
@@ -6,13 +6,13 @@ use warnings;
 use POSIX;
 use File::Spec::Functions qw/catfile/;
 use File::Compare qw/compare_text/;
-use OpenSSL::Test qw/:DEFAULT top_dir top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_dir srctop_file/;
 use OpenSSL::Test::Utils;
 
 setup("test_cms");
 
-my $smdir    = top_dir("test", "smime-certs");
-my $smcont   = top_file("test", "smcont.txt");
+my $smdir    = srctop_dir("test", "smime-certs");
+my $smcont   = srctop_file("test", "smcont.txt");
 my ($no_dh, $no_ec, $no_ec2m, $no_zlib) = disabled qw/dh ec ec2m zlib/;
 
 plan tests => 4;
index e0aa524250de764bb164281bb6f45dc638037e0f..6436735a9b75b9c013d1ec35a8ef9377fa2a340e 100644 (file)
@@ -2,7 +2,7 @@
 
 use strict;
 use warnings;
-use OpenSSL::Test qw/:DEFAULT top_dir top_file/;
+use OpenSSL::Test qw/:DEFAULT srctop_file/;
 use OpenSSL::Test::Utils;
 
 setup("test_dane");
@@ -13,5 +13,5 @@ plan skip_all => "test_dane uses ec which is not supported by this OpenSSL build
 plan tests => 1;                # The number of tests being performed
 
 ok(run(test(["danetest", "example.com",
-             top_file("test", "danetest.pem"),
-             top_file("test", "danetest.in")])), "dane tests");
+             srctop_file("test", "danetest.pem"),
+             srctop_file("test", "danetest.in")])), "dane tests");
index 6e256c7122279030384ee912a6288a1bd31c87de..43087f9fd11f2077a2c14445cc2eb8994b7ef47f 100644 (file)
@@ -6,11 +6,11 @@ use warnings;
 use POSIX;
 use File::Spec::Functions qw/devnull catfile/;
 use File::Copy;
-use OpenSSL::Test qw/:DEFAULT with pipe top_dir/;
+use OpenSSL::Test qw/:DEFAULT with pipe srctop_dir/;
 
 setup("test_ocsp");
 
-my $ocspdir=top_dir("test", "ocsp-tests");
+my $ocspdir=srctop_dir("test", "ocsp-tests");
 # 17 December 2012 so we don't get certificate expiry errors.
 my @check_time=("-attime", "1355875200");
 
index e84d3cce54bdf2b65855cb6bcbff1e50a9291e06..e0f2fc5513e1ea4f8381cd0c7d544ff0c33ee056 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use POSIX;
 use File::Spec;
 use File::Copy;
-use OpenSSL::Test qw/:DEFAULT with top_file cmdstr/;
+use OpenSSL::Test qw/:DEFAULT with bldtop_file srctop_file cmdstr/;
 use OpenSSL::Test::Utils;
 
 setup("test_ssl");
@@ -27,16 +27,16 @@ my $digest = "-sha1";
 my @reqcmd = ("openssl", "req");
 my @x509cmd = ("openssl", "x509", $digest);
 my @verifycmd = ("openssl", "verify");
-my $dummycnf = top_file("apps", "openssl.cnf");
+my $dummycnf = srctop_file("apps", "openssl.cnf");
 
 my $CAkey = "keyCA.ss";
 my $CAcert="certCA.ss";
 my $CAserial="certCA.srl";
 my $CAreq="reqCA.ss";
-my $CAconf=top_file("test","CAss.cnf");
+my $CAconf=srctop_file("test","CAss.cnf");
 my $CAreq2="req2CA.ss";        # temp
 
-my $Uconf=top_file("test","Uss.cnf");
+my $Uconf=srctop_file("test","Uss.cnf");
 my $Ukey="keyU.ss";
 my $Ureq="reqU.ss";
 my $Ucert="certU.ss";
@@ -49,13 +49,13 @@ my $Ekey="keyE.ss";
 my $Ereq="reqE.ss";
 my $Ecert="certE.ss";
 
-my $P1conf=top_file("test","P1ss.cnf");
+my $P1conf=srctop_file("test","P1ss.cnf");
 my $P1key="keyP1.ss";
 my $P1req="reqP1.ss";
 my $P1cert="certP1.ss";
 my $P1intermediate="tmp_intP1.ss";
 
-my $P2conf=top_file("test","P2ss.cnf");
+my $P2conf=srctop_file("test","P2ss.cnf");
 my $P2key="keyP2.ss";
 my $P2req="reqP2.ss";
 my $P2cert="certP2.ss";
@@ -105,7 +105,7 @@ sub testss {
     close RND;
 
     my @req_dsa = ("-newkey",
-                   "dsa:".File::Spec->catfile("..", "apps", "dsa1024.pem"));;
+                   "dsa:".srctop_file("apps", "dsa1024.pem"));
     my @req_new;
     if ($no_rsa) {
        @req_new = @req_dsa;
@@ -306,17 +306,17 @@ sub testss {
 }
 
 sub testssl {
-    my $key = shift || top_file("apps","server.pem");
-    my $cert = shift || top_file("apps","server.pem");
+    my $key = shift || bldtop_file("apps","server.pem");
+    my $cert = shift || bldtop_file("apps","server.pem");
     my $CAtmp = shift;
-    my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", top_dir("certs"));
+    my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", bldtop_dir("certs"));
     my @extra = @_;
 
     my @ssltest = ("ssltest",
                   "-s_key", $key, "-s_cert", $cert,
                   "-c_key", $key, "-c_cert", $cert);
 
-    my $serverinfo = top_file("test","serverinfo.pem");
+    my $serverinfo = srctop_file("test","serverinfo.pem");
 
     my $dsa_cert = 0;
     if (grep /DSA Public Key/, run(app(["openssl", "x509", "-in", $cert,
@@ -528,13 +528,13 @@ sub testssl {
            skip "skipping RSA tests", 2
                if $no_rsa;
 
-           ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", top_file("apps","server2.pem"), "-no_dhe", "-no_ecdhe", "-num", "10", "-f", "-time", @extra])),
+           ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", srctop_file("apps","server2.pem"), "-no_dhe", "-no_ecdhe", "-num", "10", "-f", "-time", @extra])),
               'test tlsv1 with 1024bit RSA, no (EC)DHE, multiple handshakes');
 
            skip "skipping RSA+DHE tests", 1
                if $no_dh;
 
-           ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", top_file("apps","server2.pem"), "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])),
+           ok(run(test(["ssltest", "-v", "-bio_pair", "-tls1", "-s_cert", srctop_file("apps","server2.pem"), "-dhe1024dsa", "-num", "10", "-f", "-time", @extra])),
               'test tlsv1 with 1024bit RSA, 1024bit DHE, multiple handshakes');
          }
 
@@ -760,10 +760,10 @@ sub testssl {
 }
 
 sub testsslproxy {
-    my $key = shift || top_file("apps","server.pem");
-    my $cert = shift || top_file("apps","server.pem");
+    my $key = shift || srctop_file("apps","server.pem");
+    my $cert = shift || srctop_file("apps","server.pem");
     my $CAtmp = shift;
-    my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", top_dir("certs"));
+    my @CA = $CAtmp ? ("-CAfile", $CAtmp) : ("-CApath", bldtop_dir("certs"));
     my @extra = @_;
 
     my @ssltest = ("ssltest",
index 8e02a6b038e5d5930ebb40d6166e4dfe9b098693..229f17e95d415730377e34acfd1e4c447417ac95 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use POSIX;
 use File::Spec::Functions qw/splitdir curdir catfile/;
 use File::Compare;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file/;
 
 setup("test_tsa");
 
@@ -72,12 +72,12 @@ plan tests => 20;
 note "setting up TSA test directory";
 indir "tsa" => sub
 {
-    $ENV{OPENSSL_CONF} = top_file("test", "CAtsa.cnf");
+    $ENV{OPENSSL_CONF} = srctop_file("test", "CAtsa.cnf");
     # Because that's what ../apps/CA.pl really looks at
     $ENV{OPENSSL_CONFIG} = "-config ".$ENV{OPENSSL_CONF};
     $ENV{OPENSSL} = cmdstr(app(["openssl"]));
-    $testtsa = top_file("test", "recipes", "80-test_tsa.t");
-    $CAtsa = top_file("test", "CAtsa.cnf");
+    $testtsa = srctop_file("test", "recipes", "80-test_tsa.t");
+    $CAtsa = srctop_file("test", "CAtsa.cnf");
 
  SKIP: {
      $ENV{TSDNSECT} = "ts_ca_dn";
index f8377c93e09cb8b84cf8bf0e07aa3defb03ce144..fb146dd12aef709fae3bcf30881302fddc48ccb4 100644 (file)
@@ -53,7 +53,7 @@
 # Hudson (tjh@cryptsoft.com).
 
 use strict;
-use OpenSSL::Test qw/:DEFAULT cmdstr top_file top_dir/;
+use OpenSSL::Test qw/:DEFAULT cmdstr srctop_file bldtop_file bldtop_dir/;
 use TLSProxy::Proxy;
 
 my $test_name = "test_networking";
@@ -62,15 +62,15 @@ setup($test_name);
 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 "";
+           do { local @ARGV = ( bldtop_file("Makefile") ); <> })[0] ne "";
 
-$ENV{OPENSSL_ENGINES} = top_dir("engines");
+$ENV{OPENSSL_ENGINES} = bldtop_dir("engines");
 $ENV{OPENSSL_ia32cap} = '~0x200000200000000';
 
 my $proxy = TLSProxy::Proxy->new(
     undef,
     cmdstr(app(["openssl"])),
-    top_file("apps", "server.pem")
+    srctop_file("apps", "server.pem")
 );
 
 plan tests => 2;
index 0f9b03b481a41f4ebfc3935ed48078985120df5e..eeb25d0e7213fb9048185f9a665caf70f013c6e8 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use File::Compare qw/compare_text/;
 use File::Copy;
 use lib 'testlib';
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT/;
 
 my %conversionforms = (
     # Default conversion forms.  Other series may be added with
index c91478327470b213a28de3c45a0c6a081518b2fd..f7bd6238561c279aa6e7643f5ab87ffb9063bfa4 100644 (file)
@@ -7,10 +7,11 @@ use File::Spec::Functions qw/catdir catfile curdir abs2rel rel2abs/;
 use File::Basename;
 use Test::Harness qw/runtests $switches/;
 
-my $top = $ENV{TOP};
-my $recipesdir = catdir($top, "test", "recipes");
-my $testlib = catdir($top, "test", "testlib");
-my $utillib = catdir($top, "util");
+my $srctop = $ENV{SRCTOP} || $ENV{TOP};
+my $bldtop = $ENV{BLDTOP} || $ENV{TOP};
+my $recipesdir = catdir($srctop, "test", "recipes");
+my $testlib = catdir($srctop, "test", "testlib");
+my $utillib = catdir($srctop, "util");
 
 # It seems that $switches is getting interpreted with 'eval' or something
 # like that, and that we need to take care of backslashes or they will
index 80b9a2fe7579eec747a5dd40cd0d4cb62a10f56a..47c1bdc65a98a7c8f617b1617b2f7378a7a18285 100644 (file)
@@ -7,11 +7,12 @@ use Test::More 0.96;
 
 use Exporter;
 use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
-$VERSION = "0.7";
+$VERSION = "0.8";
 @ISA = qw(Exporter);
 @EXPORT = (@Test::More::EXPORT, qw(setup indir app perlapp test perltest run));
-@EXPORT_OK = (@Test::More::EXPORT_OK, qw(top_dir top_file pipe with cmdstr
-                                         quotify));
+@EXPORT_OK = (@Test::More::EXPORT_OK, qw(bldtop_dir bldtop_file
+                                         srctop_dir srctop_file
+                                         pipe with cmdstr quotify));
 
 =head1 NAME
 
@@ -37,8 +38,9 @@ In addition to the Test::More functions, it also provides functions that
 easily find the diverse programs within a OpenSSL build tree, as well as
 some other useful functions.
 
-This module I<depends> on the environment variable C<$TOP>.  Without it,
-it refuses to work.  See L</ENVIRONMENT> below.
+This module I<depends> on the environment variables C<$TOP> or C<$SRCTOP>
+and C<$BLDTOP>.  Without one of the combinations it refuses to work.
+See L</ENVIRONMENT> below.
 
 =cut
 
@@ -55,7 +57,7 @@ my $test_name = undef;
 
 # Directories we want to keep track of TOP, APPS, TEST and RESULTS are the
 # ones we're interested in, corresponding to the environment variables TOP
-# (mandatory), BIN_D, TEST_D and RESULT_D.
+# (mandatory), BIN_D, TEST_D, UTIL_D and RESULT_D.
 my %directories = ();
 
 # A bool saying if we shall stop all testing if the current recipe has failing
@@ -80,8 +82,10 @@ my %hooks = (
 my $debug = 0;
 
 # Declare some utility functions that are defined at the end
-sub top_file;
-sub top_dir;
+sub bldtop_file;
+sub bldtop_dir;
+sub srctop_file;
+sub srctop_dir;
 sub quotify;
 
 # Declare some private functions that are defined at the end
@@ -108,9 +112,10 @@ If it's not used in a OpenSSL test recipe, the rest of the recipe will
 most likely refuse to run.
 
 C<setup> checks for environment variables (see L</ENVIRONMENT> below),
-check that C<$TOP/Configure> exists, C<chdir> into the results directory
-(defined by the C<$RESULT_D> environment variable if defined, otherwise
-C<$TEST_D> if defined, otherwise C<$TOP/test>).
+checks that C<$TOP/Configure> or C<$SRCTOP/Configure> exists, C<chdir>
+into the results directory (defined by the C<$RESULT_D> environment
+variable if defined, otherwise C<$BLDTOP/test> or C<$TOP/test>, whichever
+is defined).
 
 =back
 
@@ -120,12 +125,15 @@ sub setup {
     $test_name = shift;
 
     BAIL_OUT("setup() must receive a name") unless $test_name;
-    BAIL_OUT("setup() needs \$TOP to be defined") unless $ENV{TOP};
+    BAIL_OUT("setup() needs \$TOP or \$SRCTOP and \$BLDTOP to be defined")
+        unless $ENV{TOP} || ($ENV{SRCTOP} && $ENV{BLDTOP});
+    BAIL_OUT("setup() found both \$TOP and \$SRCTOP or \$BLDTOP...")
+        if $ENV{TOP} && ($ENV{SRCTOP} || $ENV{BLDTOP});
 
     __env();
 
     BAIL_OUT("setup() expects the file Configure in the \$TOP directory")
-       unless -f top_file("Configure");
+       unless -f srctop_file("Configure");
 
     __cwd($directories{RESULTS});
 
@@ -203,10 +211,12 @@ Both of these functions take a reference to a list that is a command and
 its arguments, and some additional options (described further on).
 
 C<app> expects to find the given command (the first item in the given list
-reference) as an executable in C<$BIN_D> (if defined, otherwise C<$TOP/apps>).
+reference) as an executable in C<$BIN_D> (if defined, otherwise C<$TOP/apps>
+or C<$BLDTOP/apps>).
 
 C<test> expects to find the given command (the first item in the given list
-reference) as an executable in C<$TEST_D> (if defined, otherwise C<$TOP/test>).
+reference) as an executable in C<$TEST_D> (if defined, otherwise C<$TOP/test>
+or C<$BLDTOP/test>).
 
 Both return a CODEREF to be used by C<run>, C<pipe> or C<cmdstr>.
 
@@ -354,11 +364,11 @@ END {
 
 The following functions are exported on request when using C<OpenSSL::Test>.
 
-  # To only get the top_file function.
-  use OpenSSL::Test qw/top_file/;
+  # To only get the bldtop_file and srctop_file functions.
+  use OpenSSL::Test qw/bldtop_file srctop_file/;
 
-  # To only get the top_file function in addition to the default ones.
-  use OpenSSL::Test qw/:DEFAULT top_file/;
+  # To only get the bldtop_file function in addition to the default ones.
+  use OpenSSL::Test qw/:DEFAULT bldtop_file/;
 
 =cut
 
@@ -366,38 +376,76 @@ The following functions are exported on request when using C<OpenSSL::Test>.
 
 =over 4
 
-=item B<top_dir LIST>
+=item B<bldtop_dir LIST>
 
 LIST is a list of directories that make up a path from the top of the OpenSSL
-source directory (as indicated by the environment variable C<$TOP>).
-C<top_dir> returns the resulting directory as a string, adapted to the local
+build directory (as indicated by the environment variable C<$TOP> or
+C<$BLDTOP>).
+C<bldtop_dir> returns the resulting directory as a string, adapted to the local
 operating system.
 
 =back
 
 =cut
 
-sub top_dir {
-    return __top_dir(@_);      # This caters for operating systems that have
+sub bldtop_dir {
+    return __bldtop_dir(@_);   # This caters for operating systems that have
                                # a very distinct syntax for directories.
 }
 
 =over 4
 
-=item B<top_file LIST, FILENAME>
+=item B<bldtop_file LIST, FILENAME>
 
 LIST is a list of directories that make up a path from the top of the OpenSSL
-source directory (as indicated by the environment variable C<$TOP>) and
-FILENAME is the name of a file located in that directory path.
-C<top_file> returns the resulting file path as a string, adapted to the local
+build directory (as indicated by the environment variable C<$TOP> or
+C<$BLDTOP>) and FILENAME is the name of a file located in that directory path.
+C<bldtop_file> returns the resulting file path as a string, adapted to the local
 operating system.
 
 =back
 
 =cut
 
-sub top_file {
-    return __top_file(@_);
+sub bldtop_file {
+    return __bldtop_file(@_);
+}
+
+=over 4
+
+=item B<srctop_dir LIST>
+
+LIST is a list of directories that make up a path from the top of the OpenSSL
+source directory (as indicated by the environment variable C<$TOP> or
+C<$SRCTOP>).
+C<srctop_dir> returns the resulting directory as a string, adapted to the local
+operating system.
+
+=back
+
+=cut
+
+sub srctop_dir {
+    return __srctop_dir(@_);   # This caters for operating systems that have
+                               # a very distinct syntax for directories.
+}
+
+=over 4
+
+=item B<srctop_file LIST, FILENAME>
+
+LIST is a list of directories that make up a path from the top of the OpenSSL
+source directory (as indicated by the environment variable C<$TOP> or
+C<$SRCTOP>) and FILENAME is the name of a file located in that directory path.
+C<srctop_file> returns the resulting file path as a string, adapted to the local
+operating system.
+
+=back
+
+=cut
+
+sub srctop_file {
+    return __srctop_file(@_);
 }
 
 =over 4
@@ -583,25 +631,39 @@ failures will result in a C<BAIL_OUT> at the end of its run.
 =cut
 
 sub __env {
-    $directories{TOP}     = $ENV{TOP},
-    $directories{APPS}    = $ENV{BIN_D}    || catdir($directories{TOP},"apps");
-    $directories{TEST}    = $ENV{TEST_D}   || catdir($directories{TOP},"test");
+    $directories{SRCTOP}  = $ENV{SRCTOP} || $ENV{TOP};
+    $directories{BLDTOP}  = $ENV{BLDTOP} || $ENV{TOP};
+    $directories{APPS}    = $ENV{BIN_D}  || __bldtop_dir("apps");
+    $directories{TEST}    = $ENV{TEST_D} || __bldtop_dir("test");
     $directories{RESULTS} = $ENV{RESULT_D} || $directories{TEST};
 
     $end_with_bailout    = $ENV{STOPTEST} ? 1 : 0;
 };
 
-sub __top_file {
+sub __srctop_file {
+    BAIL_OUT("Must run setup() first") if (! $test_name);
+
+    my $f = pop;
+    return catfile($directories{SRCTOP},@_,$f);
+}
+
+sub __srctop_dir {
+    BAIL_OUT("Must run setup() first") if (! $test_name);
+
+    return catdir($directories{SRCTOP},@_);
+}
+
+sub __bldtop_file {
     BAIL_OUT("Must run setup() first") if (! $test_name);
 
     my $f = pop;
-    return catfile($directories{TOP},@_,$f);
+    return catfile($directories{BLDTOP},@_,$f);
 }
 
-sub __top_dir {
+sub __bldtop_dir {
     BAIL_OUT("Must run setup() first") if (! $test_name);
 
-    return catdir($directories{TOP},@_);
+    return catdir($directories{BLDTOP},@_);
 }
 
 sub __test_file {
@@ -680,7 +742,7 @@ sub __cwd {
     # For each of these directory variables, figure out where they are relative
     # to the directory we want to move to if they aren't absolute (if they are,
     # they don't change!)
-    my @dirtags = ("TOP", "TEST", "APPS", "RESULTS");
+    my @dirtags = sort keys %directories;
     foreach (@dirtags) {
        if (!file_name_is_absolute($directories{$_})) {
            my $newpath = abs2rel(rel2abs($directories{$_}), rel2abs($dir));
@@ -693,7 +755,8 @@ sub __cwd {
        print STDERR "  \$directories{TEST}    = \"$directories{TEST}\"\n";
        print STDERR "  \$directories{RESULTS} = \"$directories{RESULTS}\"\n";
        print STDERR "  \$directories{APPS}    = \"$directories{APPS}\"\n";
-       print STDERR "  \$directories{TOP}     = \"$directories{TOP}\"\n";
+       print STDERR "  \$directories{SRCTOP}  = \"$directories{SRCTOP}\"\n";
+       print STDERR "  \$directories{BLDTOP}  = \"$directories{BLDTOP}\"\n";
        print STDERR "  \$test_log             = \"",__test_log(),"\"\n";
        print STDERR "\n";
        print STDERR "  current directory is \"",curdir(),"\"\n";
@@ -707,7 +770,7 @@ sub __fixup_cmd {
     my $prog = shift;
     my $exe_shell = shift;
 
-    my $prefix = __top_file("util", "shlib_wrap.sh")." ";
+    my $prefix = __bldtop_file("util", "shlib_wrap.sh")." ";
     my $ext = $ENV{"EXE_EXT"} || "";
 
     if (defined($exe_shell)) {
index 4273292f5a6834435156a50ad85b79798f3c8a14..da35b14955b1c7a6ab1f339e940705805be9e5b4 100644 (file)
@@ -34,7 +34,7 @@ This module provides utility functions for the testing framework.
 
 =cut
 
-use OpenSSL::Test qw/:DEFAULT top_file/;
+use OpenSSL::Test qw/:DEFAULT bldtop_file/;
 
 =over 4
 
@@ -75,9 +75,9 @@ 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
+    # The latter would have bldtop_file() complain that setup() hasn't
     # been run yet.
-    my $configdata = top_file("configdata.pm");
+    my $configdata = bldtop_file("configdata.pm");
     eval { require $configdata;
           %available_protocols = %configdata::available_protocols;
           %disabled = %configdata::disabled;