[openssl-commits] [openssl] master update

Richard Levitte levitte at openssl.org
Tue Feb 9 10:44:34 UTC 2016


The branch master has been updated
       via  42e0ccdfe851c9a153d3e90746a2b8561dc9b1e3 (commit)
       via  d7465918867b107058228938e7f5c9fa032ef708 (commit)
      from  f83133a5ed9757668c12d78256ab91c2ef78a921 (commit)


- Log -----------------------------------------------------------------
commit 42e0ccdfe851c9a153d3e90746a2b8561dc9b1e3
Author: Richard Levitte <levitte at openssl.org>
Date:   Sat Jan 30 01:05:33 2016 +0100

    unified build scheme: adjust test framework for out of source build tree
    
    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 at openssl.org>

commit d7465918867b107058228938e7f5c9fa032ef708
Author: Richard Levitte <levitte at openssl.org>
Date:   Sat Jan 30 00:03:58 2016 +0100

    unified build scheme: adjust some scripts
    
    util/mkdef.pl and Makefile.shared needs to know about the source and
    the build directories.
    
    Additionally, Makefile.shared needs to know how to build shared
    libraries in a directory other than the current one.
    
    Reviewed-by: Ben Laurie <ben at openssl.org>

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

Summary of changes:
 Makefile.shared                       |  38 +++++----
 test/recipes/00-check_testexes.t      |   8 +-
 test/recipes/01-test_ordinals.t       |   6 +-
 test/recipes/10-test_bn.t             |   4 +-
 test/recipes/15-test_dsa.t            |  10 +--
 test/recipes/15-test_ec.t             |  10 +--
 test/recipes/15-test_rsa.t            |  10 +--
 test/recipes/20-test_enc.t            |   4 +-
 test/recipes/25-test_crl.t            |   6 +-
 test/recipes/25-test_gen.t            |  10 +--
 test/recipes/25-test_pkcs7.t          |   8 +-
 test/recipes/25-test_req.t            |   6 +-
 test/recipes/25-test_sid.t            |   6 +-
 test/recipes/25-test_verify.t         |   8 +-
 test/recipes/25-test_x509.t           |  10 +--
 test/recipes/30-test_evp.t            |   4 +-
 test/recipes/40-test_rehash.t         |   4 +-
 test/recipes/70-test_sslcertstatus.t  |   6 +-
 test/recipes/70-test_sslextension.t   |   6 +-
 test/recipes/70-test_sslsessiontick.t |   6 +-
 test/recipes/70-test_sslskewith0p.t   |   6 +-
 test/recipes/70-test_sslvertol.t      |   6 +-
 test/recipes/70-test_tlsextms.t       |   6 +-
 test/recipes/70-test_verify_extra.t   |   8 +-
 test/recipes/80-test_ca.t             |  11 +--
 test/recipes/80-test_cms.t            |   6 +-
 test/recipes/80-test_dane.t           |   6 +-
 test/recipes/80-test_ocsp.t           |   4 +-
 test/recipes/80-test_ssl.t            |  32 ++++----
 test/recipes/80-test_tsa.t            |   8 +-
 test/recipes/90-test_networking.t     |   8 +-
 test/recipes/tconversion.pl           |   2 +-
 test/run_tests.pl                     |   9 ++-
 test/testlib/OpenSSL/Test.pm          | 143 ++++++++++++++++++++++++----------
 test/testlib/OpenSSL/Test/Utils.pm    |   6 +-
 util/mkdef.pl                         |  13 ++--
 36 files changed, 259 insertions(+), 185 deletions(-)

diff --git a/Makefile.shared b/Makefile.shared
index 13129f8..af2dc8c 100644
--- a/Makefile.shared
+++ b/Makefile.shared
@@ -31,6 +31,12 @@ LIBNAME=
 #APPNAME=foo
 APPNAME=
 
+# DSTDIR is the directory where the built file should end up in.
+DSTDIR=.
+
+# SRCDIR is the top directory of the source tree.
+SRCDIR=.
+
 # OBJECTS contains all the object files to link together into the application.
 # This must contain at least one object file.
 #OBJECTS=foo.o
@@ -109,11 +115,11 @@ LINK_SO=	\
     LIBPATH=`echo $$LIBPATH | sed -e 's/ /:/g'`; \
     echo LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
          $${SHAREDCMD} $${SHAREDFLAGS} \
