[IE TESTS] Avoid extra checks for test skipping (#10609)

Avoid double iteration over skip patterns
Skip test after first pattern match
This commit is contained in:
Egor Duplensky 2022-02-25 16:11:16 +03:00 committed by GitHub
parent 94cbbe063b
commit 18ff8afe63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 8 deletions

View File

@ -46,12 +46,16 @@ void SubgraphBaseTest::run() {
#else #else
if (sigsetjmp(CommonTestUtils::env, 1) == 0) { if (sigsetjmp(CommonTestUtils::env, 1) == 0) {
#endif #endif
LayerTestsUtils::PassRate::Statuses status = FuncTestUtils::SkipTestsConfig::currentTestIsDisabled() bool isCurrentTestDisabled = FuncTestUtils::SkipTestsConfig::currentTestIsDisabled();
? LayerTestsUtils::PassRate::Statuses::SKIPPED
: LayerTestsUtils::PassRate::Statuses::CRASHED; LayerTestsUtils::PassRate::Statuses status = isCurrentTestDisabled ?
LayerTestsUtils::PassRate::Statuses::SKIPPED :
LayerTestsUtils::PassRate::Statuses::CRASHED;
summary.setDeviceName(targetDevice); summary.setDeviceName(targetDevice);
summary.updateOPsStats(function, status); 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!!!"; ASSERT_FALSE(targetStaticShapes.empty()) << "Target Static Shape is empty!!!";
std::string errorMessage; std::string errorMessage;
@ -68,7 +72,7 @@ void SubgraphBaseTest::run() {
generate_inputs(targetStaticShapeVec); generate_inputs(targetStaticShapeVec);
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
throw std::runtime_error("Incorrect target static shape: " + throw std::runtime_error("Incorrect target static shape: " +
CommonTestUtils::vec2str(targetStaticShapeVec) + " " + ex.what()); CommonTestUtils::vec2str(targetStaticShapeVec) + " " + ex.what());
} }
infer(); infer();
validate(); validate();

View File

@ -14,15 +14,19 @@ namespace SkipTestsConfig {
bool disable_tests_skipping = false; bool disable_tests_skipping = false;
bool currentTestIsDisabled() { bool currentTestIsDisabled() {
bool skip_test = false; if (disable_tests_skipping)
return false;
const auto fullName = ::testing::UnitTest::GetInstance()->current_test_info()->test_case_name() const auto fullName = ::testing::UnitTest::GetInstance()->current_test_info()->test_case_name()
+ std::string(".") + ::testing::UnitTest::GetInstance()->current_test_info()->name(); + std::string(".") + ::testing::UnitTest::GetInstance()->current_test_info()->name();
for (const auto &pattern : disabledTestPatterns()) { for (const auto &pattern : disabledTestPatterns()) {
std::regex re(pattern); std::regex re(pattern);
if (std::regex_match(fullName, re)) if (std::regex_match(fullName, re))
skip_test = true; return true;
} }
return skip_test && !disable_tests_skipping;
return false;
} }
std::vector<std::string> readSkipTestConfigFiles(const std::vector<std::string>& filePaths) { std::vector<std::string> readSkipTestConfigFiles(const std::vector<std::string>& filePaths) {