From bd8d0e9ee0a1ee5aea5aad7e8a21eb4c395ca7ac Mon Sep 17 00:00:00 2001 From: Shreyas Atre Date: Sat, 27 Jan 2024 18:14:53 -0600 Subject: [PATCH] Add test only if Paths is included Signed-off-by: Shreyas Atre --- lib/Interpreter/Paths.cpp | 6 +++--- unittests/CppInterOp/DynamicLibraryManagerTest.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/Interpreter/Paths.cpp b/lib/Interpreter/Paths.cpp index e0e2762f2..367592a06 100644 --- a/lib/Interpreter/Paths.cpp +++ b/lib/Interpreter/Paths.cpp @@ -108,15 +108,15 @@ namespace platform { #if defined(_WIN32) void* DLOpen(const std::string& Path, std::string& Err /* = nullptr */) { - auto lib = llvm::sys::DynamicLibrary::getLibrary(Path.c_str(), Err); + auto lib = llvm::sys::DynamicLibrary::getLibrary(Path.c_str(), &Err); return lib.getOSSpecificHandle(); } void DLClose(void* Lib, std::string& Err /* = nullptr*/) { auto dl = llvm::sys::DynamicLibrary(Lib); llvm::sys::DynamicLibrary::closeLibrary(dl); - if (Err) { - *Err = std::string(); + if (Err.empty()) { + Err = std::string(); } } #else diff --git a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp index cf48e052a..5050b908a 100644 --- a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp +++ b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp @@ -59,10 +59,10 @@ TEST(DynamicLibraryManagerTest, Sanity) { TEST(UtilsPlatform, DLTest) { std::string err = ""; -#ifdef __APPLE__ +#if defined(__APPLE__) auto dlopen_handle = Cpp::utils::platform::DLOpen( "./unittests/CppInterOp/libTestSharedLib.dylib", err); -#elif defined(__WIN32__) +#elif defined(_WIN32) auto dlopen_handle = Cpp::utils::platform::DLOpen( "./unittests/CppInterOp/libTestSharedLib.dll", err); #else