From f202c45c469cc339326667e57f7973842dfa0205 Mon Sep 17 00:00:00 2001 From: Roman Lyamin Date: Fri, 24 Sep 2021 10:27:07 +0300 Subject: [PATCH] [IE TESTS] Move locale test to shared folder (#7605) --- .../behavior/locale.cpp | 14 ++++++ .../plugin/shared/include/behavior/locale.hpp | 32 ++++++++++++++ .../{gpu => shared/src}/behavior/locale.cpp | 43 +++++++++++-------- 3 files changed, 70 insertions(+), 19 deletions(-) create mode 100644 inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/locale.cpp create mode 100644 inference-engine/tests/functional/plugin/shared/include/behavior/locale.hpp rename inference-engine/tests/functional/plugin/{gpu => shared/src}/behavior/locale.cpp (60%) diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/locale.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/locale.cpp new file mode 100644 index 00000000000..5c3e9abdd42 --- /dev/null +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/behavior/locale.cpp @@ -0,0 +1,14 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#include "behavior/locale.hpp" + +using namespace BehaviorTestsDefinitions; +namespace { + INSTANTIATE_TEST_SUITE_P(smoke_CustomLocaleTest, CustomLocaleTest, + ::testing::Combine( + ::testing::Values("ru_RU.UTF-8"), + ::testing::Values(CommonTestUtils::DEVICE_GPU)), + CustomLocaleTest::getTestCaseName); +} // namespace diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/locale.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/locale.hpp new file mode 100644 index 00000000000..a27bd22eb12 --- /dev/null +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/locale.hpp @@ -0,0 +1,32 @@ +// Copyright (C) 2021 Intel Corporation +// SPDX-License-Identifier: Apache-2.0 +// + +#pragma once + +#include "common_test_utils/test_common.hpp" +#include "functional_test_utils/plugin_cache.hpp" +#include "ngraph_functions/subgraph_builders.hpp" +#include "common_test_utils/file_utils.hpp" + +namespace BehaviorTestsDefinitions { + +typedef std::tuple< + std::string, // Locale name + std::string> // Target device name + LocaleParams; + +class CustomLocaleTest : public CommonTestUtils::TestsCommon, + public ::testing::WithParamInterface { +protected: + std::shared_ptr function; + std::string localeName; + std::string testName; + std::string deviceName; + + void SetUp() override; +public: + static std::string getTestCaseName(const testing::TestParamInfo &obj); +}; + +} // namespace BehaviorTestsDefinitions diff --git a/inference-engine/tests/functional/plugin/gpu/behavior/locale.cpp b/inference-engine/tests/functional/plugin/shared/src/behavior/locale.cpp similarity index 60% rename from inference-engine/tests/functional/plugin/gpu/behavior/locale.cpp rename to inference-engine/tests/functional/plugin/shared/src/behavior/locale.cpp index 4a9e013253f..475fd08db9b 100644 --- a/inference-engine/tests/functional/plugin/gpu/behavior/locale.cpp +++ b/inference-engine/tests/functional/plugin/shared/src/behavior/locale.cpp @@ -1,13 +1,10 @@ -// Copyright (C) 2018-2021 Intel Corporation +// Copyright (C) 2021 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // -#include "common_test_utils/test_common.hpp" -#include "ngraph_functions/utils/ngraph_helpers.hpp" -#include "functional_test_utils/plugin_cache.hpp" -#include "ngraph_functions/subgraph_builders.hpp" -#include -#include +#include "behavior/locale.hpp" + +namespace BehaviorTestsDefinitions { inline std::shared_ptr makeTestModel(std::vector inputShape = {1, 1, 32, 32}) { ngraph::Shape in_shape(inputShape); @@ -25,26 +22,34 @@ inline std::shared_ptr makeTestModel(std::vector input return fnPtr; } -class CustomLocaleTest : public CommonTestUtils::TestsCommon { -protected: - std::string test_name = ::testing::UnitTest::GetInstance()->current_test_info()->name(); - std::shared_ptr function; +std::string CustomLocaleTest::getTestCaseName(const testing::TestParamInfo &obj) { + std::ostringstream results; + std::string deviceName, localeName; + std::tie(localeName, deviceName) = obj.param; + results << "locale=" << localeName << "_" + << "targetDevice=" << deviceName; + return results.str(); +} - void SetUp() override { - function = makeTestModel(); - } -}; -TEST_F(CustomLocaleTest, CanLoadNetworkWithCustomLocale) { +void CustomLocaleTest::SetUp() { + std::tie(localeName, deviceName) = GetParam(); + testName = ::testing::UnitTest::GetInstance()->current_test_info()->name(); + function = makeTestModel(); +} + +TEST_P(CustomLocaleTest, CanLoadNetworkWithCustomLocale) { auto prev = std::locale(); try { - std::locale::global(std::locale("ru_RU.UTF-8")); + std::locale::global(std::locale(localeName.c_str())); } catch (...) { GTEST_SKIP(); } - std::shared_ptr ie = PluginCache::get().ie(); + std::shared_ptr ie = PluginCache::get().ie(deviceName); InferenceEngine::CNNNetwork cnnNet(function); - ASSERT_NO_THROW(ie->LoadNetwork(cnnNet, "GPU")); + ASSERT_NO_THROW(ie->LoadNetwork(cnnNet, deviceName)); std::locale::global(prev); } + +} // namespace BehaviorTestsDefinitions