From 5d7f83f399e3aa23f16f762c0420d25a703d1dcb Mon Sep 17 00:00:00 2001 From: Jozef Daniecki Date: Thu, 5 Nov 2020 05:16:24 +0100 Subject: [PATCH] Fix testcase CheckExecGraphInfoSerialization (#2973) * Generate unique output file names in CheckExecGraphInfoSerialization testcase. When multiple instances of this test were executed in parallel the same file was accessed by multiple threads which was the cause of flakiness. * Enable ExecGraphTests.CheckExecGraphInfoSerialization on GPU --- .../skip_tests_config.cpp | 2 -- .../include/behavior/exec_graph_info.hpp | 27 +++++++++++++++++-- 2 files changed, 25 insertions(+), 4 deletions(-) diff --git a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp index 98bfb309f27..5a696f9db18 100644 --- a/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp +++ b/inference-engine/tests/functional/plugin/gpu/shared_tests_instances/skip_tests_config.cpp @@ -34,7 +34,5 @@ std::vector disabledTestPatterns() { // TODO: Issue: 41461 R"(.*TopKLayerTest.*k=10.*mode=min.*sort=index.*)", R"(.*TopKLayerTest.*k=5.*sort=(none|index).*)", - // TODO: Issue: 42029 - R"(.*BehaviorTests.*CheckExecGraphInfoSerialization.*)", }; } diff --git a/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp b/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp index f5e29fccb28..e010f3a4e9d 100644 --- a/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp +++ b/inference-engine/tests/functional/plugin/shared/include/behavior/exec_graph_info.hpp @@ -19,6 +19,7 @@ #include "common_test_utils/common_utils.hpp" #include "functional_test_utils/plugin_cache.hpp" #include "functional_test_utils/blob_utils.hpp" +#include namespace BehaviorTestsDefinitions { using ExecGraphTests = BehaviorTestsUtils::BehaviorTestsBasic; @@ -35,6 +36,23 @@ inline std::vector separateStrToVec(std::string str, const char sep return result; } +namespace { + std::string timestamp() { + auto now = std::chrono::system_clock::now(); + auto epoch = now.time_since_epoch(); + auto ns = std::chrono::duration_cast(epoch); + return std::to_string(ns.count()); + } + + std::string test_name() { + std::string test_name = + ::testing::UnitTest::GetInstance()->current_test_info()->name(); + std::replace_if(test_name.begin(), test_name.end(), + [](char c) { return (c == '/' || c == '='); }, '_'); + return test_name; + } +} // namespace + TEST_P(ExecGraphTests, CheckExecGraphInfoBeforeExecution) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() @@ -225,6 +243,10 @@ TEST_P(ExecGraphTests, CheckExecGraphInfoAfterExecution) { TEST_P(ExecGraphTests, CheckExecGraphInfoSerialization) { // Skip test according to plugin specific disabledTestPatterns() (if any) SKIP_IF_CURRENT_TEST_IS_DISABLED() + + std::string out_xml_path = test_name() + "_" + timestamp() + ".xml"; + std::string out_bin_path = test_name() + "_" + timestamp() + ".bin"; + // Create CNNNetwork from ngrpah::Function InferenceEngine::CNNNetwork cnnNet(function); InferenceEngine::CNNNetwork execGraph; @@ -235,8 +257,9 @@ TEST_P(ExecGraphTests, CheckExecGraphInfoSerialization) { // Create InferRequest InferenceEngine::InferRequest req; ASSERT_NO_THROW(req = execNet.CreateInferRequest()); - execGraph.serialize("exeNetwork.xml", "exeNetwork.bin"); - ASSERT_EQ(0, std::remove("exeNetwork.xml")); + execGraph.serialize(out_xml_path, out_bin_path); + ASSERT_EQ(0, std::remove(out_xml_path.c_str())); + ASSERT_EQ(0, std::remove(out_bin_path.c_str())); } else { ASSERT_THROW(ie->LoadNetwork(cnnNet, targetDevice).GetExecGraphInfo(), InferenceEngine::details::InferenceEngineException);