]> www.wagner.pp.ru Git - openssl-gost/engine.git/commitdiff
Merge pull request #160 from levitte/fix-146
authorDmitry Belyavskiy <beldmit@users.noreply.github.com>
Sat, 24 Aug 2019 15:00:40 +0000 (18:00 +0300)
committerGitHub <noreply@github.com>
Sat, 24 Aug 2019 15:00:40 +0000 (18:00 +0300)
test/run_tests: Always set paths when OPENSSL_ROOT_DIR is defined

.cirrus.yml
test/run_tests

index d4bb0b818d3c6f2e732db1886a570a3858cbd023..47b69c4ea579d9813170c25f2894b51e213b26a8 100644 (file)
@@ -8,7 +8,7 @@ FreeBSD_task:
     PATH: ${PREFIX}/bin:${PATH}
     OPENSSL_BRANCH: master
   script:
-    - pkg install git cmake p5-App-cpanminus gdb
+    - pkg install git cmake p5-App-cpanminus gdb pkgconf
     - sudo cpanm --notest Test2::V0
     - git clone --depth 1 -b ${OPENSSL_BRANCH} https://github.com/openssl/openssl.git
     - cd openssl
index 3dfa90c8bebb5488d0a7c13880ef5399e55ee48b..a6709fdce2bd1b776ae96d213244d5b505333391 100644 (file)
@@ -1,9 +1,37 @@
 #!/usr/bin/perl
 use TAP::Harness;
 
-if(defined $ENV{'OPENSSL_ROOT_DIR'} && !defined $ENV{'LD_LIBRARY_PATH'}) {
-  $ENV{'LD_LIBRARY_PATH'} = $ENV{'OPENSSL_ROOT_DIR'};
-  $ENV{'PATH'} = "$ENV{'OPENSSL_ROOT_DIR'}/apps:$ENV{'PATH'}";
+if(defined $ENV{'OPENSSL_ROOT_DIR'}) {
+    my $openssl_libdir;
+    my $openssl_bindir;
+
+    if (-d "$ENV{'OPENSSL_ROOT_DIR'}/apps") {
+        # The OpenSSL root dir is an OpenSSL build tree
+        $openssl_bindir = "$ENV{'OPENSSL_ROOT_DIR'}/apps";
+        $openssl_libdir = "$ENV{'OPENSSL_ROOT_DIR'}";
+    } else {
+        # The OpenSSL root dir is an OpenSSL installation tree
+        # Since we're not exactly sure what the library path is (because
+        # multilib), we ask pkg-config
+        local $ENV{PKG_CONFIG_PATH} = "$ENV{'OPENSSL_ROOT_DIR'}/lib/pkgconfig";
+        my $pkgans = `pkg-config --libs-only-L openssl`;
+
+        # If pkg-config failed for any reason, abort.  The tests will most
+        # likely fail anyway because the binary path won't have a matching
+        # library path.
+        die "pkg-config failure: $! (exit code ", $? >> 8, ", signal ", $? & 0xff, ")"
+            if ($? != 0);
+
+        $pkgans =~ s|\R$||;      # Better chomp
+        $pkgans =~ s|^-L||;      # Remove flag from answer
+
+        $openssl_libdir = $pkgans;
+        $openssl_bindir = "$ENV{'OPENSSL_ROOT_DIR'}/bin";
+    }
+    $ENV{'LD_LIBRARY_PATH'} =
+        join(':', $openssl_libdir, split(/:/, $ENV{'LD_LIBRARY_PATH'}));
+    $ENV{'PATH'} =
+        join(':', $openssl_bindir, split(/:/, $ENV{'PATH'}));
 }
 my $harness = TAP::Harness->new();
 exit ($harness->runtests(glob("*.t"))->all_passed() ? 0 : 1);