From a04706e4a19aad87d27a4a32cdaabc3bd28edc1e Mon Sep 17 00:00:00 2001 From: Alexander Penev Date: Fri, 6 Sep 2024 06:13:08 +0000 Subject: [PATCH] Cleanup --- unittests/CppInterOp/CMakeLists.txt | 5 +- .../CppInterOp/DynamicLibraryManagerTest.cpp | 53 +++---------------- .../CppInterOp/TestSharedLib3/CMakeLists.txt | 11 ---- .../TestSharedLib3/TestSharedLib3.cpp | 3 -- .../TestSharedLib3/TestSharedLib3.h | 11 ---- 5 files changed, 8 insertions(+), 75 deletions(-) delete mode 100644 unittests/CppInterOp/TestSharedLib3/CMakeLists.txt delete mode 100644 unittests/CppInterOp/TestSharedLib3/TestSharedLib3.cpp delete mode 100644 unittests/CppInterOp/TestSharedLib3/TestSharedLib3.h diff --git a/unittests/CppInterOp/CMakeLists.txt b/unittests/CppInterOp/CMakeLists.txt index 97747c1b..1e633485 100644 --- a/unittests/CppInterOp/CMakeLists.txt +++ b/unittests/CppInterOp/CMakeLists.txt @@ -48,12 +48,11 @@ set_output_directory(DynamicLibraryManagerTests BINARY_DIR ${CMAKE_BINARY_DIR}/u add_dependencies(DynamicLibraryManagerTests TestSharedLib) #export_executable_symbols_for_plugins(TestSharedLib) add_subdirectory(TestSharedLib) + add_dependencies(DynamicLibraryManagerTests TestSharedLib1) #export_executable_symbols_for_plugins(TestSharedLib1) add_subdirectory(TestSharedLib1) + add_dependencies(DynamicLibraryManagerTests TestSharedLib2) #export_executable_symbols_for_plugins(TestSharedLib2) add_subdirectory(TestSharedLib2) -add_dependencies(DynamicLibraryManagerTests TestSharedLib3) -#export_executable_symbols_for_plugins(TestSharedLib3) -add_subdirectory(TestSharedLib3) diff --git a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp index bf9ec5a3..5bddb915 100644 --- a/unittests/CppInterOp/DynamicLibraryManagerTest.cpp +++ b/unittests/CppInterOp/DynamicLibraryManagerTest.cpp @@ -167,51 +167,10 @@ TEST(DynamicLibraryManagerTest, LibrariesAutoloadExtraCoverage) { rss << MU; EXPECT_STRNE("", rss.str().c_str()) << "MU problem!"; - // Cover: LoadLibrary error - // if (DLM->loadLibrary(lib, false) != DynamicLibraryManager::LoadLibResult::kLoadLibSuccess) { - // LLVM_DEBUG(dbgs() << "MU: Failed to load library " << lib); - // string err = "MU: Failed to load library! " + lib; - // perror(err.c_str()); - // } else { - // Find library with "ret_value" symbol defined and exported - std::string PathToTestSharedLib3 = - Cpp::SearchLibrariesForSymbol(MangleNameForDlsym("ret_val").c_str(), /*search_system=*/false); - // If result is "" then we cannot find this library. - EXPECT_STRNE("", PathToTestSharedLib3.c_str()) - << "Cannot find: '" << PathToTestSharedLib3 << "' in '" << Dir.str() << "'"; - // Remove library for simulate load error - llvm::sys::fs::remove(PathToTestSharedLib3, true); - EXPECT_TRUE(Cpp::GetLibrariesAutoload()); - // FIXME: Conda returns false to run this code on osx. - EXPECT_FALSE(Cpp::GetFunctionAddress(MangleNameForDlsym("ret_val").c_str())); - - // Cover - // } else { - // // Collect all failing symbols, delegate their responsibility and then - // // fail their materialization. R->defineNonExistent() sounds like it - // // should do that, but it's not implemented?! - // failedSymbols.insert(symbol); - // TODO: implement test this case - - // Cover - // if (!failedSymbols.empty()) { - // auto failingMR = R->delegate(failedSymbols); - // if (failingMR) { - // (*failingMR)->failMaterialization(); - // TODO: implement test this case - - // Cover - // void discard(const llvm::orc::JITDylib &JD, const llvm::orc::SymbolStringPtr &Name) override {} - // TODO: implement test this case - - // Cover - // if (Path.empty()) { - // LLVM_DEBUG(dbgs() << "DynamicLibraryManager::lookupLibMaybeAddExt(): " - // TODO: implement test this case - - // Cover - // platform::DLClose(dyLibHandle, &errMsg); - // if (!errMsg.empty()) { - // LLVM_DEBUG(dbgs() << "DynamicLibraryManager::unloadLibrary(): " - // TODO: implement test this case + //TODO: Test and cover also if it is possible: + // 1. Error when LoadLibrary + // 2. if (!failedSymbols.empty()) { ... + // 3. void discard(const llvm::orc::JITDylib &JD, const llvm::orc::SymbolStringPtr &Name) override {} + // 4. if (Path.empty()) { ... + // 5. platform::DLClose(dyLibHandle, &errMsg); } diff --git a/unittests/CppInterOp/TestSharedLib3/CMakeLists.txt b/unittests/CppInterOp/TestSharedLib3/CMakeLists.txt deleted file mode 100644 index b170f0bb..00000000 --- a/unittests/CppInterOp/TestSharedLib3/CMakeLists.txt +++ /dev/null @@ -1,11 +0,0 @@ -add_llvm_library(TestSharedLib3 - SHARED - DISABLE_LLVM_LINK_LLVM_DYLIB - BUILDTREE_ONLY - TestSharedLib3.cpp) -# Put TestSharedLib3 next to the unit test executable. -set_output_directory(TestSharedLib3 - BINARY_DIR ${CMAKE_BINARY_DIR}/unittests/bin/$/ - LIBRARY_DIR ${CMAKE_BINARY_DIR}/unittests/bin/$/ - ) -set_target_properties(TestSharedLib2 PROPERTIES FOLDER "Tests") diff --git a/unittests/CppInterOp/TestSharedLib3/TestSharedLib3.cpp b/unittests/CppInterOp/TestSharedLib3/TestSharedLib3.cpp deleted file mode 100644 index cd5c189a..00000000 --- a/unittests/CppInterOp/TestSharedLib3/TestSharedLib3.cpp +++ /dev/null @@ -1,3 +0,0 @@ -#include "TestSharedLib3.h" - -int ret_val() { return 42; } diff --git a/unittests/CppInterOp/TestSharedLib3/TestSharedLib3.h b/unittests/CppInterOp/TestSharedLib3/TestSharedLib3.h deleted file mode 100644 index 0752d50a..00000000 --- a/unittests/CppInterOp/TestSharedLib3/TestSharedLib3.h +++ /dev/null @@ -1,11 +0,0 @@ -#ifndef UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB3_H -#define UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB3_H - -// Avoid having to mangle/demangle the symbol name in tests -#ifdef _WIN32 -extern "C" __declspec(dllexport) int ret_val(); -#else -extern "C" int ret_val(); -#endif - -#endif // UNITTESTS_CPPINTEROP_TESTSHAREDLIB_TESTSHAREDLIB3_H