Align RegisterPluginsInRegistry() with RegisterPluginByName() (#15026)
* Align `RegisterPluginsInRegistry()` with `RegisterPluginByName()` * Add gmock dependency to commonTestUtils If use macros like OV_EXPECT_THROW, it requires target to be linked with `gmock`. So add the dependency directly to commonTestUtils * Add `ThrowOnRegisterPlugin(s)Twice` tests * ClangFormat
This commit is contained in:
1 parent
9c7beee5e5
commit
b4faeebc84
4 files changed
+46
-2
No files matched your search
@@ -587,12 +587,15 @@ public:
|
||||
|
||||
FOREACH_CHILD (pluginNode, devicesNode, "plugin") {
|
||||
std::string deviceName = GetStrAttr(pluginNode, "name");
|
||||
ov::util::FilePath pluginPath = getPluginPath(GetStrAttr(pluginNode, "location"));
|
||||
|
||||
if (pluginRegistry.find(deviceName) != pluginRegistry.end()) {
|
||||
IE_THROW() << "Device with \"" << deviceName << "\" is already registered in the OpenVINO Runtime";
|
||||
}
|
||||
if (deviceName.find('.') != std::string::npos) {
|
||||
IE_THROW() << "Device name must not contain dot '.' symbol";
|
||||
}
|
||||
|
||||
ov::util::FilePath pluginPath = getPluginPath(GetStrAttr(pluginNode, "location"));
|
||||
|
||||
// check properties
|
||||
auto propertiesNode = pluginNode.child("properties");
|
||||
ov::AnyMap config;
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
// Copyright (C) 2023 Intel Corporation
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
//
|
||||
|
||||
#include "openvino/runtime/core.hpp"
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
#include <fstream>
|
||||
|
||||
#include "common_test_utils/file_utils.hpp"
|
||||
#include "common_test_utils/test_assertions.hpp"
|
||||
#include "openvino/util/file_util.hpp"
|
||||
|
||||
TEST(CoreTests, ThrowOnRegisterPluginTwice) {
|
||||
ov::Core core;
|
||||
core.register_plugin("test_plugin", "TEST_DEVICE");
|
||||
OV_EXPECT_THROW(core.register_plugin("test_plugin", "TEST_DEVICE"),
|
||||
ov::Exception,
|
||||
::testing::HasSubstr("Device with \"TEST_DEVICE\" is already registered in the OpenVINO Runtime"));
|
||||
}
|
||||
|
||||
TEST(CoreTests, ThrowOnRegisterPluginsTwice) {
|
||||
ov::Core core;
|
||||
|
||||
auto getPluginXml = [&]() -> std::string {
|
||||
std::string pluginsXML = "test_plugins.xml";
|
||||
std::ofstream file(pluginsXML);
|
||||
file << "<ie><plugins><plugin location=\"libtest_plugin.so\" name=\"TEST_DEVICE\"></plugin></plugins></ie>";
|
||||
file.flush();
|
||||
file.close();
|
||||
return pluginsXML;
|
||||
};
|
||||
|
||||
core.register_plugins(getPluginXml());
|
||||
OV_EXPECT_THROW(core.register_plugins(getPluginXml()),
|
||||
ov::Exception,
|
||||
::testing::HasSubstr("Device with \"TEST_DEVICE\" is already registered in the OpenVINO Runtime"));
|
||||
}
|
||||
@@ -18,6 +18,7 @@ function(add_common_utils ADD_TARGET_NAME)
|
||||
PUBLIC
|
||||
gtest
|
||||
gtest_main
|
||||
gmock
|
||||
ngraphFunctions
|
||||
openvino::runtime
|
||||
openvino::runtime::dev
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
#include <gmock/gmock-matchers.h>
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
Reference in new issue
Block a user