No exception throws when getting version from unregistered plugin (#19722)
* Updated the behavior of core.get_version() and added corresponding test cases. * Remove the prompt message. * Update src/inference/src/dev/core_impl_ie.cpp Co-authored-by: Ilya Churaev <ilyachur@gmail.com> --------- Co-authored-by: Ilya Churaev <ilyachur@gmail.com> Co-authored-by: yanlan song <bell.song@intel.com> Co-authored-by: Chen Peter <peter.chen@intel.com>
This commit is contained in:
parent
85145cd60c
commit
bf7fcb08e7
@ -553,7 +553,8 @@ ov::Plugin ov::CoreImpl::get_plugin(const std::string& pluginName) const {
|
||||
it = pluginRegistry.find(deviceName);
|
||||
if (it == pluginRegistry.end()) {
|
||||
if (pluginName == ov::DEFAULT_DEVICE_NAME)
|
||||
OPENVINO_THROW("No device is provided, so AUTO device is used by default, which failed loading.");
|
||||
OPENVINO_THROW("No device is provided, so AUTO device is used by default, which is not registered in "
|
||||
"the OpenVINO Runtime.");
|
||||
else
|
||||
OPENVINO_THROW("Device with \"", deviceName, "\" name is not registered in the OpenVINO Runtime");
|
||||
}
|
||||
|
@ -267,10 +267,17 @@ std::map<std::string, InferenceEngine::Version> ov::CoreImpl::GetVersions(const
|
||||
ov::DeviceIDParser parser(deviceName_);
|
||||
std::string deviceNameLocal = parser.get_device_name();
|
||||
|
||||
ov::Plugin cppPlugin = get_plugin(deviceNameLocal);
|
||||
|
||||
versions[deviceNameLocal] =
|
||||
ov::legacy_convert::convert_plugin(ov::SoPtr<ov::IPlugin>{cppPlugin.m_ptr, cppPlugin.m_so})->GetVersion();
|
||||
try {
|
||||
ov::Plugin cppPlugin = get_plugin(deviceNameLocal);
|
||||
auto convertedPlugin =
|
||||
ov::legacy_convert::convert_plugin(ov::SoPtr<ov::IPlugin>{cppPlugin.m_ptr, cppPlugin.m_so});
|
||||
versions[deviceNameLocal] = convertedPlugin->GetVersion();
|
||||
} catch (const ov::Exception& ex) {
|
||||
std::string exception(ex.what());
|
||||
if (exception.find("not registered in the OpenVINO Runtime") == std::string::npos) {
|
||||
throw;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return versions;
|
||||
|
@ -9,6 +9,7 @@
|
||||
#include "openvino/runtime/properties.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
#include "openvino/util/shared_object.hpp"
|
||||
#include "unit_test_utils/mocks/openvino/runtime/mock_iplugin.hpp"
|
||||
|
||||
using namespace ::testing;
|
||||
using namespace std;
|
||||
@ -34,6 +35,48 @@ inline void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std
|
||||
injectProxyEngine(plugin.get());
|
||||
}
|
||||
|
||||
TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
|
||||
ov::Core core;
|
||||
auto plugin = std::make_shared<ov::test::utils::MockPlugin>();
|
||||
std::shared_ptr<ov::IPlugin> base_plugin = plugin;
|
||||
std::shared_ptr<void> m_so;
|
||||
mockPlugin(core, base_plugin, m_so);
|
||||
std::string mock_plugin_name{"MOCK_REGISTERED_HARDWARE"};
|
||||
// Registered plugin with invalid so here
|
||||
ASSERT_NO_THROW(core.register_plugin(
|
||||
ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(),
|
||||
std::string("mock_registered_engine") + IE_BUILD_POSTFIX),
|
||||
mock_plugin_name));
|
||||
ASSERT_THROW(core.get_versions("MOCK_REGISTERED_HARDWARE"), ov::Exception);
|
||||
}
|
||||
|
||||
TEST(RegisterPluginTests, getVersionforNoRegisteredPluginNoThrows) {
|
||||
ov::Core core;
|
||||
ASSERT_NO_THROW(core.get_versions("unkown_device"));
|
||||
|
||||
auto plugin = std::make_shared<NiceMock<ov::MockIPlugin>>();
|
||||
|
||||
ON_CALL(*plugin.get(), get_property(ov::supported_properties.name(), _))
|
||||
.WillByDefault(Return(std::vector<ov::PropertyName>{}));
|
||||
|
||||
ON_CALL(*plugin.get(), get_property(ov::internal::supported_properties.name(), _))
|
||||
.WillByDefault(Return(std::vector<ov::PropertyName>{}));
|
||||
|
||||
ON_CALL(*plugin.get(), set_property(_)).WillByDefault(Return());
|
||||
|
||||
std::shared_ptr<ov::IPlugin> base_plugin = plugin;
|
||||
std::shared_ptr<void> m_so;
|
||||
mockPlugin(core, base_plugin, m_so);
|
||||
|
||||
std::string mock_plugin_name{"MOCK_HARDWARE"};
|
||||
|
||||
ASSERT_NO_THROW(
|
||||
core.register_plugin(ov::util::make_plugin_library_name(ov::test::utils::getExecutableDirectory(),
|
||||
std::string("mock_engine") + IE_BUILD_POSTFIX),
|
||||
mock_plugin_name));
|
||||
ASSERT_NO_THROW(core.get_versions("MOCK_HARDWARE"));
|
||||
}
|
||||
|
||||
TEST(RegisterPluginTests, registerNewPluginNoThrows) {
|
||||
ov::Core core;
|
||||
auto plugin = std::make_shared<ov::test::utils::MockPlugin>();
|
||||
|
Loading…
Reference in New Issue
Block a user