diff --git a/tests/src/Simple/SharedLibrary/SharedLibrary.cpp b/tests/src/Simple/SharedLibrary/SharedLibrary.cpp index a7d3d96ad61..6b985e8d555 100644 --- a/tests/src/Simple/SharedLibrary/SharedLibrary.cpp +++ b/tests/src/Simple/SharedLibrary/SharedLibrary.cpp @@ -4,6 +4,7 @@ #include "dlfcn.h" #endif #include "stdio.h" +#include "string.h" #ifndef _WIN32 #define __stdcall @@ -15,14 +16,18 @@ typedef bool(__stdcall *f_ReturnsPrimitiveBool)(); typedef char(__stdcall *f_ReturnsPrimitiveChar)(); typedef void(__stdcall *f_EnsureManagedClassLoaders)(); +#ifdef _WIN32 int main() +#else +int main(int argc, char* argv[]) +#endif { #ifdef _WIN32 HINSTANCE handle = LoadLibrary("SharedLibrary.dll"); #elif __APPLE__ - void *handle = dlopen("SharedLibrary.dylib", RTLD_LAZY); + void *handle = dlopen(strcat(argv[0], ".dylib"), RTLD_LAZY); #else - void *handle = dlopen("SharedLibrary.so", RTLD_LAZY); + void *handle = dlopen(strcat(argv[0], ".so"), RTLD_LAZY); #endif if (!handle) @@ -34,10 +39,10 @@ int main() f_ReturnsPrimitiveChar returnsPrimitiveChar = (f_ReturnsPrimitiveChar)GetProcAddress(handle, "ReturnsPrimitiveChar"); f_EnsureManagedClassLoaders ensureManagedClassLoaders = (f_EnsureManagedClassLoaders)GetProcAddress(handle, "EnsureManagedClassLoaders"); #else - f_ReturnsPrimitiveInt returnsPrimitiveInt = dlsym(handle, "ReturnsPrimitiveInt"); - f_ReturnsPrimitiveBool returnsPrimitiveBool = dlsym(handle, "ReturnsPrimitiveBool"); - f_ReturnsPrimitiveChar returnsPrimitiveChar = dlsym(handle, "ReturnsPrimitiveChar"); - f_EnsureManagedClassLoaders ensureManagedClassLoaders = dlsym(handle, "EnsureManagedClassLoaders"); + f_ReturnsPrimitiveInt returnsPrimitiveInt = (f_ReturnsPrimitiveInt)dlsym(handle, "ReturnsPrimitiveInt"); + f_ReturnsPrimitiveBool returnsPrimitiveBool = (f_ReturnsPrimitiveBool)dlsym(handle, "ReturnsPrimitiveBool"); + f_ReturnsPrimitiveChar returnsPrimitiveChar = (f_ReturnsPrimitiveChar)dlsym(handle, "ReturnsPrimitiveChar"); + f_EnsureManagedClassLoaders ensureManagedClassLoaders = (f_EnsureManagedClassLoaders)dlsym(handle, "EnsureManagedClassLoaders"); #endif if (returnsPrimitiveInt() != 10) diff --git a/tests/src/Simple/SharedLibrary/SharedLibrary.csproj b/tests/src/Simple/SharedLibrary/SharedLibrary.csproj index e381860e0ae..eb693601ec5 100644 --- a/tests/src/Simple/SharedLibrary/SharedLibrary.csproj +++ b/tests/src/Simple/SharedLibrary/SharedLibrary.csproj @@ -22,10 +22,12 @@ + + diff --git a/tests/src/Simple/SharedLibrary/SharedLibrary.sh b/tests/src/Simple/SharedLibrary/SharedLibrary.sh new file mode 100755 index 00000000000..6640f629fca --- /dev/null +++ b/tests/src/Simple/SharedLibrary/SharedLibrary.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +$1/$2 +if [ $? == 100 ]; then + echo pass + exit 0 +else + echo fail + exit 1 +fi