Skip to content

Commit

Permalink
Fix MockPlugin behavior in tests (#25461)
Browse files Browse the repository at this point in the history
### Details:
 - Fix MockPlugin behavior in tests

### Tickets:
 - CVS-134410
  • Loading branch information
olpipi authored Jul 11, 2024
1 parent 9a3f656 commit 0c999c0
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/linux_sanitizers.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ jobs:
--gtest_output=xml:${INSTALL_TEST_DIR}/TEST-OVCoreUT.xml
- name: OpenVINO Inference Functional Tests
if: ${{ 'false' }} # Ticket: 134410
if: always()
run: |
source ${INSTALL_DIR}/setupvars.sh
Expand Down
11 changes: 10 additions & 1 deletion src/inference/tests/functional/ov_register_plugin_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ using namespace std;

#ifndef OPENVINO_STATIC_LIBRARY

inline void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std::shared_ptr<void>& m_so) {
namespace {
void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std::shared_ptr<void>& m_so) {
std::string libraryPath = ov::test::utils::get_mock_engine_path();
if (!m_so)
m_so = ov::util::load_shared_object(libraryPath.c_str());
Expand All @@ -36,6 +37,12 @@ inline void mockPlugin(ov::Core& core, std::shared_ptr<ov::IPlugin>& plugin, std
injectProxyEngine(plugin.get());
}

void clearMockPlugin(const std::shared_ptr<void>& m_so) {
ASSERT_TRUE(m_so);
ov::test::utils::make_std_function<void()>(m_so, "ClearTargets")();
}
} // namespace

TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
ov::Core core;
auto plugin = std::make_shared<ov::test::utils::MockPlugin>();
Expand All @@ -49,6 +56,7 @@ TEST(RegisterPluginTests, getVersionforRegisteredPluginThrows) {
std::string("mock_registered_engine") + OV_BUILD_POSTFIX),
mock_plugin_name));
ASSERT_THROW(core.get_versions("MOCK_REGISTERED_HARDWARE"), ov::Exception);
clearMockPlugin(m_so);
}

TEST(RegisterPluginTests, getVersionforNoRegisteredPluginNoThrows) {
Expand Down Expand Up @@ -113,6 +121,7 @@ TEST(RegisterPluginTests, registerExistingPluginThrows) {
std::string("mock_engine") + OV_BUILD_POSTFIX),
mock_plugin_name),
ov::Exception);
clearMockPlugin(m_so);
}

inline std::string getPluginFile() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,3 +190,8 @@ OPENVINO_PLUGIN_API void InjectPlugin(ov::IPlugin* target) {
std::lock_guard<std::mutex> lock(targets_mutex);
targets.push(std::make_shared<MockInternalPlugin>(target));
}

OPENVINO_PLUGIN_API void ClearTargets() {
std::lock_guard<std::mutex> lock(targets_mutex);
targets = {};
}

0 comments on commit 0c999c0

Please sign in to comment.