-	     -o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+	     -o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
 	     $$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS; \
     LD_LIBRARY_PATH=$$LIBPATH:$$LD_LIBRARY_PATH \
     $${SHAREDCMD} $${SHAREDFLAGS} \
-	-o $$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
+	-o $(DSTDIR)/$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX \
 	$$ALLSYMSFLAGS $$SHOBJECTS $$NOALLSYMSFLAGS $$LIBDEPS \
   ) && $(SYMLINK_SO)
 
@@ -122,30 +128,30 @@ SYMLINK_SO=	\
 		prev=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
 		if [ -n "$$SHLIB_COMPAT" ]; then \
 			for x in $$SHLIB_COMPAT; do \
-				( $(SET_X); rm -f $$SHLIB$$x$$SHLIB_SUFFIX; \
-				  ln -s $$prev $$SHLIB$$x$$SHLIB_SUFFIX ); \
+				( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX; \
+				  ln -s $$prev $(DSTDIR)/$$SHLIB$$x$$SHLIB_SUFFIX ); \
 				prev=$$SHLIB$$x$$SHLIB_SUFFIX; \
 			done; \
 		fi; \
 		if [ -n "$$SHLIB_SOVER" ]; then \
-			( $(SET_X); rm -f $$SHLIB$$SHLIB_SUFFIX; \
-			  ln -s $$prev $$SHLIB$$SHLIB_SUFFIX ); \
+			( $(SET_X); rm -f $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX; \
+			  ln -s $$prev $(DSTDIR)/$$SHLIB$$SHLIB_SUFFIX ); \
 		fi; \
 	fi
 
-LINK_SO_A=	SHOBJECTS="lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
+LINK_SO_A=	SHOBJECTS="$(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS)"; $(LINK_SO)
 LINK_SO_O=	SHOBJECTS="$(LIBEXTRAS)"; $(LINK_SO)
 
 LINK_SO_A_VIA_O=	\
-  SHOBJECTS=lib$(LIBNAME).o; \
+  SHOBJECTS=$(DSTDIR)/lib$(LIBNAME).o; \
   ALL=$$ALLSYMSFLAGS; ALLSYMSFLAGS=; NOALLSYMSFLAGS=; \
-  ( echo ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
-    ld $(LDFLAGS) -r -o lib$(LIBNAME).o $$ALL lib$(LIBNAME).a $(LIBEXTRAS) ); \
-  $(LINK_SO) && ( echo rm -f lib$(LIBNAME).o; rm -f lib$(LIBNAME).o )
+  ( echo ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL lib$(LIBNAME).a $(LIBEXTRAS); \
+    ld $(LDFLAGS) -r -o $$SHOBJECTS.o $$ALL $(DSTDIR)/lib$(LIBNAME).a $(LIBEXTRAS) ); \
+  $(LINK_SO) && ( echo rm -f $$SHOBJECTS; rm -f $$SHOBJECTS )
 
 LINK_SO_A_UNPACKED=	\
   UNPACKDIR=link_tmp.$$$$; rm -rf $$UNPACKDIR; mkdir $$UNPACKDIR; \
