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: Matt Caswell <matt@openssl.org>
Reviewed-by: Rich Salz <rsalz@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/1844)
This commit is contained in:
Richard Levitte 2016-11-03 18:48:23 +01:00
parent 00bb5504cc
commit 62dd3351a1
2 changed files with 11 additions and 25 deletions

View File

@ -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");

View File

@ -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)