From 18ff8afe639de70aad164efdb69a91200f58d35c Mon Sep 17 00:00:00 2001 From: Egor Duplensky Date: Fri, 25 Feb 2022 16:11:16 +0300 Subject: [PATCH] [IE TESTS] Avoid extra checks for test skipping (#10609) Avoid double iteration over skip patterns Skip test after first pattern match --- .../shared_test_classes/src/base/ov_subgraph.cpp | 14 +++++++++----- .../src/skip_tests_config.cpp | 10 +++++++--- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp b/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp index 3d5de5ec2d1..e3313db12b8 100644 --- a/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp +++ b/src/tests/functional/shared_test_classes/src/base/ov_subgraph.cpp @@ -46,12 +46,16 @@ void SubgraphBaseTest::run() { #else if (sigsetjmp(CommonTestUtils::env, 1) == 0) { #endif - LayerTestsUtils::PassRate::Statuses status = FuncTestUtils::SkipTestsConfig::currentTestIsDisabled() - ? LayerTestsUtils::PassRate::Statuses::SKIPPED - : LayerTestsUtils::PassRate::Statuses::CRASHED; + bool isCurrentTestDisabled = FuncTestUtils::SkipTestsConfig::currentTestIsDisabled(); + + LayerTestsUtils::PassRate::Statuses status = isCurrentTestDisabled ? + LayerTestsUtils::PassRate::Statuses::SKIPPED : + LayerTestsUtils::PassRate::Statuses::CRASHED; summary.setDeviceName(targetDevice); summary.updateOPsStats(function, status); - SKIP_IF_CURRENT_TEST_IS_DISABLED(); + + if (isCurrentTestDisabled) + GTEST_SKIP() << "Disabled test due to configuration" << std::endl; ASSERT_FALSE(targetStaticShapes.empty()) << "Target Static Shape is empty!!!"; std::string errorMessage; @@ -68,7 +72,7 @@ void SubgraphBaseTest::run() { generate_inputs(targetStaticShapeVec); } catch (const std::exception& ex) { throw std::runtime_error("Incorrect target static shape: " + - CommonTestUtils::vec2str(targetStaticShapeVec) + " " + ex.what()); + CommonTestUtils::vec2str(targetStaticShapeVec) + " " + ex.what()); } infer(); validate(); diff --git a/src/tests/ie_test_utils/functional_test_utils/src/skip_tests_config.cpp b/src/tests/ie_test_utils/functional_test_utils/src/skip_tests_config.cpp index 56e90a7ce97..0eac0439e96 100644 --- a/src/tests/ie_test_utils/functional_test_utils/src/skip_tests_config.cpp +++ b/src/tests/ie_test_utils/functional_test_utils/src/skip_tests_config.cpp @@ -14,15 +14,19 @@ namespace SkipTestsConfig { bool disable_tests_skipping = false; bool currentTestIsDisabled() { - bool skip_test = false; + if (disable_tests_skipping) + return false; + const auto fullName = ::testing::UnitTest::GetInstance()->current_test_info()->test_case_name() + std::string(".") + ::testing::UnitTest::GetInstance()->current_test_info()->name(); + for (const auto &pattern : disabledTestPatterns()) { std::regex re(pattern); if (std::regex_match(fullName, re)) - skip_test = true; + return true; } - return skip_test && !disable_tests_skipping; + + return false; } std::vector readSkipTestConfigFiles(const std::vector& filePaths) {