Commit 8f8e9f18 authored by Richard Levitte's avatar Richard Levitte Committed by Richard Levitte
Browse files

Don't assume to know the shared library extension



test/shlibloadtest.c assumes all Unix style platforms use .so as
shared library extension.  This is not the case for Mac OS X, which
uses .dylib.  Instead of this, have the test recipe find out the
extension from configuration data.

Reviewed-by: default avatarMatt Caswell <matt@openssl.org>
Reviewed-by: default avatarRich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1844)
(cherry picked from commit 62dd3351)
parent 0d325d9c
Loading
Loading
Loading
Loading
+8 −9
Original line number Diff line number Diff line
@@ -22,16 +22,15 @@ plan skip_all => "Test only supported in a shared build" if disabled("shared");

plan tests => 3;

ok(run(test(["shlibloadtest", "-crypto_first",
             $unified_info{sharednames}->{libcrypto},
             $unified_info{sharednames}->{libssl}])),
my $libcrypto =
    $unified_info{sharednames}->{libcrypto}.$target{shared_extension_simple};
my $libssl =
    $unified_info{sharednames}->{libssl}.$target{shared_extension_simple};

ok(run(test(["shlibloadtest", "-crypto_first", $libcrypto, $libssl])),
   "running shlibloadtest -crypto_first");
ok(run(test(["shlibloadtest", "-ssl_first",
             $unified_info{sharednames}->{libcrypto},
             $unified_info{sharednames}->{libssl}])),
ok(run(test(["shlibloadtest", "-ssl_first", $libcrypto, $libssl])),
   "running shlibloadtest -ssl_first");
ok(run(test(["shlibloadtest", "-just_crypto",
             $unified_info{sharednames}->{libcrypto},
             $unified_info{sharednames}->{libssl}])),
ok(run(test(["shlibloadtest", "-just_crypto", $libcrypto, $libssl])),
   "running shlibloadtest -just_crypto");
+3 −16
Original line number Diff line number Diff line
@@ -44,22 +44,9 @@ typedef void * SHLIB;
typedef void * SHLIB_SYM;
# define SHLIB_INIT NULL

# define SHARED_LIBRARY_SUFFIX ".so"

static int shlib_load(char *filename, SHLIB *lib)
static int shlib_load(const char *filename, SHLIB *lib)
{
    char *tmpfile;
    size_t filenamelen = strlen(filename);

    /* Total length = base filename len + suffix len + 1 for NULL terminator */
    tmpfile = malloc(filenamelen + sizeof(SHARED_LIBRARY_SUFFIX) + 1);
    if (tmpfile == NULL)
        return 0;
    strcpy(tmpfile, filename);
    strcpy(tmpfile + filenamelen, SHARED_LIBRARY_SUFFIX);

    *lib = dlopen(tmpfile, RTLD_GLOBAL | RTLD_LAZY);
    free(tmpfile);
    *lib = dlopen(filename, RTLD_GLOBAL | RTLD_LAZY);

    if (*lib == NULL)
        return 0;
@@ -90,7 +77,7 @@ typedef HINSTANCE SHLIB;
typedef void * SHLIB_SYM;
# define SHLIB_INIT 0

static int shlib_load(char *filename, SHLIB *lib)
static int shlib_load(const char *filename, SHLIB *lib)
{
    *lib = LoadLibraryA(filename);
    if (*lib == NULL)