diff options
author | Tina Zhang <tina.zhang@intel.com> | 2014-07-25 10:13:53 +0800 |
---|---|---|
committer | Vince Harron <vharron@google.com> | 2014-07-27 19:41:56 -0700 |
commit | 1ee821ec62d0adf1fc6132a1cf853d3af0467908 (patch) | |
tree | 2f1d08fc297d189ad081026edcd8a096c357c7c4 /emulator/opengl/shared/emugl/common/shared_library_unittest.cpp | |
parent | ec58e2e9626c5f4c5da339a77178d81c32fdb461 (diff) | |
download | sdk-1ee821ec62d0adf1fc6132a1cf853d3af0467908.zip sdk-1ee821ec62d0adf1fc6132a1cf853d3af0467908.tar.gz sdk-1ee821ec62d0adf1fc6132a1cf853d3af0467908.tar.bz2 |
Support dynamic lib name without ".dylib" on Mac
On Mac, some of the dynamic libs has name without ".dylib". Like,
"System/Library/Frameworks/OpenGL.framework/OpenGL", we need solution
to handle it in the dlopen() API.
Change-Id: Ie513ace5a0d7d154f73e0f13919005d1498901d7
Signed-off-by: Tina Zhang <tina.zhang@intel.com>
Signed-off-by: Chao Qin <chaox.qin@intel.com>
Diffstat (limited to 'emulator/opengl/shared/emugl/common/shared_library_unittest.cpp')
-rw-r--r-- | emulator/opengl/shared/emugl/common/shared_library_unittest.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp b/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp index cec4c73..cb74efa 100644 --- a/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp +++ b/emulator/opengl/shared/emugl/common/shared_library_unittest.cpp @@ -100,6 +100,11 @@ public: SharedLibrary* operator->() { return mLib; } + void release() { + delete mLib; + mLib = NULL; + } + private: SharedLibrary* mLib; }; @@ -111,19 +116,37 @@ TEST_F(SharedLibraryTest, Open) { EXPECT_TRUE(lib.get()); } -TEST_F(SharedLibraryTest, OpenWithExtension) { +TEST_F(SharedLibraryTest, OpenLibraryWithExtension) { std::string path = library_path(); + + // test extension append + ScopedSharedLibrary libNoExtension(SharedLibrary::open(path.c_str())); + EXPECT_TRUE(libNoExtension.get()); + libNoExtension.release(); + #ifdef _WIN32 path += ".dll"; #elif defined(__APPLE__) + // try to open the library without an extension + path += ".dylib"; #else path += ".so"; #endif + + // test open with prepended extension ScopedSharedLibrary lib(SharedLibrary::open(path.c_str())); EXPECT_TRUE(lib.get()); } +#ifdef __APPLE__ +TEST_F(SharedLibraryTest, OpenLibraryWithoutExtension) { + const char* library = "/System/Library/Frameworks/OpenGL.framework/OpenGL"; + ScopedSharedLibrary lib(SharedLibrary::open(library)); + EXPECT_TRUE(lib.get()); +} +#endif + TEST_F(SharedLibraryTest, FindSymbol) { ScopedSharedLibrary lib(SharedLibrary::open(library_path())); EXPECT_TRUE(lib.get()); |