enable_testing()
find_package(OpenSSL 3.0 REQUIRED)
+find_program(OPENSSL_PROGRAM openssl
+ PATHS ${OPENSSL_ROOT_DIR} PATH_SUFFIXES apps bin NO_DEFAULT_PATH)
+message("-- Found OpenSSL application: ${OPENSSL_PROGRAM}")
include_directories(${OPENSSL_INCLUDE_DIR})
if (CMAKE_C_COMPILER_ID MATCHES "Clang")
execute_process(COMMAND perl -MTest2::V0 -e ""
ERROR_QUIET RESULT_VARIABLE HAVE_TEST2_V0)
if(NOT HAVE_TEST2_V0)
+ set(TEST_ENVIRONMENT
+ CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR}
+ PERL5LIB=${CMAKE_CURRENT_SOURCE_DIR}/test
+ OPENSSL_ENGINES=${CMAKE_RUNTIME_OUTPUT_DIRECTORY}
+ OPENSSL_PROGRAM=${OPENSSL_PROGRAM}
+ OPENSSL_CRYPTO_LIBRARY=${OPENSSL_CRYPTO_LIBRARY}
+ OPENSSL_CONF=${CMAKE_CURRENT_SOURCE_DIR}/test/empty.cnf
+ )
add_test(NAME engine
- COMMAND perl run_tests
- WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}/test)
- set_tests_properties(engine PROPERTIES ENVIRONMENT
- "OPENSSL_ROOT_DIR=${OPENSSL_ROOT_DIR};OPENSSL_ENGINES=${OUTPUT_DIRECTORY};OPENSSL_CONF=${CMAKE_SOURCE_DIR}/test/empty.cnf")
+ COMMAND prove --merge -PWrapOpenSSL ${CMAKE_CURRENT_SOURCE_DIR}/test)
+ set_tests_properties(engine PROPERTIES ENVIRONMENT "${TEST_ENVIRONMENT}")
else()
message(STATUS "No Test2::V0 perl module (engine tests skipped)")
endif()
--- /dev/null
+#! /usr/bin/env perl
+#
+# CC0 license applied, see LICENSE.md
+
+package WrapOpenSSL;
+use strict;
+use warnings;
+
+use File::Basename;
+use File::Spec::Functions;
+
+sub load {
+ my ($class, $p) = @_;
+ my $app = $p->{app_prove};
+
+ # turn on verbosity
+ my $verbose = $ENV{CTEST_INTERACTIVE_DEBUG_MODE} || $app->verbose();
+ $app->verbose( $verbose );
+
+ my $openssl_libdir = dirname($ENV{OPENSSL_CRYPTO_LIBRARY})
+ if $ENV{OPENSSL_CRYPTO_LIBRARY};
+ my $openssl_bindir = dirname($ENV{OPENSSL_PROGRAM})
+ if $ENV{OPENSSL_PROGRAM};
+ my $openssl_rootdir = $ENV{OPENSSL_ROOT_DIR};
+ my $openssl_rootdir_is_buildtree =
+ $openssl_rootdir && -d catdir($openssl_rootdir, 'configdata.pm');
+
+ unless ($openssl_libdir) {
+ $openssl_libdir = $openssl_rootdir_is_buildtree
+ ? $openssl_rootdir
+ : catdir($openssl_rootdir, 'lib');
+ }
+ unless ($openssl_bindir) {
+ $openssl_bindir = $openssl_rootdir_is_buildtree
+ ? catdir($openssl_rootdir, 'apps')
+ : catdir($openssl_rootdir, 'bin');
+ }
+
+ if ($openssl_libdir) {
+ # Variants of library paths
+ $ENV{$_} = join(':', $openssl_libdir, $ENV{$_} // ())
+ foreach (
+ 'LD_LIBRARY_PATH', # Linux, ELF HP-UX
+ 'DYLD_LIBRARY_PATH', # MacOS X
+ 'LIBPATH', # AIX, OS/2
+ );
+ if ($verbose) {
+ print STDERR "Added $openssl_libdir to:\n";
+ print STDERR " LD_LIBRARY_PATH, DYLD_LIBRARY_PATH, LIBPATH\n";
+ }
+ }
+
+ if ($openssl_bindir) {
+ # Binary path, works the same everywhere
+ $ENV{PATH} = join(':', $openssl_bindir, $ENV{PATH});
+ if ($verbose) {
+ print STDERR "Added $openssl_bindir to:\n";
+ print STDERR " PATH\n";
+ }
+ }
+ if ($verbose) {
+ print STDERR "$_=", $ENV{$_} // '', "\n"
+ foreach qw(LD_LIBRARY_PATH DYLD_LIBRARY_PATH LIBPATH PATH);
+ }
+}
+
+1;
+++ /dev/null
-#!/usr/bin/perl
-use TAP::Harness;
-
-exit 0 if (defined $ENV{'SKIP_PERL_TEST'});
-
-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";
- }
-
- # Variants of library paths
- # Linux, ELF HP-UX
- $ENV{'LD_LIBRARY_PATH'} =
- join(':', $openssl_libdir, split(/:/, $ENV{'LD_LIBRARY_PATH'}));
- # MacOS X
- $ENV{'DYLD_LIBRARY_PATH'} =
- join(':', $openssl_libdir, split(/:/, $ENV{'DYLD_LIBRARY_PATH'}));
- # AIX, OS/2
- $ENV{'LIBPATH'} =
- join(':', $openssl_libdir, split(/:/, $ENV{'LIBPATH'}));
-
- # Binary path, works on all Unix-like platforms
- $ENV{'PATH'} =
- join(':', $openssl_bindir, split(/:/, $ENV{'PATH'}));
-}
-my $harness = TAP::Harness->new({
- verbosity => (($ENV{CTEST_INTERACTIVE_DEBUG_MODE} // 0) != 0)
-});
-exit ($harness->runtests(glob("*.t"))->all_passed() ? 0 : 1);