Failed plugins search from current directory w/o LD_LIBRARY_PATH (#12499)

This commit is contained in:
Ilya Lavrenov authored and GitHub committed 2022-08-12 12:10:03 +04:00
1 parent 91c192f358
commit af05733a3a
4 files changed
+15 -43

No files matched your search

+2 -7
View File
@@ -38,13 +38,8 @@ else()
set(IE_MAIN_SAMPLES_DIR ${CMAKE_CURRENT_BINARY_DIR})
endif()
if(NOT(UNIX))
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
else ()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/lib)
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER}/lib)
endif()
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_COMPILE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_PDB_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY ${IE_MAIN_SAMPLES_DIR}/${BIN_FOLDER})
@@ -15,10 +15,8 @@
// Helper functions
namespace FrontEndTestUtils {
std::string find_ov_path();
int run_tests(int argc, char** argv);
std::string get_current_executable_path();
int run_tests(int argc, char** argv);
inline std::tuple<ov::frontend::FrontEnd::Ptr, ov::frontend::InputModel::Ptr>
load_from_file(ov::frontend::FrontEndManager& fem, const std::string& frontend_name, const std::string& model_file) {
@@ -52,7 +50,7 @@ inline int set_test_env(const char* name, const char* value) {
inline void setupTestEnv() {
NGRAPH_SUPPRESS_DEPRECATED_START
std::string fePath = ov::util::get_directory(find_ov_path());
std::string fePath = ov::util::get_ov_lib_path();
set_test_env("OV_FRONTEND_PATH", fePath.c_str());
NGRAPH_SUPPRESS_DEPRECATED_END
}
@@ -4,38 +4,6 @@
#include "utils.hpp"
#ifdef _WIN32
# ifndef NOMINMAX
# define NOMINMAX
# endif
# include <windows.h>
# if defined(WINAPI_FAMILY) && !WINAPI_PARTITION_DESKTOP
# error "Only WINAPI_PARTITION_DESKTOP is supported, because of LoadLibrary[A|W]"
# endif
#elif defined(__linux) || defined(__APPLE__)
# include <dlfcn.h>
#endif
std::string FrontEndTestUtils::find_ov_path() {
#ifdef _WIN32
HMODULE hModule = GetModuleHandleW(SHARED_LIB_PREFIX L"frontend_common" SHARED_LIB_SUFFIX);
WCHAR wpath[MAX_PATH];
GetModuleFileNameW(hModule, wpath, MAX_PATH);
std::wstring ws(wpath);
std::string path(ws.begin(), ws.end());
std::replace(path.begin(), path.end(), '\\', '/');
path = ov::util::get_directory(path);
path += "/";
return path;
#elif defined(__linux) || defined(__APPLE__)
Dl_info dl_info;
dladdr(reinterpret_cast<void*>(ngraph::to_lower), &dl_info);
return ov::util::get_absolute_file_path(dl_info.dli_fname);
#else
# error "Unsupported OS"
#endif
}
std::string FrontEndTestUtils::get_disabled_tests(const std::string& manifest_path) {
std::string result = "-";
std::ifstream manifest_stream(manifest_path);
+11
View File
@@ -104,9 +104,20 @@ ov::util::FilePath getPluginPath(const std::string& pluginName, bool needAddSuff
auto pluginPath = ov::util::to_file_path(pluginName.c_str());
// 0. user can provide a full path
#ifndef _WIN32
try {
// dlopen works with absolute paths; otherwise searches from LD_LIBRARY_PATH
pluginPath = ov::util::to_file_path(ov::util::get_absolute_file_path(pluginName));
} catch (const std::runtime_error&) {
// failed to resolve absolute path; not critical
}
#endif // _WIN32
if (FileUtils::fileExist(pluginPath))
return pluginPath;
// ov::Core::register_plugin(plugin_name, device_name) case
if (needAddSuffixes)
pluginPath = FileUtils::makePluginLibraryName({}, pluginPath);