Skip to content

Commit

Permalink
Use DynamicLibraryManager to find library
Browse files Browse the repository at this point in the history
Signed-off-by: Shreyas Atre <shreyasatre16@gmail.com>
  • Loading branch information
SAtacker committed Feb 16, 2024
1 parent f991b6b commit e6651f3
Showing 1 changed file with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions unittests/CppInterOp/DynamicLibraryManagerTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

#include "../../lib/Interpreter/Paths.h"

#include <filesystem>
#include "../../lib/Interpreter/DynamicLibraryManager.h"

// This function isn't referenced outside its translation unit, but it
// can't use the "static" keyword because its address is used for
Expand Down Expand Up @@ -61,27 +61,11 @@ TEST(DynamicLibraryManagerTest, Sanity) {

TEST(UtilsPlatform, DLTest) {
std::string err = "";
std::string path = "";
for (auto const& dir_entry : std::filesystem::recursive_directory_iterator(
std::filesystem::current_path())) {
if (std::string(dir_entry.path()).find("libTestSharedLib.") !=
std::string::npos) {
path = dir_entry.path();
break;
}
}
std::string path =
(new Cpp::DynamicLibraryManager)->lookupLibrary("libTestSharedLib");
EXPECT_FALSE(path.empty());
std::cout<<path<<"\n";
#if defined(__APPLE__)
auto dlopen_handle =
Cpp::utils::platform::DLOpen("./libTestSharedLib.dylib", err);
#elif defined(_WIN32)
auto dlopen_handle =
Cpp::utils::platform::DLOpen("./libTestSharedLib.dll", err);
#else
auto dlopen_handle =
Cpp::utils::platform::DLOpen("./libTestSharedLib.so", err);
#endif
auto dlopen_handle = Cpp::utils::platform::DLOpen(path, err);
EXPECT_TRUE(dlopen_handle);
EXPECT_TRUE(err.empty());
Cpp::utils::platform::DLOpen("missing", err);
Expand Down

0 comments on commit e6651f3

Please sign in to comment.