Skip to content

Commit 9934864

Browse files
committed
Fix MockPlugin behavior in tests
1 parent 7ca8cb1 commit 9934864

File tree

3 files changed

+17
-2
lines changed

3 files changed

+17
-2
lines changed

.github/workflows/linux_sanitizers.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ jobs:
286286
--gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVCoreUT.xml
287287
288288
- name: OpenVINO Inference Functional Tests
289-
if: ${{ 'false' }} # Ticket: 134410
289+
if: always()
290290
run: |
291291
source ${INSTALL_DIR}/setupvars.sh
292292

src/inference/tests/functional/ov_register_plugin_test.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ using namespace std;
2626

2727
#ifndef OPENVINO_STATIC_LIBRARY
2828

29-
inline void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std::shared_ptr<void>& m_so) {
29+
namespace {
30+
void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std::shared_ptr<void>& m_so) {
3031
std::string libraryPath = ov::test::utils::get_mock_engine_path();
3132
if (!m_so)
3233
m_so = ov::util::load_shared_object(libraryPath.c_str());
@@ -36,6 +37,13 @@ inline void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std
3637
injectProxyEngine(plugin.get());
3738
}
3839

40+
void clearMockPlugin(const std::shared_ptr<void>& m_so) {
41+
std::string libraryPath = ov::test::utils::get_mock_engine_path();
42+
ASSERT_TRUE(m_so);
43+
ov::test::utils::make_std_function<void()>(m_so, "ClearTargets")();
44+
}
45+
} // namespace
46+
3947
TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
4048
ov::Core core;
4149
auto plugin = std::make_shared<ov::test::utils::MockPlugin>();
@@ -49,6 +57,7 @@ TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
4957
std::string("mock_registered_engine") + OV_BUILD_POSTFIX),
5058
mock_plugin_name));
5159
ASSERT_THROW(core.get_versions("MOCK_REGISTERED_HARDWARE"), ov::Exception);
60+
clearMockPlugin(m_so);
5261
}
5362

5463
TEST(RegisterPluginTests, getVersionforNoRegisteredPluginNoThrows) {
@@ -113,6 +122,7 @@ TEST(RegisterPluginTests, registerExistingPluginThrows) {
113122
std::string("mock_engine") + OV_BUILD_POSTFIX),
114123
mock_plugin_name),
115124
ov::Exception);
125+
clearMockPlugin(m_so);
116126
}
117127

118128
inline std::string getPluginFile() {

src/tests/test_utils/unit_test_utils/mocks/mock_engine/mock_plugin.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -190,3 +190,8 @@ OPENVINO_PLUGIN_API void InjectPlugin(ov::IPlugin* target) {
190190
std::lock_guard<std::mutex> lock(targets_mutex);
191191
targets.push(std::make_shared<MockInternalPlugin>(target));
192192
}
193+
194+
OPENVINO_PLUGIN_API void ClearTargets() {
195+
decltype(targets) empty;
196+
std::swap(targets, empty);
197+
}

0 commit comments

Comments
 (0)