-  (cd $$UNPACKDIR; ar x ../lib$(LIBNAME).a) && \
+  (cd $$UNPACKDIR; ar x ../$(DSTDIR)/lib$(LIBNAME).a) && \
   ([ -z "$(LIBEXTRAS)" ] || cp $(LIBEXTRAS) $$UNPACKDIR) && \
   SHOBJECTS=$$UNPACKDIR/*.o; \
   $(LINK_SO) && rm -rf $$UNPACKDIR
@@ -178,7 +184,7 @@ link_app.gnu:
 
 link_a.linux-shared:
 	@if [ $(LIBNAME) != "crypto" -a $(LIBNAME) != "ssl" ]; then $(DO_GNU_SO); else \
-	$(PERL) util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
+	$(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
 	$(CALC_VERSIONS); \
 	SHLIB=lib$(LIBNAME).so; \
 	SHLIB_SUFFIX=; \
@@ -294,7 +300,7 @@ link_a.cygwin:
 		esac; \
 		SHLIB_SOVER=32; \
 		extras="$(LIBNAME).def"; \
-		$(PERL) util/mkdef.pl 32 $$SHLIB > $$extras; \
+		$(PERL) $(SRCDIR)/util/mkdef.pl 32 $$SHLIB > $$extras; \
 		base=; [ $(LIBNAME) = "crypto" ] && base=-Wl,--image-base,0x63000000; \
 	fi; \
 	dll_name=$$SHLIB$$SHLIB_SOVER$$SHLIB_SUFFIX; \
@@ -312,7 +318,7 @@ link_a.cygwin:
 	cp -p $$dll_name test/
 link_app.cygwin:
 	@if expr "$(CFLAGS)" : '.*OPENSSL_USE_APPLINK' > /dev/null; then \
-		LIBDEPS="$(TOP)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
+		LIBDEPS="$(SRCDIR)/crypto/applink.o $${LIBDEPS:-$(LIBDEPS)}"; \
 		export LIBDEPS; \
 	fi; \
 	$(LINK_APP)
@@ -393,7 +399,7 @@ link_a.solaris:
 		if [ $(LIBNAME) != "crypto" -a $(LIBNAME) != "ssl" ]; then \
 			ALLSYMSFLAGS="$${MINUSZ}allextract"; \
 		else \
-			$(PERL) util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
+			$(PERL) $(SRCDIR)/util/mkdef.pl $(LIBNAME) linux >$(LIBNAME).map; \
 			ALLSYMSFLAGS="$${MINUSZ}allextract,-M,$(LIBNAME).map"; \
 		fi; \
 		NOALLSYMSFLAGS="$${MINUSZ}defaultextract"; \
diff --git a/test/recipes/00-check_testexes.t b/test/recipes/00-check_testexes.t
index c086f7f..9da85f2 100644
--- a/test/recipes/00-check_testexes.t
+++ b/test/recipes/00-check_testexes.t
@@ -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)),
diff --git a/test/recipes/01-test_ordinals.t b/test/recipes/01-test_ordinals.t
index 6c5efff..ffda0f7 100755
--- a/test/recipes/01-test_ordinals.t
+++ b/test/recipes/01-test_ordinals.t
@@ -53,14 +53,14 @@
 # Hudson (tjh at 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
 {
diff --git a/test/recipes/10-test_bn.t b/test/recipes/10-test_bn.t
index a01d9bf..7e728f4 100644
--- a/test/recipes/10-test_bn.t
+++ b/test/recipes/10-test_bn.t
@@ -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');
diff --git a/test/recipes/15-test_dsa.t b/test/recipes/15-test_dsa.t
index 5a1917d..22f971c 100644
--- a/test/recipes/15-test_dsa.t
+++ b/test/recipes/15-test_dsa.t
@@ -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");
      };
 }
diff --git a/test/recipes/15-test_ec.t b/test/recipes/15-test_ec.t
index 4701dc8..48b8ce8 100644
--- a/test/recipes/15-test_ec.t
+++ b/test/recipes/15-test_ec.t
@@ -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");
      };
 }
diff --git a/test/recipes/15-test_rsa.t b/test/recipes/15-test_rsa.t
index 6418ff7..42bba1d 100644
--- a/test/recipes/15-test_rsa.t
+++ b/test/recipes/15-test_rsa.t
@@ -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");
      };
 }
diff --git a/test/recipes/20-test_enc.t b/test/recipes/20-test_enc.t
index 55f3942..2efcf70 100644
--- a/test/recipes/20-test_enc.t
+++ b/test/recipes/20-test_enc.t
@@ -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");
 
diff --git a/test/recipes/25-test_crl.t b/test/recipes/25-test_crl.t
index 6779a0b..8650bfc 100644
--- a/test/recipes/25-test_crl.t
+++ b/test/recipes/25-test_crl.t
@@ -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"));
 };
diff --git a/test/recipes/25-test_gen.t b/test/recipes/25-test_gen.t
index dc8ca6a..ce4a5ee 100644
--- a/test/recipes/25-test_gen.t
+++ b/test/recipes/25-test_gen.t
@@ -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");
 };
diff --git a/test/recipes/25-test_pkcs7.t b/test/recipes/25-test_pkcs7.t
index 3a4dbb4..6e9b397 100644
--- a/test/recipes/25-test_pkcs7.t
+++ b/test/recipes/25-test_pkcs7.t
@@ -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");
 };
diff --git a/test/recipes/25-test_req.t b/test/recipes/25-test_req.t
index ce1f869..fac9771 100644
--- a/test/recipes/25-test_req.t
+++ b/test/recipes/25-test_req.t
@@ -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");
diff --git a/test/recipes/25-test_sid.t b/test/recipes/25-test_sid.t
index b223c0d..84444b3 100644
--- a/test/recipes/25-test_sid.t
+++ b/test/recipes/25-test_sid.t
@@ -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");
 };
diff --git a/test/recipes/25-test_verify.t b/test/recipes/25-test_verify.t
index 444f69b..c1d222b 100644
--- a/test/recipes/25-test_verify.t
+++ b/test/recipes/25-test_verify.t
@@ -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]));
 }
 
diff --git a/test/recipes/25-test_x509.t b/test/recipes/25-test_x509.t
index e2d795a..1572a06 100644
--- a/test/recipes/25-test_x509.t
+++ b/test/recipes/25-test_x509.t
@@ -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"));
 };
diff --git a/test/recipes/30-test_evp.t b/test/recipes/30-test_evp.t
index 9d5ce6f..9ee24f4 100644
--- a/test/recipes/30-test_evp.t
+++ b/test/recipes/30-test_evp.t
@@ -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");
diff --git a/test/recipes/40-test_rehash.t b/test/recipes/40-test_rehash.t
index c4c6abc..f0a8fae 100644
--- a/test/recipes/40-test_rehash.t
+++ b/test/recipes/40-test_rehash.t
@@ -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');
diff --git a/test/recipes/70-test_sslcertstatus.t b/test/recipes/70-test_sslcertstatus.t
index 814ca0a..a7f2d8a 100755
--- a/test/recipes/70-test_sslcertstatus.t
+++ b/test/recipes/70-test_sslcertstatus.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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;
diff --git a/test/recipes/70-test_sslextension.t b/test/recipes/70-test_sslextension.t
index 3c9caad..f7ac9f4 100755
--- a/test/recipes/70-test_sslextension.t
+++ b/test/recipes/70-test_sslextension.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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;
diff --git a/test/recipes/70-test_sslsessiontick.t b/test/recipes/70-test_sslsessiontick.t
index 7e5ccad..f2c00da 100755
--- a/test/recipes/70-test_sslsessiontick.t
+++ b/test/recipes/70-test_sslsessiontick.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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;
diff --git a/test/recipes/70-test_sslskewith0p.t b/test/recipes/70-test_sslskewith0p.t
index 8261238..0e6a780 100755
--- a/test/recipes/70-test_sslskewith0p.t
+++ b/test/recipes/70-test_sslskewith0p.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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;
diff --git a/test/recipes/70-test_sslvertol.t b/test/recipes/70-test_sslvertol.t
index e5eef31..b12abee 100755
--- a/test/recipes/70-test_sslvertol.t
+++ b/test/recipes/70-test_sslvertol.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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;
diff --git a/test/recipes/70-test_tlsextms.t b/test/recipes/70-test_tlsextms.t
index 8e3b414..a4419f5 100644
--- a/test/recipes/70-test_tlsextms.t
+++ b/test/recipes/70-test_tlsextms.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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
 );
 
diff --git a/test/recipes/70-test_verify_extra.t b/test/recipes/70-test_verify_extra.t
index eec8904..8c213e8 100644
--- a/test/recipes/70-test_verify_extra.t
+++ b/test/recipes/70-test_verify_extra.t
@@ -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")])));
diff --git a/test/recipes/80-test_ca.t b/test/recipes/80-test_ca.t
index e97a83f..97e44c8 100644
--- a/test/recipes/80-test_ca.t
+++ b/test/recipes/80-test_ca.t
@@ -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;
 }
+
diff --git a/test/recipes/80-test_cms.t b/test/recipes/80-test_cms.t
index 5445311..e372271 100644
--- a/test/recipes/80-test_cms.t
+++ b/test/recipes/80-test_cms.t
@@ -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;
diff --git a/test/recipes/80-test_dane.t b/test/recipes/80-test_dane.t
index e0aa524..6436735 100644
--- a/test/recipes/80-test_dane.t
+++ b/test/recipes/80-test_dane.t
@@ -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");
diff --git a/test/recipes/80-test_ocsp.t b/test/recipes/80-test_ocsp.t
index 6e256c7..43087f9 100644
--- a/test/recipes/80-test_ocsp.t
+++ b/test/recipes/80-test_ocsp.t
@@ -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");
 
diff --git a/test/recipes/80-test_ssl.t b/test/recipes/80-test_ssl.t
index e84d3cc..e0f2fc5 100644
--- a/test/recipes/80-test_ssl.t
+++ b/test/recipes/80-test_ssl.t
@@ -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",
diff --git a/test/recipes/80-test_tsa.t b/test/recipes/80-test_tsa.t
index 8e02a6b..229f17e 100644
--- a/test/recipes/80-test_tsa.t
+++ b/test/recipes/80-test_tsa.t
@@ -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";
diff --git a/test/recipes/90-test_networking.t b/test/recipes/90-test_networking.t
index f8377c9..fb146dd 100644
--- a/test/recipes/90-test_networking.t
+++ b/test/recipes/90-test_networking.t
@@ -53,7 +53,7 @@
 # Hudson (tjh at 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;
diff --git a/test/recipes/tconversion.pl b/test/recipes/tconversion.pl
index 0f9b03b..eeb25d0 100644
--- a/test/recipes/tconversion.pl
+++ b/test/recipes/tconversion.pl
@@ -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
diff --git a/test/run_tests.pl b/test/run_tests.pl
index c914783..f7bd623 100644
--- a/test/run_tests.pl
+++ b/test/run_tests.pl
@@ -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
diff --git a/test/testlib/OpenSSL/Test.pm b/test/testlib/OpenSSL/Test.pm
index 80b9a2f..47c1bdc 100644
--- a/test/testlib/OpenSSL/Test.pm
+++ b/test/testlib/OpenSSL/Test.pm
@@ -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));
- at EXPORT_OK = (@Test::More::EXPORT_OK, qw(top_dir top_file pipe with cmdstr
-                                         quotify));
+ at 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}, at _,$f);
+}
+
+sub __srctop_dir {
+    BAIL_OUT("Must run setup() first") if (! $test_name);
+
+    return catdir($directories{SRCTOP}, at _);
+}
+
+sub __bldtop_file {
     BAIL_OUT("Must run setup() first") if (! $test_name);
 
     my $f = pop;
-    return catfile($directories{TOP}, at _,$f);
+    return catfile($directories{BLDTOP}, at _,$f);
 }
 
-sub __top_dir {
+sub __bldtop_dir {
     BAIL_OUT("Must run setup() first") if (! $test_name);
 
-    return catdir($directories{TOP}, at _);
+    return catdir($directories{BLDTOP}, at _);
 }
 
 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)) {
diff --git a/test/testlib/OpenSSL/Test/Utils.pm b/test/testlib/OpenSSL/Test/Utils.pm
index 4273292..da35b14 100644
--- a/test/testlib/OpenSSL/Test/Utils.pm
+++ b/test/testlib/OpenSSL/Test/Utils.pm
@@ -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;
diff --git a/util/mkdef.pl b/util/mkdef.pl
index 3151800..ff68d86 100755
--- a/util/mkdef.pl
+++ b/util/mkdef.pl
@@ -40,11 +40,12 @@
 
 use lib ".";
 use configdata;
+use File::Spec::Functions;
 
 my $debug=0;
 
-my $crypto_num= "util/libeay.num";
-my $ssl_num=    "util/ssleay.num";
+my $crypto_num= catfile($config{sourcedir},"util","libeay.num");
+my $ssl_num=    catfile($config{sourcedir},"util","ssleay.num");
 my $libname;
 
 my $do_update = 0;
@@ -384,8 +385,9 @@ sub do_defs
 
 	foreach $file (split(/\s+/,$symhacksfile." ".$files))
 		{
-		print STDERR "DEBUG: starting on $file:\n" if $debug;
-		open(IN,"<$file") || die "unable to open $file:$!\n";
+		my $fn = catfile($config{sourcedir},$file);
+		print STDERR "DEBUG: starting on $fn:\n" if $debug;
+		open(IN,"<$fn") || die "unable to open $fn:$!\n";
 		my $line = "", my $def= "";
 		my %tag = (
 			(map { $_ => 0 } @known_platforms),
@@ -1552,7 +1554,8 @@ sub count_parens
 #version
 sub get_openssl_version()
 {
-	open (IN, "include/openssl/opensslv.h") || die "Can't open opensslv.h";
+	my $fn = catfile($config{sourcedir},"include","openssl","opensslv.h");
+	open (IN, "$fn") || die "Can't open opensslv.h";
 
 	while(<IN>) {
 		if (/OPENSSL_VERSION_TEXT\s+"OpenSSL (\d\.\d\.)(\d[a-z]*)(-| )/) {


More information about the openssl-commits mailing list