Skip to content

Commit 0c999c0

Browse files
authored
Fix MockPlugin behavior in tests (#25461)
### Details: - Fix MockPlugin behavior in tests ### Tickets: - CVS-134410
1 parent 9a3f656 commit 0c999c0

File tree

3 files changed

+16
-2
lines changed

3 files changed

+16
-2
lines changed

.github/workflows/linux_sanitizers.yml

+1-1
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

+10-1
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,12 @@ 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+
ASSERT_TRUE(m_so);
42+
ov::test::utils::make_std_function<void()>(m_so, "ClearTargets")();
43+
}
44+
} // namespace
45+
3946
TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
4047
ov::Core core;
4148
auto plugin = std::make_shared<ov::test::utils::MockPlugin>();
@@ -49,6 +56,7 @@ TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
4956
std::string("mock_registered_engine") + OV_BUILD_POSTFIX),
5057
mock_plugin_name));
5158
ASSERT_THROW(core.get_versions("MOCK_REGISTERED_HARDWARE"), ov::Exception);
59+
clearMockPlugin(m_so);
5260
}
5361

5462
TEST(RegisterPluginTests, getVersionforNoRegisteredPluginNoThrows) {
@@ -113,6 +121,7 @@ TEST(RegisterPluginTests, registerExistingPluginThrows) {
113121
std::string("mock_engine") + OV_BUILD_POSTFIX),
114122
mock_plugin_name),
115123
ov::Exception);
124+
clearMockPlugin(m_so);
116125
}
117126

118127
inline std::string getPluginFile() {

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

+5
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+
std::lock_guard<std::mutex> lock(targets_mutex);
196+
targets = {};
197+
}

0 commit comments

Comments
 (0)