From 0ca3ccb7fb629e3d03a3614bcda5b82c99467150 Mon Sep 17 00:00:00 2001 From: River Li Date: Tue, 14 Mar 2023 20:34:33 +0800 Subject: [PATCH] [CAPI][TEST] remove testdata repository dependency (#16259) * [CAPI][TEST] remove testdata repository dependency Change-Id: I93798d47bcf4abf69562f76aab1469498b4e9ee1 * SCI issue Change-Id: Ifb422fafdefe26be85a0ae8efdc1530f7f032079 * Apply TEST SUIT for C API tests Change-Id: Ic716cdb357060e1cbf989871ae39d006f2878632 * Fix issue for static build Change-Id: I5d33f23b48dcda4baf260553aa8d34e62c13c128 --- .ci/azure/linux.yml | 6 - .ci/azure/windows.yml | 6 - src/bindings/c/tests/CMakeLists.txt | 9 +- src/bindings/c/tests/ie_c_api_test.cpp | 574 +++++++++--------- .../c/tests/ov_compiled_model_test.cpp | 74 ++- src/bindings/c/tests/ov_core_test.cpp | 111 ++-- .../c/tests/ov_infer_request_test.cpp | 78 +-- src/bindings/c/tests/ov_model_test.cpp | 100 +-- src/bindings/c/tests/ov_preprocess_test.cpp | 72 ++- .../c/tests/ov_remote_context_test.cpp | 6 +- src/bindings/c/tests/ov_test.cpp | 8 - src/bindings/c/tests/ov_test.hpp | 22 +- src/bindings/c/tests/test_model_repo.hpp | 81 +-- 13 files changed, 577 insertions(+), 570 deletions(-) diff --git a/.ci/azure/linux.yml b/.ci/azure/linux.yml index 9818391ffc3..20b7fc4de54 100644 --- a/.ci/azure/linux.yml +++ b/.ci/azure/linux.yml @@ -447,16 +447,10 @@ jobs: - script: | $(RUN_PREFIX) $(INSTALL_TEST_DIR)/InferenceEngineCAPITests --gtest_output=xml:$(INSTALL_TEST_DIR)/TEST-InferenceEngineCAPITests.xml - env: - DATA_PATH: $(MODELS_PATH) - MODELS_PATH: $(MODELS_PATH) displayName: 'IE CAPITests' - script: | $(RUN_PREFIX) $(INSTALL_TEST_DIR)/ov_capi_test --gtest_output=xml:$(INSTALL_TEST_DIR)/TEST-ov_capi_test.xml - env: - DATA_PATH: $(MODELS_PATH) - MODELS_PATH: $(MODELS_PATH) displayName: 'OV CAPITests' - task: CMake@1 diff --git a/.ci/azure/windows.yml b/.ci/azure/windows.yml index a5907ded609..cb42e0f8e30 100644 --- a/.ci/azure/windows.yml +++ b/.ci/azure/windows.yml @@ -315,16 +315,10 @@ jobs: - script: | call $(SETUPVARS) && $(INSTALL_TEST_DIR)\InferenceEngineCAPITests --gtest_output=xml:$(INSTALL_TEST_DIR)\TEST-InferenceEngineCAPITests.xml - env: - DATA_PATH: $(MODELS_PATH) - MODELS_PATH: $(MODELS_PATH) displayName: 'IE CAPITests' - script: | call $(SETUPVARS) && $(INSTALL_TEST_DIR)\ov_capi_test --gtest_output=xml:$(INSTALL_TEST_DIR)\TEST-ov_capi_test.xml - env: - DATA_PATH: $(MODELS_PATH) - MODELS_PATH: $(MODELS_PATH) displayName: 'OV CAPITests' - task: PublishTestResults@2 diff --git a/src/bindings/c/tests/CMakeLists.txt b/src/bindings/c/tests/CMakeLists.txt index 01a8dfa46b3..bfd4e2c85be 100644 --- a/src/bindings/c/tests/CMakeLists.txt +++ b/src/bindings/c/tests/CMakeLists.txt @@ -11,9 +11,7 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_c commonTestUtils gtest_ma target_compile_definitions(${TARGET_NAME} PRIVATE - $<$:ENABLE_GAPI_PREPROCESSING> - DATA_PATH=\"${DATA_PATH}\" - MODELS_PATH=\"${MODELS_PATH}\") + $<$:ENABLE_GAPI_PREPROCESSING>) if(ENABLE_AUTO OR ENABLE_MULTI) add_dependencies(${TARGET_NAME} openvino_auto_plugin) @@ -55,11 +53,6 @@ target_link_libraries(${TARGET_NAME} PRIVATE openvino_c openvino::util target_include_directories(${TARGET_NAME} PUBLIC $) -target_compile_definitions(${TARGET_NAME} - PRIVATE - DATA_PATH=\"${DATA_PATH}\" - MODELS_PATH=\"${MODELS_PATH}\") - if(TARGET OpenCL::OpenCL) target_link_libraries(${TARGET_NAME} PRIVATE OpenCL::OpenCL) endif() diff --git a/src/bindings/c/tests/ie_c_api_test.cpp b/src/bindings/c/tests/ie_c_api_test.cpp index f5dfff0f646..f4d527d6180 100644 --- a/src/bindings/c/tests/ie_c_api_test.cpp +++ b/src/bindings/c/tests/ie_c_api_test.cpp @@ -2,7 +2,6 @@ // SPDX-License-Identifier: Apache-2.0 // -// clang-format off #include #include #include @@ -13,64 +12,23 @@ #include "test_model_repo.hpp" #include -std::string xml_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.xml"), - bin_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.bin"), - input_image_nv12_std = TestDataHelpers::generate_image_path("224x224", "dog6.yuv"); - -const char* xml = xml_std.c_str(); -const char* bin = bin_std.c_str(); -const char* input_image_nv12 = input_image_nv12_std.c_str(); - -std::mutex m; -bool ready = false; -std::condition_variable condVar; - #define IE_EXPECT_OK(...) EXPECT_EQ(IEStatusCode::OK, __VA_ARGS__) #define IE_ASSERT_OK(...) ASSERT_EQ(IEStatusCode::OK, __VA_ARGS__) #define IE_EXPECT_NOT_OK(...) EXPECT_NE(IEStatusCode::OK, __VA_ARGS__) -inline size_t read_image_from_file(const char* img_path, unsigned char *img_data, size_t size) { - FILE *fp = fopen(img_path, "rb+"); - size_t read_size = 0; +static std::mutex m; +static bool ready = false; +static std::condition_variable condVar; - if (fp) { - fseek(fp, 0, SEEK_END); - if (ftell(fp) >= static_cast(size)) { - fseek(fp, 0, SEEK_SET); - read_size = fread(img_data, 1, size, fp); - } - fclose(fp); - } - return read_size; -} +static void completion_callback(void* args) { + ie_infer_request_t* infer_request = (ie_infer_request_t*)args; + ie_blob_t* output_blob = nullptr; -inline size_t find_device(ie_available_devices_t avai_devices, const char *device_name) { - for (size_t i = 0; i < avai_devices.num_devices; ++i) { - if (strstr(avai_devices.devices[i], device_name)) - return i; - } - - return -1; -} - -TEST(ie_c_api_version, apiVersion) { - ie_version_t version = ie_c_api_version(); - auto ver = InferenceEngine::GetInferenceEngineVersion(); - std::string ver_str = ver->buildNumber; - - EXPECT_EQ(strcmp(version.api_version, ver_str.c_str()), 0); - ie_version_free(&version); -} - -static void completion_callback(void *args) { - ie_infer_request_t *infer_request = (ie_infer_request_t *)args; - ie_blob_t *output_blob = nullptr; - - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "Relu_1", &output_blob)); ie_blob_buffer_t buffer; IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer)); - float *output_data = (float *)(buffer.buffer); + float* output_data = (float*)(buffer.buffer); EXPECT_NEAR(output_data[9], 0.f, 1.e-5); ie_blob_free(&output_blob); @@ -80,7 +38,61 @@ static void completion_callback(void *args) { condVar.notify_one(); } -TEST(ie_core_create, coreCreatewithConfig) { +class ie_c_api_test : public ::testing::TestWithParam { +public: + void SetUp() override { + TestDataHelpers::generate_test_model(); + xml_file_name = TestDataHelpers::get_model_xml_file_name(); + bin_file_name = TestDataHelpers::get_model_bin_file_name(); + } + + void TearDown() override { + TestDataHelpers::release_test_model(); + } + +public: + size_t find_device(ie_available_devices_t avai_devices, const char* device_name) { + for (size_t i = 0; i < avai_devices.num_devices; ++i) { + if (strstr(avai_devices.devices[i], device_name)) + return i; + } + + return -1; + } + + std::vector content_from_file(const char* filename, bool is_binary) { + std::vector result; + { + std::ifstream is(filename, is_binary ? std::ifstream::binary | std::ifstream::in : std::ifstream::in); + if (is) { + is.seekg(0, std::ifstream::end); + result.resize(is.tellg()); + if (result.size() > 0) { + is.seekg(0, std::ifstream::beg); + is.read(reinterpret_cast(&result[0]), result.size()); + } + } + } + return result; + } + + std::string xml_file_name, bin_file_name; + const char* input_port_name = "Param_1"; + const char* output_port_name = "Relu_1"; +}; + +INSTANTIATE_TEST_SUITE_P(ie_c_api, ie_c_api_test, ::testing::Values("")); + +TEST_P(ie_c_api_test, ie_c_api_version) { + ie_version_t version = ie_c_api_version(); + auto ver = InferenceEngine::GetInferenceEngineVersion(); + std::string ver_str = ver->buildNumber; + + EXPECT_EQ(strcmp(version.api_version, ver_str.c_str()), 0); + ie_version_free(&version); +} + +TEST_P(ie_c_api_test, ie_core_create_coreCreatewithConfig) { std::string plugins_xml = TestDataHelpers::generate_test_xml_file(); ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create(plugins_xml.c_str(), &core)); @@ -90,7 +102,7 @@ TEST(ie_core_create, coreCreatewithConfig) { TestDataHelpers::delete_test_xml_file(); } -TEST(ie_core_create, coreCreateNoConfig) { +TEST_P(ie_c_api_test, ie_core_create_coreCreateNoConfig) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -98,7 +110,7 @@ TEST(ie_core_create, coreCreateNoConfig) { ie_core_free(&core); } -TEST(ie_core_get_available_devices, getAvailableDevices) { +TEST_P(ie_c_api_test, ie_core_get_available_devices) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); @@ -112,7 +124,7 @@ TEST(ie_core_get_available_devices, getAvailableDevices) { // TODO: CVS-68982 #ifndef OPENVINO_STATIC_LIBRARY -TEST(ie_core_register_plugin, registerPlugin) { +TEST_P(ie_c_api_test, ie_core_register_plugin) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -124,7 +136,7 @@ TEST(ie_core_register_plugin, registerPlugin) { ie_core_free(&core); } -TEST(ie_core_register_plugins, registerPlugins) { +TEST_P(ie_c_api_test, ie_core_register_plugins) { std::string plugins_xml = TestDataHelpers::generate_test_xml_file(); ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); @@ -136,7 +148,7 @@ TEST(ie_core_register_plugins, registerPlugins) { TestDataHelpers::delete_test_xml_file(); } -TEST(ie_core_unload_plugin, unloadPlugin) { +TEST_P(ie_c_api_test, ie_core_unload_plugin) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -154,7 +166,7 @@ TEST(ie_core_unload_plugin, unloadPlugin) { #endif // !OPENVINO_STATIC_LIBRARY -TEST(ie_core_set_config, setConfig) { +TEST_P(ie_c_api_test, ie_core_set_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -166,7 +178,7 @@ TEST(ie_core_set_config, setConfig) { ie_core_free(&core); } -TEST(ie_core_get_metric, getMetric) { +TEST_P(ie_c_api_test, ie_core_get_metric) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -181,7 +193,7 @@ TEST(ie_core_get_metric, getMetric) { ie_core_free(&core); } -TEST(ie_core_get_config, getConfig) { +TEST_P(ie_c_api_test, ie_core_get_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -197,7 +209,7 @@ TEST(ie_core_get_config, getConfig) { ie_core_free(&core); } -TEST(ie_core_get_versions, getVersions) { +TEST_P(ie_c_api_test, ie_core_get_versions) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -210,41 +222,25 @@ TEST(ie_core_get_versions, getVersions) { ie_core_free(&core); } -TEST(ie_core_read_network, networkRead) { +TEST_P(ie_c_api_test, ie_core_read_network) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); ie_network_free(&network); ie_core_free(&core); } -static std::vector content_from_file(const char * filename, bool is_binary) { - std::vector result; - { - std::ifstream is(filename, is_binary ? std::ifstream::binary | std::ifstream::in : std::ifstream::in); - if (is) { - is.seekg(0, std::ifstream::end); - result.resize(is.tellg()); - if (result.size() > 0) { - is.seekg(0, std::ifstream::beg); - is.read(reinterpret_cast(&result[0]), result.size()); - } - } - } - return result; -} - -TEST(ie_core_read_network_from_memory, networkReadFromMemory) { +TEST_P(ie_c_api_test, ie_core_read_network_from_memory) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); - std::vector weights_content(content_from_file(bin, true)); + std::vector weights_content(content_from_file(bin_file_name.c_str(), true)); tensor_desc_t weights_desc { ANY, { 1, { weights_content.size() } }, U8 }; ie_blob_t *weights_blob = nullptr; @@ -252,7 +248,7 @@ TEST(ie_core_read_network_from_memory, networkReadFromMemory) { EXPECT_NE(nullptr, weights_blob); if (weights_blob != nullptr) { - std::vector xml_content(content_from_file(xml, false)); + std::vector xml_content(content_from_file(xml_file_name.c_str(), false)); ie_network_t *network = nullptr; IE_EXPECT_OK(ie_core_read_network_from_memory(core, xml_content.data(), xml_content.size(), weights_blob, &network)); @@ -265,7 +261,7 @@ TEST(ie_core_read_network_from_memory, networkReadFromMemory) { ie_core_free(&core); } -TEST(ie_core_export_network_to_file, exportNetworktoFile) { +TEST_P(ie_c_api_test, ie_core_export_network_to_file) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -273,10 +269,10 @@ TEST(ie_core_export_network_to_file, exportNetworktoFile) { ie_config_t config = {nullptr, nullptr, nullptr}; ie_executable_network_t *exe_network = nullptr; - IE_EXPECT_OK(ie_core_load_network_from_file(core, xml, "HETERO:CPU", &config, &exe_network)); + IE_EXPECT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "HETERO:CPU", &config, &exe_network)); EXPECT_NE(nullptr, exe_network); - std::string export_path = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); + std::string export_path = TestDataHelpers::get_exported_blob_file_name(); IE_EXPECT_OK(ie_core_export_network(exe_network, export_path.c_str())); std::ifstream file(export_path.c_str()); EXPECT_NE(file.peek(), std::ifstream::traits_type::eof()); @@ -286,17 +282,17 @@ TEST(ie_core_export_network_to_file, exportNetworktoFile) { ie_core_free(&core); } -TEST(ie_core_import_network_from_memory, importNetworkFromMem) { +TEST_P(ie_c_api_test, ie_core_import_network_from_memory) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_executable_network_t *exe_network = nullptr; - IE_EXPECT_OK(ie_core_load_network_from_file(core, xml, "HETERO:CPU", nullptr, &exe_network)); + IE_EXPECT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "HETERO:CPU", nullptr, &exe_network)); EXPECT_NE(nullptr, exe_network); - std::string export_path = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); + std::string export_path = TestDataHelpers::get_exported_blob_file_name(); IE_EXPECT_OK(ie_core_export_network(exe_network, export_path.c_str())); std::vector buffer(content_from_file(export_path.c_str(), true)); @@ -310,7 +306,7 @@ TEST(ie_core_import_network_from_memory, importNetworkFromMem) { ie_core_free(&core); } -TEST(ie_core_import_network_from_file, importNetworkFromFile) { +TEST_P(ie_c_api_test, ie_core_import_network_from_file) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -318,10 +314,10 @@ TEST(ie_core_import_network_from_file, importNetworkFromFile) { ie_config_t conf = {nullptr, nullptr, nullptr}; ie_executable_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_load_network_from_file(core, xml, "HETERO:CPU", &conf, &network)); + IE_EXPECT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "HETERO:CPU", &conf, &network)); EXPECT_NE(nullptr, network); - std::string exported_model = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); + std::string exported_model = TestDataHelpers::get_exported_blob_file_name(); IE_EXPECT_OK(ie_core_export_network(network, exported_model.c_str())); std::ifstream file(exported_model); EXPECT_NE(file.peek(), std::ifstream::traits_type::eof()); @@ -335,7 +331,7 @@ TEST(ie_core_import_network_from_file, importNetworkFromFile) { ie_core_free(&core); } -TEST(ie_core_import_network_from_file, importNetwork_errorHandling) { +TEST_P(ie_c_api_test, ie_core_import_network_from_file_errorHandling) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -343,10 +339,10 @@ TEST(ie_core_import_network_from_file, importNetwork_errorHandling) { ie_config_t config = {nullptr, nullptr, nullptr}; ie_executable_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_load_network_from_file(core, xml, "HETERO:CPU", &config, &network)); + IE_EXPECT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "HETERO:CPU", &config, &network)); EXPECT_NE(nullptr, network); - std::string exported_model = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); + std::string exported_model = TestDataHelpers::get_exported_blob_file_name(); IE_EXPECT_OK(ie_core_export_network(network, exported_model.c_str())); ie_executable_network_t *exe_network = nullptr; @@ -370,17 +366,17 @@ TEST(ie_core_import_network_from_file, importNetwork_errorHandling) { ie_core_free(&core); } -TEST(ie_core_load_network, loadNetwork) { +TEST_P(ie_c_api_test, ie_core_load_network_with_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_layout(network, "data", layout_e::NHWC)); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_layout(network, input_port_name, layout_e::NHWC)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); ie_config_t config = {"CPU_THREADS_NUM", "3", nullptr}; ie_executable_network_t *exe_network = nullptr; @@ -392,13 +388,13 @@ TEST(ie_core_load_network, loadNetwork) { ie_core_free(&core); } -TEST(ie_core_load_network, loadNetworkNoConfig) { +TEST_P(ie_c_api_test, ie_core_load_network_no_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); ie_config_t config = {nullptr, nullptr, nullptr}; @@ -411,13 +407,13 @@ TEST(ie_core_load_network, loadNetworkNoConfig) { ie_core_free(&core); } -TEST(ie_core_load_network, loadNetworkNullConfig) { +TEST_P(ie_c_api_test, ie_core_load_network_null_Config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); ie_executable_network_t *exe_network = nullptr; @@ -429,27 +425,27 @@ TEST(ie_core_load_network, loadNetworkNullConfig) { ie_core_free(&core); } -TEST(ie_core_load_network_from_file, loadNetworkNoConfig) { +TEST_P(ie_c_api_test, ie_core_load_network_from_file_no_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_config_t config = {nullptr, nullptr, nullptr}; ie_executable_network_t *exe_network = nullptr; - IE_EXPECT_OK(ie_core_load_network_from_file(core, xml, "CPU", &config, &exe_network)); + IE_EXPECT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "CPU", &config, &exe_network)); EXPECT_NE(nullptr, exe_network); ie_exec_network_free(&exe_network); ie_core_free(&core); } -TEST(ie_core_load_network_from_file, loadNetworkNullConfig) { +TEST_P(ie_c_api_test, ie_core_load_network_from_file_null_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_executable_network_t *exe_network = nullptr; - IE_EXPECT_OK(ie_core_load_network_from_file(core, xml, "CPU", nullptr, &exe_network)); + IE_EXPECT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "CPU", nullptr, &exe_network)); EXPECT_NE(nullptr, exe_network); ie_exec_network_free(&exe_network); @@ -457,57 +453,57 @@ TEST(ie_core_load_network_from_file, loadNetworkNullConfig) { } -TEST(ie_core_load_network_from_file, loadNetwork_errorHandling) { +TEST_P(ie_c_api_test, ie_core_load_network_from_file_errorHandling) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_config_t config = {nullptr, nullptr, nullptr}; ie_executable_network_t *exe_network = nullptr; - IE_EXPECT_NOT_OK(ie_core_load_network_from_file(nullptr, xml, "CPU", &config, &exe_network)); + IE_EXPECT_NOT_OK(ie_core_load_network_from_file(nullptr, xml_file_name.c_str(), "CPU", &config, &exe_network)); EXPECT_EQ(nullptr, exe_network); IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, nullptr, "CPU", &config, &exe_network)); EXPECT_EQ(nullptr, exe_network); - IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, xml, nullptr, &config, &exe_network)); + IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), nullptr, &config, &exe_network)); EXPECT_EQ(nullptr, exe_network); - IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, xml, "CPU", &config, nullptr)); + IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "CPU", &config, nullptr)); EXPECT_EQ(nullptr, exe_network); - IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, xml, "UnregisteredDevice", &config, &exe_network)); + IE_EXPECT_NOT_OK(ie_core_load_network_from_file(core, xml_file_name.c_str(), "UnregisteredDevice", &config, &exe_network)); EXPECT_EQ(nullptr, exe_network); ie_core_free(&core); } -TEST(ie_network_get_name, networkName) { +TEST_P(ie_c_api_test, ie_network_get_name) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); char *network_name = nullptr; IE_EXPECT_OK(ie_network_get_name(network, &network_name)); - EXPECT_STREQ(network_name, "test_model"); + EXPECT_NE(network_name, nullptr); ie_network_name_free(&network_name); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_inputs_number, inputNumer) { +TEST_P(ie_c_api_test, ie_network_get_inputs_number) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); size_t size; @@ -519,50 +515,49 @@ TEST(ie_network_get_inputs_number, inputNumer) { ie_core_free(&core); } -TEST(ie_network_get_input_name, inputName) { +TEST_P(ie_c_api_test, ie_network_get_input_name) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); char *input_name = nullptr; IE_EXPECT_OK(ie_network_get_input_name(network, 0, &input_name)); - EXPECT_STREQ(input_name, "data"); + EXPECT_STREQ(input_name, input_port_name); ie_network_name_free(&input_name); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_input_precision, getPrecision) { +TEST_P(ie_c_api_test, ie_network_get_input_precision) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; precision_e p; - IE_EXPECT_OK(ie_network_get_input_precision(network, name, &p)); + IE_EXPECT_OK(ie_network_get_input_precision(network, input_port_name, &p)); EXPECT_EQ(p, precision_e::FP32); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_input_precision, incorrectName) { +TEST_P(ie_c_api_test, ie_network_get_input_precision_incorrectName) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); const char *name = "model"; @@ -573,170 +568,162 @@ TEST(ie_network_get_input_precision, incorrectName) { ie_core_free(&core); } -TEST(ie_network_set_input_precision, setPrecision) { +TEST_P(ie_c_api_test, ie_network_set_input_precision) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; const precision_e p = precision_e::FP16; - IE_EXPECT_OK(ie_network_set_input_precision(network, name, p)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, p)); precision_e p2; - IE_EXPECT_OK(ie_network_get_input_precision(network, name, &p2)); + IE_EXPECT_OK(ie_network_get_input_precision(network, input_port_name, &p2)); EXPECT_EQ(p, p2); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_input_layout, getLayout) { +TEST_P(ie_c_api_test, ie_network_get_input_layout) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; layout_e l; - IE_EXPECT_OK(ie_network_get_input_layout(network, name, &l)); + IE_EXPECT_OK(ie_network_get_input_layout(network, input_port_name, &l)); EXPECT_EQ(l, layout_e::NCHW); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_set_input_layout, setLayout) { +TEST_P(ie_c_api_test, ie_network_set_input_layout) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; const layout_e l = layout_e ::NHWC; - IE_EXPECT_OK(ie_network_set_input_layout(network, name, l)); + IE_EXPECT_OK(ie_network_set_input_layout(network, input_port_name, l)); layout_e l2; - IE_EXPECT_OK(ie_network_get_input_layout(network, name, &l2)); + IE_EXPECT_OK(ie_network_get_input_layout(network, input_port_name, &l2)); EXPECT_EQ(l, l2); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_input_dims, getDims) { +TEST_P(ie_c_api_test, ie_network_get_input_dims) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; dimensions_t dims_res; - IE_EXPECT_OK(ie_network_get_input_dims(network, name, &dims_res)); + IE_EXPECT_OK(ie_network_get_input_dims(network, input_port_name, &dims_res)); EXPECT_EQ(dims_res.dims[0], 1); EXPECT_EQ(dims_res.dims[1], 3); - EXPECT_EQ(dims_res.dims[2], 32); - EXPECT_EQ(dims_res.dims[3], 32); + EXPECT_EQ(dims_res.dims[2], 227); + EXPECT_EQ(dims_res.dims[3], 227); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_input_resize_algorithm, getResizeAlgo) { +TEST_P(ie_c_api_test, ie_network_get_input_resize_algorithm_resize_algo) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; resize_alg_e resizeAlg; - IE_EXPECT_OK(ie_network_get_input_resize_algorithm(network, name, &resizeAlg)); + IE_EXPECT_OK(ie_network_get_input_resize_algorithm(network, input_port_name, &resizeAlg)); EXPECT_EQ(resizeAlg, resize_alg_e::NO_RESIZE); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_set_input_resize_algorithm, setResizeAlgo) { +TEST_P(ie_c_api_test, ie_network_set_input_resize_algorithm_resize_algo) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; resize_alg_e resizeAlg = resize_alg_e::RESIZE_BILINEAR; - IE_EXPECT_OK(ie_network_set_input_resize_algorithm(network, name, resizeAlg)); + IE_EXPECT_OK(ie_network_set_input_resize_algorithm(network, input_port_name, resizeAlg)); resize_alg_e resizeAlg2; - IE_EXPECT_OK(ie_network_get_input_resize_algorithm(network, name, &resizeAlg2)); + IE_EXPECT_OK(ie_network_get_input_resize_algorithm(network, input_port_name, &resizeAlg2)); EXPECT_EQ(resizeAlg, resizeAlg2); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_color_format, getColorFormat) { +TEST_P(ie_c_api_test, ie_network_get_color_format) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; colorformat_e color; - IE_EXPECT_OK(ie_network_get_color_format(network, name, &color)); + IE_EXPECT_OK(ie_network_get_color_format(network, input_port_name, &color)); EXPECT_EQ(color, colorformat_e::RAW); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_set_color_format, setColorFormat) { +TEST_P(ie_c_api_test, ie_network_set_color_format) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "data"; const colorformat_e color = colorformat_e::BGR; - IE_EXPECT_OK(ie_network_set_color_format(network, name, color)); + IE_EXPECT_OK(ie_network_set_color_format(network, input_port_name, color)); colorformat_e color2; - IE_EXPECT_OK(ie_network_get_color_format(network, name, &color2)); + IE_EXPECT_OK(ie_network_get_color_format(network, input_port_name, &color2)); EXPECT_EQ(color2, colorformat_e::BGR); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_input_shapes, getInputShapes) { +TEST_P(ie_c_api_test, ie_network_get_input_shapes) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); input_shapes_t shapes; @@ -748,13 +735,13 @@ TEST(ie_network_get_input_shapes, getInputShapes) { ie_core_free(&core); } -TEST(ie_network_reshape, reshape) { +TEST_P(ie_c_api_test, ie_network_reshape) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); input_shapes_t inputShapes; @@ -774,13 +761,13 @@ TEST(ie_network_reshape, reshape) { ie_core_free(&core); } -TEST(ie_network_get_outputs_number, getNumber) { +TEST_P(ie_c_api_test, ie_network_get_outputs_number) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); size_t size; @@ -791,31 +778,31 @@ TEST(ie_network_get_outputs_number, getNumber) { ie_core_free(&core); } -TEST(ie_network_get_output_name, getName) { +TEST_P(ie_c_api_test, ie_network_get_output_name) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); char *output_name = nullptr; IE_EXPECT_OK(ie_network_get_output_name(network, 0, &output_name)); - EXPECT_STREQ(output_name, "fc_out"); + EXPECT_STREQ(output_name, output_port_name); ie_network_name_free(&output_name); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_output_name, incorrectNumber) { +TEST_P(ie_c_api_test, ie_network_get_output_name_incorrectNumber) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); char *output_name = nullptr; @@ -826,109 +813,104 @@ TEST(ie_network_get_output_name, incorrectNumber) { ie_core_free(&core); } -TEST(ie_network_get_output_precision, getPrecision) { +TEST_P(ie_c_api_test, ie_network_get_output_precision) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "fc_out"; precision_e p; - IE_EXPECT_OK(ie_network_get_output_precision(network, name, &p)); + IE_EXPECT_OK(ie_network_get_output_precision(network, output_port_name, &p)); EXPECT_EQ(p, precision_e::FP32); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_set_output_precision, setPrecision) { +TEST_P(ie_c_api_test, ie_network_set_output_precision) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "fc_out"; precision_e p = precision_e::FP16; - IE_EXPECT_OK(ie_network_set_output_precision(network, name, p)); + IE_EXPECT_OK(ie_network_set_output_precision(network, output_port_name, p)); precision_e precision_res; - IE_EXPECT_OK(ie_network_get_output_precision(network, name, &precision_res)); + IE_EXPECT_OK(ie_network_get_output_precision(network, output_port_name, &precision_res)); EXPECT_EQ(p, precision_res); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_output_layout, getLayout) { +TEST_P(ie_c_api_test, ie_network_get_output_layout) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "fc_out"; layout_e l; - IE_EXPECT_OK(ie_network_get_output_layout(network, name, &l)); - EXPECT_EQ(l, layout_e::NC); + IE_EXPECT_OK(ie_network_get_output_layout(network, output_port_name, &l)); + EXPECT_EQ(l, layout_e::NCHW); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_set_output_layout, setLayout) { +TEST_P(ie_c_api_test, ie_network_set_output_layout) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "fc_out"; - layout_e l = layout_e::CN; - IE_EXPECT_OK(ie_network_set_output_layout(network, name, l)); + layout_e l = layout_e::NCHW; + IE_EXPECT_OK(ie_network_set_output_layout(network, output_port_name, l)); layout_e l_res; - IE_EXPECT_OK(ie_network_get_output_layout(network, name, &l_res)); + IE_EXPECT_OK(ie_network_get_output_layout(network, output_port_name, &l_res)); EXPECT_EQ(l, l_res); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_network_get_output_dims, getDims) { +TEST_P(ie_c_api_test, ie_network_get_output_dims) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - const char *name = "fc_out"; dimensions_t dims_res; - IE_EXPECT_OK(ie_network_get_output_dims(network, name, &dims_res)); + IE_EXPECT_OK(ie_network_get_output_dims(network, output_port_name, &dims_res)); EXPECT_EQ(dims_res.dims[0], 1); - EXPECT_EQ(dims_res.dims[1], 10); + EXPECT_EQ(dims_res.dims[1], 4); ie_network_free(&network); ie_core_free(&core); } -TEST(ie_exec_network_create_infer_request, createInferRquest) { +TEST_P(ie_c_api_test, ie_exec_network_create_infer_request) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); const char *device_name = "CPU"; @@ -947,13 +929,13 @@ TEST(ie_exec_network_create_infer_request, createInferRquest) { ie_core_free(&core); } -TEST(ie_exec_network_get_config, getConfig) { +TEST_P(ie_c_api_test, ie_exec_network_get_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); const char *device_name = "CPU"; @@ -972,7 +954,7 @@ TEST(ie_exec_network_get_config, getConfig) { ie_core_free(&core); } -TEST(ie_exec_network_set_config, setConfig) { +TEST_P(ie_c_api_test, ie_exec_network_set_config) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -984,7 +966,7 @@ TEST(ie_exec_network_set_config, setConfig) { } ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); const char *device_name = "MULTI:GPU,CPU"; @@ -1002,13 +984,13 @@ TEST(ie_exec_network_set_config, setConfig) { ie_param_free(¶m); } -TEST(ie_exec_network_get_metric, getMetric) { +TEST_P(ie_c_api_test, ie_exec_network_get_metric) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); const char *device_name = "CPU"; @@ -1027,13 +1009,13 @@ TEST(ie_exec_network_get_metric, getMetric) { ie_core_free(&core); } -TEST(ie_infer_request_get_blob, getBlob) { +TEST_P(ie_c_api_test, ie_infer_request_get_blob) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); char *input_name = nullptr; @@ -1059,21 +1041,21 @@ TEST(ie_infer_request_get_blob, getBlob) { ie_core_free(&core); } -TEST(ie_infer_request_set_blob, setBlob) { +TEST_P(ie_c_api_test, ie_infer_request_set_blob) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); dimensions_t dim_t; precision_e p = precision_e::U8; layout_e l = layout_e::NCHW; - IE_EXPECT_OK(ie_network_get_input_dims(network, "data", &dim_t)); - IE_EXPECT_OK(ie_network_set_input_layout(network, "data", l)); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", p)); + IE_EXPECT_OK(ie_network_get_input_dims(network, input_port_name, &dim_t)); + IE_EXPECT_OK(ie_network_set_input_layout(network, input_port_name, l)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, p)); const char *device_name = "CPU"; ie_config_t config = {nullptr, nullptr, nullptr}; @@ -1092,7 +1074,7 @@ TEST(ie_infer_request_set_blob, setBlob) { ie_blob_t *blob = nullptr; IE_EXPECT_OK(ie_blob_make_memory(&tensor, &blob)); - IE_EXPECT_OK(ie_infer_request_set_blob(infer_request, "data", blob)); + IE_EXPECT_OK(ie_infer_request_set_blob(infer_request, input_port_name, blob)); ie_blob_deallocate(&blob); ie_infer_request_free(&infer_request); @@ -1101,16 +1083,16 @@ TEST(ie_infer_request_set_blob, setBlob) { ie_core_free(&core); } -TEST(ie_infer_request_infer, infer) { +TEST_P(ie_c_api_test, ie_infer_request_infer) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); const char *device_name = "CPU"; ie_config_t config = {nullptr, nullptr, nullptr}; @@ -1123,7 +1105,7 @@ TEST(ie_infer_request_infer, infer) { EXPECT_NE(nullptr, infer_request); ie_blob_t *blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, input_port_name, &blob)); dimensions_t dims; IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); @@ -1137,11 +1119,11 @@ TEST(ie_infer_request_infer, infer) { IE_EXPECT_OK(ie_infer_request_infer(infer_request)); ie_blob_t *output_blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, output_port_name, &output_blob)); dimensions_t dim_res; IE_EXPECT_OK(ie_blob_get_dims(output_blob, &dim_res)); - EXPECT_EQ(dim_res.ranks, 2); - EXPECT_EQ(dim_res.dims[1], 10); + EXPECT_EQ(dim_res.ranks, 4); + EXPECT_EQ(dim_res.dims[1], 4); ie_blob_buffer_t out_buffer; IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer)); @@ -1156,16 +1138,16 @@ TEST(ie_infer_request_infer, infer) { ie_core_free(&core); } -TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) { +TEST_P(ie_c_api_test, ie_infer_request_infer_async_wait_finish) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); const char *device_name = "CPU"; ie_config_t config = {nullptr, nullptr, nullptr}; @@ -1178,7 +1160,7 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) { EXPECT_NE(nullptr, infer_request); ie_blob_t *blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, input_port_name, &blob)); dimensions_t dims; IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); @@ -1195,7 +1177,7 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) { if (!HasFatalFailure()) { IE_EXPECT_OK(ie_infer_request_wait(infer_request, -1)); - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, output_port_name, &output_blob)); EXPECT_NE(nullptr, output_blob); ie_blob_buffer_t out_buffer; @@ -1212,16 +1194,16 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitFinish) { ie_core_free(&core); } -TEST(ie_infer_request_infer_async, inferAsyncWaitTime) { +TEST_P(ie_c_api_test, ie_infer_request_infer_async_wait_time) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); const char *device_name = "CPU"; ie_config_t config = {nullptr, nullptr, nullptr}; @@ -1234,7 +1216,7 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) { EXPECT_NE(nullptr, infer_request); ie_blob_t *blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, input_port_name, &blob)); EXPECT_NE(nullptr, blob); dimensions_t dims; @@ -1256,7 +1238,7 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) { IE_EXPECT_OK(ie_infer_request_wait(infer_request, -1)); } - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, output_port_name, &output_blob)); ie_blob_buffer_t out_buffer; IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &out_buffer)); @@ -1274,7 +1256,7 @@ TEST(ie_infer_request_infer_async, inferAsyncWaitTime) { // For ARM plugin, no "Batch" related operations support for now, so skip related APIs #ifndef __aarch64__ -TEST(ie_infer_request_set_batch, setBatch) { +TEST_P(ie_c_api_test, ie_infer_request_set_batch) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -1284,7 +1266,7 @@ TEST(ie_infer_request_set_batch, setBatch) { IE_EXPECT_OK(ie_core_set_config(core, &config, device_name)); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); ie_executable_network_t *exe_network = nullptr; @@ -1303,7 +1285,7 @@ TEST(ie_infer_request_set_batch, setBatch) { ie_core_free(&core); } -TEST(ie_infer_request_set_batch, setZeroBatch) { +TEST_P(ie_c_api_test, ie_infer_request_set_zero_batch) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -1313,7 +1295,7 @@ TEST(ie_infer_request_set_batch, setZeroBatch) { IE_EXPECT_OK(ie_core_set_config(core, &config, device_name)); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); ie_executable_network_t *exe_network = nullptr; @@ -1332,7 +1314,7 @@ TEST(ie_infer_request_set_batch, setZeroBatch) { ie_core_free(&core); } -TEST(ie_infer_request_set_batch, setNegativeBatch) { +TEST_P(ie_c_api_test, ie_infer_request_set_negative_batch) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); @@ -1342,7 +1324,7 @@ TEST(ie_infer_request_set_batch, setNegativeBatch) { IE_EXPECT_OK(ie_core_set_config(core, &config, device_name)); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); ie_executable_network_t *exe_network = nullptr; @@ -1362,7 +1344,7 @@ TEST(ie_infer_request_set_batch, setNegativeBatch) { } #endif -TEST(ie_blob_make_memory, makeMemory) { +TEST_P(ie_c_api_test, ie_blob_make_memory) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1379,7 +1361,7 @@ TEST(ie_blob_make_memory, makeMemory) { ie_blob_deallocate(&blob); } -TEST(ie_blob_make_memory_from_preallocated, makeMemoryfromPreallocated) { +TEST_P(ie_c_api_test, ie_blob_make_memory_from_preallocated) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1398,7 +1380,7 @@ TEST(ie_blob_make_memory_from_preallocated, makeMemoryfromPreallocated) { ie_blob_free(&blob); } -TEST(ie_blob_make_memory_with_roi, makeMemorywithROI) { +TEST_P(ie_c_api_test, ie_blob_make_memory_with_roi) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1421,7 +1403,7 @@ TEST(ie_blob_make_memory_with_roi, makeMemorywithROI) { ie_blob_free(&input_blob); } -TEST(ie_blob_deallocate, blobDeallocate) { +TEST_P(ie_c_api_test, ie_blob_deallocate) { dimensions_t dim_t; dim_t.ranks = 4 ; dim_t.dims[0] = 1, dim_t.dims[1] = 3, dim_t.dims[2] = 4, dim_t.dims[3] = 4; @@ -1437,7 +1419,7 @@ TEST(ie_blob_deallocate, blobDeallocate) { ie_blob_deallocate(&blob); } -TEST(ie_blob_get_dims, getDims) { +TEST_P(ie_c_api_test, ie_blob_get_dims) { dimensions_t dim_t; dim_t.ranks = 4 ; dim_t.dims[0] = 1, dim_t.dims[1] = 3, dim_t.dims[2] = 4, dim_t.dims[3] = 4; @@ -1457,7 +1439,7 @@ TEST(ie_blob_get_dims, getDims) { ie_blob_deallocate(&blob); } -TEST(ie_blob_get_layout, getLayout) { +TEST_P(ie_c_api_test, ie_blob_get_layout) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1478,7 +1460,7 @@ TEST(ie_blob_get_layout, getLayout) { ie_blob_deallocate(&blob); } -TEST(ie_blob_get_precision, getPrecision) { +TEST_P(ie_c_api_test, ie_blob_get_precision) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1500,7 +1482,7 @@ TEST(ie_blob_get_precision, getPrecision) { ie_blob_deallocate(&blob); } -TEST(ie_blob_size, getSize) { +TEST_P(ie_c_api_test, ie_blob_size) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1521,7 +1503,7 @@ TEST(ie_blob_size, getSize) { ie_blob_deallocate(&blob); } -TEST(ie_blob_byte_size, getByteSize) { +TEST_P(ie_c_api_test, ie_blob_byte_size) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1542,7 +1524,7 @@ TEST(ie_blob_byte_size, getByteSize) { ie_blob_deallocate(&blob); } -TEST(ie_blob_get_buffer, getBuffer) { +TEST_P(ie_c_api_test, ie_blob_get_buffer) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1563,7 +1545,7 @@ TEST(ie_blob_get_buffer, getBuffer) { ie_blob_deallocate(&blob); } -TEST(ie_blob_get_cbuffer, getBuffer) { +TEST_P(ie_c_api_test, ie_blob_get_cbuffer) { dimensions_t dim_t; dim_t.ranks = 4 ; @@ -1584,16 +1566,16 @@ TEST(ie_blob_get_cbuffer, getBuffer) { ie_blob_deallocate(&blob); } -TEST(ie_infer_set_completion_callback, setCallback) { +TEST_P(ie_c_api_test, ie_infer_set_completion_callback) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); const char *device_name = "CPU"; ie_config_t config = {nullptr, nullptr, nullptr}; @@ -1606,7 +1588,7 @@ TEST(ie_infer_set_completion_callback, setCallback) { EXPECT_NE(nullptr, infer_request); ie_blob_t *blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "data", &blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, input_port_name, &blob)); dimensions_t dims; IE_EXPECT_OK(ie_blob_get_dims(blob, &dims)); @@ -1637,7 +1619,7 @@ TEST(ie_infer_set_completion_callback, setCallback) { ie_core_free(&core); } -TEST(ie_blob_make_memory_nv12, makeNV12Blob) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1655,7 +1637,7 @@ TEST(ie_blob_make_memory_nv12, makeNV12Blob) { ie_blob_deallocate(&blob_uv); } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobFromNullptrBlobs) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobFromNullptrBlobs) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1672,7 +1654,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobFromNullptrBlobs) { IE_EXPECT_NOT_OK(ie_blob_make_memory_nv12(blob_y, blob_uv, &blob_nv12)); } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobFromPlanesWithDifferentElementSize) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobFromPlanesWithDifferentElementSize) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1691,7 +1673,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobFromPlanesWithDifferentElementS ie_blob_deallocate(&blob_uv); } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobFromPlanesWithNonU8Precision) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobFromPlanesWithNonU8Precision) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1709,7 +1691,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobFromPlanesWithNonU8Precision) { ie_blob_deallocate(&blob_uv); } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithInconsistentBatchSize) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobWithInconsistentBatchSize) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {2, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1727,7 +1709,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithInconsistentBatchSize) { ie_blob_deallocate(&blob_uv); } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithWrongChannelNumber) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobWithWrongChannelNumber) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1747,7 +1729,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithWrongChannelNumber) { ie_blob_deallocate(&blob_uv); } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithWrongHeightRation) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobWithWrongHeightRation) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 2, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1766,7 +1748,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithWrongHeightRation) { } -TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithWrongWidthRation) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_cannotMakeNV12BlobWithWrongWidthRation) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 4}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1784,7 +1766,7 @@ TEST(ie_blob_make_memory_nv12, cannotMakeNV12BlobWithWrongWidthRation) { ie_blob_deallocate(&blob_uv); } -TEST(ie_blob_make_memory_nv12, NV12BlobInvalidAfterDeallocateYPlane) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_NV12BlobInvalidAfterDeallocateYPlane) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1806,7 +1788,7 @@ TEST(ie_blob_make_memory_nv12, NV12BlobInvalidAfterDeallocateYPlane) { ie_blob_free(&blob_nv12); } -TEST(ie_blob_make_memory_nv12, NV12BlobInvalidAfterDeallocateUVPlane) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_NV12BlobInvalidAfterDeallocateUVPlane) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_uv = {4, {1, 2, 4, 6}}; tensor_desc tensor_y, tensor_uv; tensor_y.dims = dim_y; @@ -1830,20 +1812,20 @@ TEST(ie_blob_make_memory_nv12, NV12BlobInvalidAfterDeallocateUVPlane) { #ifdef ENABLE_GAPI_PREPROCESSING -TEST(ie_blob_make_memory_nv12, inferRequestWithNV12Blob) { +TEST_P(ie_c_api_test, ie_blob_make_memory_nv12_inferRequestWithNV12Blob) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); - IE_EXPECT_OK(ie_network_set_input_layout(network, "data", layout_e::NCHW)); - IE_EXPECT_OK(ie_network_set_input_resize_algorithm(network, "data", resize_alg_e::RESIZE_BILINEAR)); - IE_EXPECT_OK(ie_network_set_color_format(network, "data", colorformat_e::NV12)); - IE_EXPECT_OK(ie_network_set_output_precision(network, "fc_out", precision_e::FP32)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_layout(network, input_port_name, layout_e::NCHW)); + IE_EXPECT_OK(ie_network_set_input_resize_algorithm(network, input_port_name, resize_alg_e::RESIZE_BILINEAR)); + IE_EXPECT_OK(ie_network_set_color_format(network, input_port_name, colorformat_e::NV12)); + IE_EXPECT_OK(ie_network_set_output_precision(network, output_port_name, precision_e::FP32)); ie_config_t config = {nullptr, nullptr, nullptr}; ie_executable_network_t *exe_network = nullptr; @@ -1858,7 +1840,7 @@ TEST(ie_blob_make_memory_nv12, inferRequestWithNV12Blob) { size_t img_size = img_width * (img_height * 3 / 2); unsigned char *img_data = (unsigned char *)calloc(img_size, sizeof(unsigned char)); EXPECT_NE(nullptr, img_data); - EXPECT_EQ(img_size, read_image_from_file(input_image_nv12, img_data, img_size)); + TestDataHelpers::fill_random_input_nv12_data(img_data, img_width, img_height); dimensions_t dim_y = {4, {1, 1, img_height, img_width}}; dimensions_t dim_uv = {4, {1, 2, img_height / 2, img_width / 2}}; @@ -1874,21 +1856,17 @@ TEST(ie_blob_make_memory_nv12, inferRequestWithNV12Blob) { IE_EXPECT_OK(ie_blob_make_memory_from_preallocated(&tensor_uv, img_data + offset, img_width * (img_height / 2), &blob_uv)); IE_EXPECT_OK(ie_blob_make_memory_nv12(blob_y, blob_uv, &blob_nv12)); - IE_EXPECT_OK(ie_infer_request_set_blob(infer_request, "data", blob_nv12)); + IE_EXPECT_OK(ie_infer_request_set_blob(infer_request, input_port_name, blob_nv12)); IE_EXPECT_OK(ie_infer_request_infer(infer_request)); ie_blob_t *output_blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, output_port_name, &output_blob)); EXPECT_NE(nullptr, output_blob); ie_blob_buffer_t buffer; buffer.buffer = nullptr; IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer)); EXPECT_NE(buffer.buffer, nullptr); - if (buffer.buffer) { - float *output_data = (float *)(buffer.buffer); - EXPECT_NEAR(output_data[1], 0.f, 1.e-5); - } ie_blob_free(&output_blob); ie_blob_free(&blob_nv12); @@ -1903,7 +1881,7 @@ TEST(ie_blob_make_memory_nv12, inferRequestWithNV12Blob) { #endif // ENABLE_GAPI_PREPROCESSING -TEST(ie_blob_make_memory_i420, makeI420Blob) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -1924,7 +1902,7 @@ TEST(ie_blob_make_memory_i420, makeI420Blob) { ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromNullptrBlobs) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromNullptrBlobs) { dimensions_t dim = {4, {1, 1, 8, 12}}; tensor_desc tensor; tensor.dims = dim; @@ -1939,7 +1917,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromNullptrBlobs) { ie_blob_deallocate(&blob); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithDifferentElementSize) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromPlanesWithDifferentElementSize) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -1960,7 +1938,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithDifferentElementS ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithNonU8Precision) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromPlanesWithNonU8Precision) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -1980,7 +1958,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithNonU8Precision) { ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithInconsistentBatchSize) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromPlanesWithInconsistentBatchSize) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {2, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2000,7 +1978,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithInconsistentBatch ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithWrongChannelNumber) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromPlanesWithWrongChannelNumber) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 2, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2020,7 +1998,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithWrongChannelNumbe ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithWrongWidthRatio) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromPlanesWithWrongWidthRatio) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 4}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2040,7 +2018,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithWrongWidthRatio) ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithWrongHeightRatio) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_cannotMakeI420BlobFromPlanesWithWrongHeightRatio) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 2, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2060,7 +2038,7 @@ TEST(ie_blob_make_memory_i420, cannotMakeI420BlobFromPlanesWithWrongHeightRatio) ie_blob_deallocate(&blob_v); } -TEST(ie_blob_make_memory_i420, I420BlobInvalidAfterDeallocateYPlane) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_I420BlobInvalidAfterDeallocateYPlane) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2085,7 +2063,7 @@ TEST(ie_blob_make_memory_i420, I420BlobInvalidAfterDeallocateYPlane) { ie_blob_free(&blob_i420); } -TEST(ie_blob_make_memory_i420, I420BlobInvalidAfterDeallocateUPlane) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_I420BlobInvalidAfterDeallocateUPlane) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2110,7 +2088,7 @@ TEST(ie_blob_make_memory_i420, I420BlobInvalidAfterDeallocateUPlane) { ie_blob_free(&blob_i420); } -TEST(ie_blob_make_memory_i420, I420BlobInvalidAfterDeallocateVPlane) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_I420BlobInvalidAfterDeallocateVPlane) { dimensions_t dim_y = {4, {1, 1, 8, 12}}, dim_u = {4, {1, 1, 4, 6}}, dim_v = {4, {1, 1, 4, 6}}; tensor_desc tensor_y, tensor_u, tensor_v; tensor_y.dims = dim_y; @@ -2137,20 +2115,20 @@ TEST(ie_blob_make_memory_i420, I420BlobInvalidAfterDeallocateVPlane) { #ifdef ENABLE_GAPI_PREPROCESSING -TEST(ie_blob_make_memory_i420, inferRequestWithI420) { +TEST_P(ie_c_api_test, ie_blob_make_memory_i420_inferRequestWithI420) { ie_core_t *core = nullptr; IE_ASSERT_OK(ie_core_create("", &core)); ASSERT_NE(nullptr, core); ie_network_t *network = nullptr; - IE_EXPECT_OK(ie_core_read_network(core, xml, bin, &network)); + IE_EXPECT_OK(ie_core_read_network(core, xml_file_name.c_str(), bin_file_name.c_str(), &network)); EXPECT_NE(nullptr, network); - IE_EXPECT_OK(ie_network_set_input_precision(network, "data", precision_e::U8)); - IE_EXPECT_OK(ie_network_set_input_layout(network, "data", layout_e::NCHW)); - IE_EXPECT_OK(ie_network_set_input_resize_algorithm(network, "data", resize_alg_e::RESIZE_BILINEAR)); - IE_EXPECT_OK(ie_network_set_color_format(network, "data", colorformat_e::I420)); - IE_EXPECT_OK(ie_network_set_output_precision(network, "fc_out", precision_e::FP32)); + IE_EXPECT_OK(ie_network_set_input_precision(network, input_port_name, precision_e::U8)); + IE_EXPECT_OK(ie_network_set_input_layout(network, input_port_name, layout_e::NCHW)); + IE_EXPECT_OK(ie_network_set_input_resize_algorithm(network, input_port_name, resize_alg_e::RESIZE_BILINEAR)); + IE_EXPECT_OK(ie_network_set_color_format(network, input_port_name, colorformat_e::I420)); + IE_EXPECT_OK(ie_network_set_output_precision(network, output_port_name, precision_e::FP32)); ie_config_t config = {nullptr, nullptr, nullptr}; ie_executable_network_t *exe_network = nullptr; @@ -2165,7 +2143,7 @@ TEST(ie_blob_make_memory_i420, inferRequestWithI420) { size_t img_size = img_width * (img_height * 3 / 2); unsigned char *img_data = (unsigned char *)calloc(img_size, sizeof(unsigned char)); EXPECT_NE(nullptr, img_data); - EXPECT_EQ(img_size, read_image_from_file(input_image_nv12, img_data, img_size)); + TestDataHelpers::fill_random_input_nv12_data(img_data, img_width, img_height); dimensions_t dim_y = {4, {1, 1, img_height, img_width}}; dimensions_t dim_u = {4, {1, 1, img_height / 2, img_width / 2}}; @@ -2184,16 +2162,16 @@ TEST(ie_blob_make_memory_i420, inferRequestWithI420) { IE_EXPECT_OK(ie_blob_make_memory_from_preallocated(&tensor_v, img_data + offset * 5 / 4, img_width * (img_height / 4), &blob_v)); IE_EXPECT_OK(ie_blob_make_memory_i420(blob_y, blob_u, blob_v, &blob_i420)); - IE_EXPECT_OK(ie_infer_request_set_blob(infer_request, "data", blob_i420)); + IE_EXPECT_OK(ie_infer_request_set_blob(infer_request, input_port_name, blob_i420)); IE_EXPECT_OK(ie_infer_request_infer(infer_request)); ie_blob_t *output_blob = nullptr; - IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, "fc_out", &output_blob)); + IE_EXPECT_OK(ie_infer_request_get_blob(infer_request, output_port_name, &output_blob)); ie_blob_buffer_t buffer; IE_EXPECT_OK(ie_blob_get_buffer(output_blob, &buffer)); float *output_data = (float *)(buffer.buffer); - EXPECT_NEAR(output_data[1], 0.f, 1.e-5); + EXPECT_NE(output_data, nullptr); ie_blob_free(&output_blob); ie_blob_free(&blob_i420); diff --git a/src/bindings/c/tests/ov_compiled_model_test.cpp b/src/bindings/c/tests/ov_compiled_model_test.cpp index 8d00f28611c..0ff98f5ba2d 100644 --- a/src/bindings/c/tests/ov_compiled_model_test.cpp +++ b/src/bindings/c/tests/ov_compiled_model_test.cpp @@ -6,18 +6,26 @@ namespace { -class ov_compiled_model : public ::testing::TestWithParam {}; +class ov_compiled_model_test : public ov_capi_test_base { + void SetUp() override { + ov_capi_test_base::SetUp(); + } -INSTANTIATE_TEST_SUITE_P(device_name, ov_compiled_model, ::testing::Values("CPU")); + void TearDown() override { + ov_capi_test_base::TearDown(); + } +}; -TEST_P(ov_compiled_model, ov_compiled_model_inputs_size) { +INSTANTIATE_TEST_SUITE_P(device_name, ov_compiled_model_test, ::testing::Values("CPU")); + +TEST_P(ov_compiled_model_test, ov_compiled_model_inputs_size) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -33,14 +41,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_inputs_size) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_input) { +TEST_P(ov_compiled_model_test, ov_compiled_model_input) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -57,14 +65,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_input) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_input_by_index) { +TEST_P(ov_compiled_model_test, ov_compiled_model_input_by_index) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -85,14 +93,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_input_by_index) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_input_by_name) { +TEST_P(ov_compiled_model_test, ov_compiled_model_input_by_name) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -113,7 +121,7 @@ TEST_P(ov_compiled_model, ov_compiled_model_input_by_name) { ov_core_free(core); } -TEST_P(ov_compiled_model, set_and_get_property) { +TEST_P(ov_compiled_model_test, set_and_get_property) { // It seems that all set_property() for CPU plugin are not implement in compiled_model. auto device_name = "MULTI:GPU,CPU"; ov_core_t* core = nullptr; @@ -128,7 +136,7 @@ TEST_P(ov_compiled_model, set_and_get_property) { } ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -152,14 +160,14 @@ TEST_P(ov_compiled_model, set_and_get_property) { ov_core_free(core); } -TEST_P(ov_compiled_model, get_property) { +TEST_P(ov_compiled_model_test, get_property) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -176,14 +184,14 @@ TEST_P(ov_compiled_model, get_property) { ov_core_free(core); } -TEST_P(ov_compiled_model, create_compiled_model_with_property) { +TEST_P(ov_compiled_model_test, create_compiled_model_with_property) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); const char* key = ov_property_key_hint_performance_mode; @@ -201,14 +209,14 @@ TEST_P(ov_compiled_model, create_compiled_model_with_property) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_outputs_size) { +TEST_P(ov_compiled_model_test, ov_compiled_model_outputs_size) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -224,14 +232,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_outputs_size) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_output) { +TEST_P(ov_compiled_model_test, ov_compiled_model_output) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -248,14 +256,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_output) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_output_by_index) { +TEST_P(ov_compiled_model_test, ov_compiled_model_output_by_index) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -276,14 +284,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_output_by_index) { ov_core_free(core); } -TEST_P(ov_compiled_model, ov_compiled_model_output_by_name) { +TEST_P(ov_compiled_model_test, ov_compiled_model_output_by_name) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -291,7 +299,7 @@ TEST_P(ov_compiled_model, ov_compiled_model_output_by_name) { EXPECT_NE(nullptr, compiled_model); ov_output_const_port_t* output_port = nullptr; - OV_EXPECT_OK(ov_compiled_model_output_by_name(compiled_model, "fc_out", &output_port)); + OV_EXPECT_OK(ov_compiled_model_output_by_name(compiled_model, "relu", &output_port)); EXPECT_NE(nullptr, output_port); ov_shape_t shape; @@ -304,14 +312,14 @@ TEST_P(ov_compiled_model, ov_compiled_model_output_by_name) { ov_core_free(core); } -TEST_P(ov_compiled_model, get_runtime_model) { +TEST_P(ov_compiled_model_test, get_runtime_model) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -328,14 +336,14 @@ TEST_P(ov_compiled_model, get_runtime_model) { ov_core_free(core); } -TEST_P(ov_compiled_model, get_runtime_model_error_handling) { +TEST_P(ov_compiled_model_test, get_runtime_model_error_handling) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -352,14 +360,14 @@ TEST_P(ov_compiled_model, get_runtime_model_error_handling) { ov_core_free(core); } -TEST_P(ov_compiled_model, create_infer_request) { +TEST_P(ov_compiled_model_test, create_infer_request) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -376,14 +384,14 @@ TEST_P(ov_compiled_model, create_infer_request) { ov_core_free(core); } -TEST_P(ov_compiled_model, create_infer_request_error_handling) { +TEST_P(ov_compiled_model_test, create_infer_request_error_handling) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; diff --git a/src/bindings/c/tests/ov_core_test.cpp b/src/bindings/c/tests/ov_core_test.cpp index 5b3fcb5af43..6804504c940 100644 --- a/src/bindings/c/tests/ov_core_test.cpp +++ b/src/bindings/c/tests/ov_core_test.cpp @@ -22,10 +22,19 @@ TEST(ov_util, ov_get_error_info_check) { EXPECT_STREQ(res, str); } -class ov_core : public ::testing::TestWithParam {}; -INSTANTIATE_TEST_SUITE_P(device_name, ov_core, ::testing::Values("CPU")); +class ov_core_test : public ov_capi_test_base { +public: + void SetUp() override { + ov_capi_test_base::SetUp(); + } -TEST(ov_core, ov_core_create_with_config) { + void TearDown() override { + ov_capi_test_base::TearDown(); + } +}; +INSTANTIATE_TEST_SUITE_P(device_name, ov_core_test, ::testing::Values("CPU")); + +TEST_P(ov_core_test, ov_core_create_with_config) { std::string plugins_xml = TestDataHelpers::generate_test_xml_file(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create_with_config(plugins_xml.c_str(), &core)); @@ -34,45 +43,45 @@ TEST(ov_core, ov_core_create_with_config) { TestDataHelpers::delete_test_xml_file(); } -TEST(ov_core, ov_core_create_with_no_config) { +TEST_P(ov_core_test, ov_core_create_with_no_config) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_core_free(core); } -TEST(ov_core, ov_core_read_model) { +TEST_P(ov_core_test, ov_core_read_model) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_model_free(model); ov_core_free(core); } -TEST(ov_core, ov_core_read_model_no_bin) { +TEST_P(ov_core_test, ov_core_read_model_no_bin) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, nullptr, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), nullptr, &model)); EXPECT_NE(nullptr, model); ov_model_free(model); ov_core_free(core); } -TEST(ov_core, ov_core_read_model_from_memory) { +TEST_P(ov_core_test, ov_core_read_model_from_memory) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); - std::vector weights_content(content_from_file(bin, true)); + std::vector weights_content(content_from_file(bin_file_name.c_str(), true)); ov_tensor_t* tensor = nullptr; ov_shape_t shape; @@ -81,7 +90,7 @@ TEST(ov_core, ov_core_read_model_from_memory) { OV_EXPECT_OK(ov_tensor_create_from_host_ptr(ov_element_type_e::U8, shape, weights_content.data(), &tensor)); EXPECT_NE(nullptr, tensor); - std::vector xml_content(content_from_file(xml, false)); + std::vector xml_content(content_from_file(xml_file_name.c_str(), false)); ov_model_t* model = nullptr; OV_EXPECT_OK( ov_core_read_model_from_memory(core, reinterpret_cast(xml_content.data()), tensor, &model)); @@ -93,14 +102,14 @@ TEST(ov_core, ov_core_read_model_from_memory) { ov_core_free(core); } -TEST_P(ov_core, ov_core_compile_model) { +TEST_P(ov_core_test, ov_core_compile_model) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, nullptr, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), nullptr, &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -112,14 +121,14 @@ TEST_P(ov_core, ov_core_compile_model) { ov_core_free(core); } -TEST_P(ov_core, ov_core_compile_model_with_property) { +TEST_P(ov_core_test, ov_core_compile_model_with_property) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, nullptr, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), nullptr, &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -138,14 +147,14 @@ TEST_P(ov_core, ov_core_compile_model_with_property) { ov_core_free(core); } -TEST_P(ov_core, ov_core_compile_model_with_property_invalid) { +TEST_P(ov_core_test, ov_core_compile_model_with_property_invalid) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, nullptr, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), nullptr, &model)); EXPECT_NE(nullptr, model); ov_compiled_model_t* compiled_model = nullptr; @@ -159,21 +168,21 @@ TEST_P(ov_core, ov_core_compile_model_with_property_invalid) { ov_core_free(core); } -TEST_P(ov_core, ov_core_compile_model_from_file) { +TEST_P(ov_core_test, ov_core_compile_model_from_file) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_compiled_model_t* compiled_model = nullptr; - OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml, device_name.c_str(), 0, &compiled_model)); + OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml_file_name.c_str(), device_name.c_str(), 0, &compiled_model)); EXPECT_NE(nullptr, compiled_model); ov_compiled_model_free(compiled_model); ov_core_free(core); } -TEST_P(ov_core, ov_core_set_property_enum) { +TEST_P(ov_core_test, ov_core_set_property_enum) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -186,7 +195,7 @@ TEST_P(ov_core, ov_core_set_property_enum) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_property_invalid_number_property_arguments) { +TEST_P(ov_core_test, ov_core_set_property_invalid_number_property_arguments) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -209,7 +218,7 @@ TEST_P(ov_core, ov_core_set_property_invalid_number_property_arguments) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_property_enum_invalid) { +TEST_P(ov_core_test, ov_core_set_property_enum_invalid) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -232,7 +241,7 @@ TEST_P(ov_core, ov_core_set_property_enum_invalid) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_and_get_property_enum) { +TEST_P(ov_core_test, ov_core_set_and_get_property_enum) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -249,7 +258,7 @@ TEST_P(ov_core, ov_core_set_and_get_property_enum) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_and_get_property_bool) { +TEST_P(ov_core_test, ov_core_set_and_get_property_bool) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -266,7 +275,7 @@ TEST_P(ov_core, ov_core_set_and_get_property_bool) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_and_get_property_bool_invalid) { +TEST_P(ov_core_test, ov_core_set_and_get_property_bool_invalid) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -284,7 +293,7 @@ TEST_P(ov_core, ov_core_set_and_get_property_bool_invalid) { ov_core_free(core); } -TEST_P(ov_core, ov_core_get_property) { +TEST_P(ov_core_test, ov_core_get_property) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -297,7 +306,7 @@ TEST_P(ov_core, ov_core_get_property) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_get_property_str) { +TEST_P(ov_core_test, ov_core_set_get_property_str) { #ifdef __aarch64__ GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported"; #endif @@ -319,7 +328,7 @@ TEST_P(ov_core, ov_core_set_get_property_str) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_get_property_int) { +TEST_P(ov_core_test, ov_core_set_get_property_int) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -337,7 +346,7 @@ TEST_P(ov_core, ov_core_set_get_property_int) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_property_int_invalid) { +TEST_P(ov_core_test, ov_core_set_property_int_invalid) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -353,7 +362,7 @@ TEST_P(ov_core, ov_core_set_property_int_invalid) { ov_core_free(core); } -TEST_P(ov_core, ov_core_set_multiple_common_properties) { +TEST_P(ov_core_test, ov_core_set_multiple_common_properties) { #ifdef __aarch64__ GTEST_SKIP() << "Skip this test for ARM CPU for now, cause no string property supported"; #endif @@ -404,7 +413,7 @@ TEST_P(ov_core, ov_core_set_multiple_common_properties) { ov_core_free(core); } -TEST(ov_core, ov_core_get_available_devices) { +TEST_P(ov_core_test, ov_core_get_available_devices) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); @@ -416,7 +425,7 @@ TEST(ov_core, ov_core_get_available_devices) { ov_core_free(core); } -TEST_P(ov_core, ov_compiled_model_export_model) { +TEST_P(ov_core_test, ov_compiled_model_export_model) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -429,17 +438,17 @@ TEST_P(ov_core, ov_compiled_model_export_model) { } ov_compiled_model_t* compiled_model = nullptr; - OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml, device_name.c_str(), 0, &compiled_model)); + OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml_file_name.c_str(), device_name.c_str(), 0, &compiled_model)); EXPECT_NE(nullptr, compiled_model); - std::string export_path = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); + std::string export_path = TestDataHelpers::get_exported_blob_file_name(); OV_EXPECT_OK(ov_compiled_model_export_model(compiled_model, export_path.c_str())); ov_compiled_model_free(compiled_model); ov_core_free(core); } -TEST_P(ov_core, ov_core_import_model) { +TEST_P(ov_core_test, ov_core_import_model) { auto device_name = GetParam(); ov_core_t* core = nullptr; @@ -453,10 +462,10 @@ TEST_P(ov_core, ov_core_import_model) { } ov_compiled_model_t* compiled_model = nullptr; - OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml, device_name.c_str(), 0, &compiled_model)); + OV_EXPECT_OK(ov_core_compile_model_from_file(core, xml_file_name.c_str(), device_name.c_str(), 0, &compiled_model)); EXPECT_NE(nullptr, compiled_model); - std::string export_path = TestDataHelpers::generate_model_path("test_model", "exported_model.blob"); + std::string export_path = TestDataHelpers::get_exported_blob_file_name(); OV_EXPECT_OK(ov_compiled_model_export_model(compiled_model, export_path.c_str())); ov_compiled_model_free(compiled_model); @@ -472,7 +481,7 @@ TEST_P(ov_core, ov_core_import_model) { ov_core_free(core); } -TEST_P(ov_core, ov_core_get_versions_by_device_name) { +TEST_P(ov_core_test, ov_core_get_versions_by_device_name) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -495,14 +504,14 @@ const std::vector test_unicode_postfix_vector = {L"unicode_Яㅎ L"그것이정당하다", L"АБВГДЕЁЖЗИЙ", L"СТУФХЦЧШЩЬЮЯ"}; -TEST(ov_core, ov_core_create_with_config_unicode) { +TEST_P(ov_core_test, ov_core_create_with_config_unicode) { std::string plugins_xml = TestDataHelpers::generate_test_xml_file(); ov_core_t* core = nullptr; for (std::size_t index = 0; index < test_unicode_postfix_vector.size(); index++) { std::wstring postfix = L"_" + test_unicode_postfix_vector[index]; - std::wstring plugins_xml_ws = add_unicode_postfix_to_path(plugins_xml, postfix); - ASSERT_EQ(true, copy_file(plugins_xml, plugins_xml_ws)); + std::wstring plugins_xml_ws = add_unicode_postfix_to_path(plugins_xml.c_str(), postfix); + ASSERT_EQ(true, copy_file(plugins_xml.c_str(), plugins_xml_ws)); OV_EXPECT_OK(ov_core_create_with_config_unicode(plugins_xml_ws.c_str(), &core)); EXPECT_NE(nullptr, core); @@ -512,7 +521,7 @@ TEST(ov_core, ov_core_create_with_config_unicode) { TestDataHelpers::delete_test_xml_file(); } -TEST(ov_core, ov_core_read_model_unicode) { +TEST_P(ov_core_test, ov_core_read_model_unicode) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); @@ -520,11 +529,11 @@ TEST(ov_core, ov_core_read_model_unicode) { ov_model_t* model = nullptr; for (std::size_t index = 0; index < test_unicode_postfix_vector.size(); index++) { std::wstring postfix = L"_" + test_unicode_postfix_vector[index]; - std::wstring xml_ws = add_unicode_postfix_to_path(xml, postfix); - std::wstring bin_ws = add_unicode_postfix_to_path(bin, postfix); + std::wstring xml_ws = add_unicode_postfix_to_path(xml_file_name.c_str(), postfix); + std::wstring bin_ws = add_unicode_postfix_to_path(bin_file_name.c_str(), postfix); - ASSERT_EQ(true, copy_file(xml, xml_ws)); - ASSERT_EQ(true, copy_file(bin, bin_ws)); + ASSERT_EQ(true, copy_file(xml_file_name.c_str(), xml_ws)); + ASSERT_EQ(true, copy_file(bin_file_name.c_str(), bin_ws)); OV_EXPECT_OK(ov_core_read_model_unicode(core, xml_ws.c_str(), bin_ws.c_str(), &model)); EXPECT_NE(nullptr, model); @@ -537,7 +546,7 @@ TEST(ov_core, ov_core_read_model_unicode) { ov_core_free(core); } -TEST_P(ov_core, ov_core_compile_model_from_file_unicode) { +TEST_P(ov_core_test, ov_core_compile_model_from_file_unicode) { auto device_name = GetParam(); ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); @@ -546,10 +555,10 @@ TEST_P(ov_core, ov_core_compile_model_from_file_unicode) { ov_compiled_model_t* compiled_model = nullptr; for (std::size_t index = 0; index < test_unicode_postfix_vector.size(); index++) { std::wstring postfix = L"_" + test_unicode_postfix_vector[index]; - std::wstring xml_ws = add_unicode_postfix_to_path(xml, postfix); - std::wstring bin_ws = add_unicode_postfix_to_path(bin, postfix); - ASSERT_EQ(true, copy_file(xml, xml_ws)); - ASSERT_EQ(true, copy_file(bin, bin_ws)); + std::wstring xml_ws = add_unicode_postfix_to_path(xml_file_name.c_str(), postfix); + std::wstring bin_ws = add_unicode_postfix_to_path(bin_file_name.c_str(), postfix); + ASSERT_EQ(true, copy_file(xml_file_name.c_str(), xml_ws)); + ASSERT_EQ(true, copy_file(bin_file_name.c_str(), bin_ws)); OV_EXPECT_OK( ov_core_compile_model_from_file_unicode(core, xml_ws.c_str(), device_name.c_str(), 0, &compiled_model)); diff --git a/src/bindings/c/tests/ov_infer_request_test.cpp b/src/bindings/c/tests/ov_infer_request_test.cpp index 721c33a492f..7c1ccd7e268 100644 --- a/src/bindings/c/tests/ov_infer_request_test.cpp +++ b/src/bindings/c/tests/ov_infer_request_test.cpp @@ -30,7 +30,7 @@ inline void get_tensor_info(ov_model_t* model, bool input, char** name, ov_shape ov_output_const_port_free(port); } -class ov_infer_request : public ::testing::TestWithParam { +class ov_infer_request_test : public ov_capi_test_base { protected: void SetUp() override { auto device_name = GetParam(); @@ -43,11 +43,12 @@ protected: infer_request = nullptr; input_const_port = nullptr; input_port = nullptr; + ov_capi_test_base::SetUp(); OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); OV_EXPECT_OK(ov_model_const_input(model, &input_const_port)); @@ -81,6 +82,7 @@ protected: ov_compiled_model_free(compiled_model); ov_model_free(model); ov_core_free(core); + ov_capi_test_base::TearDown(); } public: @@ -97,11 +99,11 @@ public: static bool ready; static std::condition_variable condVar; }; -bool ov_infer_request::ready = false; -std::mutex ov_infer_request::m; -std::condition_variable ov_infer_request::condVar; +bool ov_infer_request_test::ready = false; +std::mutex ov_infer_request_test::m; +std::condition_variable ov_infer_request_test::condVar; -class ov_infer_request_ppp : public ::testing::TestWithParam { +class ov_infer_request_ppp : public ov_capi_test_base { protected: void SetUp() override { auto device_name = GetParam(); @@ -118,11 +120,12 @@ protected: ov_layout_t* model_layout = nullptr; compiled_model = nullptr; infer_request = nullptr; + ov_capi_test_base::SetUp(); OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); @@ -182,6 +185,7 @@ protected: ov_preprocess_prepostprocessor_free(preprocess); ov_model_free(model); ov_core_free(core); + ov_capi_test_base::TearDown(); } public: @@ -198,83 +202,83 @@ public: ov_preprocess_input_model_info_t* input_model; }; -INSTANTIATE_TEST_SUITE_P(device_name, ov_infer_request, ::testing::Values("CPU")); +INSTANTIATE_TEST_SUITE_P(device_name, ov_infer_request_test, ::testing::Values("CPU")); INSTANTIATE_TEST_SUITE_P(device_name, ov_infer_request_ppp, ::testing::Values("CPU")); -TEST_P(ov_infer_request, set_tensor) { +TEST_P(ov_infer_request_test, set_tensor) { OV_EXPECT_OK(ov_infer_request_set_tensor(infer_request, in_tensor_name, input_tensor)); } -TEST_P(ov_infer_request, set_input_tensor_by_index) { +TEST_P(ov_infer_request_test, set_input_tensor_by_index) { OV_EXPECT_OK(ov_infer_request_set_input_tensor_by_index(infer_request, 0, input_tensor)); } -TEST_P(ov_infer_request, set_tensor_by_port) { +TEST_P(ov_infer_request_test, set_tensor_by_port) { OV_EXPECT_OK(ov_infer_request_set_tensor_by_port(infer_request, input_port, input_tensor)); } -TEST_P(ov_infer_request, set_tensor_by_const_port) { +TEST_P(ov_infer_request_test, set_tensor_by_const_port) { OV_EXPECT_OK(ov_infer_request_set_tensor_by_const_port(infer_request, input_const_port, input_tensor)); } -TEST_P(ov_infer_request, set_input_tensor) { +TEST_P(ov_infer_request_test, set_input_tensor) { OV_EXPECT_OK(ov_infer_request_set_input_tensor(infer_request, input_tensor)); } -TEST_P(ov_infer_request, set_output_tensor_by_index) { +TEST_P(ov_infer_request_test, set_output_tensor_by_index) { OV_EXPECT_OK(ov_infer_request_get_output_tensor_by_index(infer_request, 0, &output_tensor)); EXPECT_NE(nullptr, output_tensor); OV_EXPECT_OK(ov_infer_request_set_output_tensor_by_index(infer_request, 0, output_tensor)); } -TEST_P(ov_infer_request, set_output_tensor) { +TEST_P(ov_infer_request_test, set_output_tensor) { OV_EXPECT_OK(ov_infer_request_get_output_tensor_by_index(infer_request, 0, &output_tensor)); EXPECT_NE(nullptr, output_tensor); OV_EXPECT_OK(ov_infer_request_set_output_tensor(infer_request, output_tensor)); } -TEST_P(ov_infer_request, set_tensor_error_handling) { +TEST_P(ov_infer_request_test, set_tensor_error_handling) { OV_EXPECT_NOT_OK(ov_infer_request_set_tensor(nullptr, in_tensor_name, input_tensor)); OV_EXPECT_NOT_OK(ov_infer_request_set_tensor(infer_request, nullptr, input_tensor)); OV_EXPECT_NOT_OK(ov_infer_request_set_tensor(infer_request, in_tensor_name, nullptr)); } -TEST_P(ov_infer_request, get_tensor) { +TEST_P(ov_infer_request_test, get_tensor) { OV_EXPECT_OK(ov_infer_request_get_tensor(infer_request, in_tensor_name, &input_tensor)); EXPECT_NE(nullptr, input_tensor); } -TEST_P(ov_infer_request, get_input_tensor_by_index) { +TEST_P(ov_infer_request_test, get_input_tensor_by_index) { OV_EXPECT_OK(ov_infer_request_get_input_tensor_by_index(infer_request, 0, &output_tensor)); } -TEST_P(ov_infer_request, get_tensor_by_const_port) { +TEST_P(ov_infer_request_test, get_tensor_by_const_port) { OV_EXPECT_OK(ov_infer_request_get_tensor_by_const_port(infer_request, input_const_port, &output_tensor)); } -TEST_P(ov_infer_request, get_tensor_by_port) { +TEST_P(ov_infer_request_test, get_tensor_by_port) { OV_EXPECT_OK(ov_infer_request_get_tensor_by_port(infer_request, input_port, &output_tensor)); } -TEST_P(ov_infer_request, get_input_tensor) { +TEST_P(ov_infer_request_test, get_input_tensor) { OV_EXPECT_OK(ov_infer_request_get_input_tensor(infer_request, &output_tensor)); } -TEST_P(ov_infer_request, get_output_tensor_by_index) { +TEST_P(ov_infer_request_test, get_output_tensor_by_index) { OV_EXPECT_OK(ov_infer_request_get_output_tensor_by_index(infer_request, 0, &output_tensor)); } -TEST_P(ov_infer_request, get_output_tensor) { +TEST_P(ov_infer_request_test, get_output_tensor) { OV_EXPECT_OK(ov_infer_request_get_output_tensor(infer_request, &output_tensor)); } -TEST_P(ov_infer_request, get_tensor_error_handling) { +TEST_P(ov_infer_request_test, get_tensor_error_handling) { OV_EXPECT_NOT_OK(ov_infer_request_get_tensor(nullptr, in_tensor_name, &input_tensor)); OV_EXPECT_NOT_OK(ov_infer_request_get_tensor(infer_request, nullptr, &input_tensor)); OV_EXPECT_NOT_OK(ov_infer_request_get_tensor(infer_request, in_tensor_name, nullptr)); } -TEST_P(ov_infer_request, infer) { +TEST_P(ov_infer_request_test, infer) { OV_EXPECT_OK(ov_infer_request_set_tensor(infer_request, in_tensor_name, input_tensor)); OV_ASSERT_OK(ov_infer_request_infer(infer_request)); @@ -291,7 +295,7 @@ TEST_P(ov_infer_request, infer) { ov_free(out_tensor_name); } -TEST_P(ov_infer_request, cancel) { +TEST_P(ov_infer_request_test, cancel) { OV_EXPECT_OK(ov_infer_request_set_tensor(infer_request, in_tensor_name, input_tensor)); OV_EXPECT_OK(ov_infer_request_cancel(infer_request)); @@ -306,11 +310,11 @@ TEST_P(ov_infer_request_ppp, infer_ppp) { EXPECT_NE(nullptr, output_tensor); } -TEST(ov_infer_request, infer_error_handling) { +TEST_P(ov_infer_request_test, infer_error_handling) { OV_EXPECT_NOT_OK(ov_infer_request_infer(nullptr)); } -TEST_P(ov_infer_request, infer_async) { +TEST_P(ov_infer_request_test, infer_async) { OV_EXPECT_OK(ov_infer_request_set_input_tensor_by_index(infer_request, 0, input_tensor)); OV_ASSERT_OK(ov_infer_request_start_async(infer_request)); @@ -323,7 +327,7 @@ TEST_P(ov_infer_request, infer_async) { } } -TEST_P(ov_infer_request, infer_async_wait_for) { +TEST_P(ov_infer_request_test, infer_async_wait_for) { OV_EXPECT_OK(ov_infer_request_set_input_tensor_by_index(infer_request, 0, input_tensor)); OV_ASSERT_OK(ov_infer_request_start_async(infer_request)); @@ -358,12 +362,12 @@ inline void infer_request_callback(void* args) { ov_tensor_free(out_tensor); - std::lock_guard lock(ov_infer_request::m); - ov_infer_request::ready = true; - ov_infer_request::condVar.notify_one(); + std::lock_guard lock(ov_infer_request_test::m); + ov_infer_request_test::ready = true; + ov_infer_request_test::condVar.notify_one(); } -TEST_P(ov_infer_request, infer_request_set_callback) { +TEST_P(ov_infer_request_test, infer_request_set_callback) { OV_EXPECT_OK(ov_infer_request_set_input_tensor_by_index(infer_request, 0, input_tensor)); ov_callback_t callback; @@ -375,14 +379,14 @@ TEST_P(ov_infer_request, infer_request_set_callback) { OV_ASSERT_OK(ov_infer_request_start_async(infer_request)); if (!HasFatalFailure()) { - std::unique_lock lock(ov_infer_request::m); - ov_infer_request::condVar.wait(lock, [] { - return ov_infer_request::ready; + std::unique_lock lock(ov_infer_request_test::m); + ov_infer_request_test::condVar.wait(lock, [] { + return ov_infer_request_test::ready; }); } } -TEST_P(ov_infer_request, get_profiling_info) { +TEST_P(ov_infer_request_test, get_profiling_info) { auto device_name = GetParam(); OV_EXPECT_OK(ov_infer_request_set_tensor(infer_request, in_tensor_name, input_tensor)); diff --git a/src/bindings/c/tests/ov_model_test.cpp b/src/bindings/c/tests/ov_model_test.cpp index 818a9f22082..c4f2e743d13 100644 --- a/src/bindings/c/tests/ov_model_test.cpp +++ b/src/bindings/c/tests/ov_model_test.cpp @@ -3,13 +3,25 @@ // #include "ov_test.hpp" -TEST(ov_model, ov_model_const_input) { +class ov_model_test : public ov_capi_test_base { + void SetUp() override { + ov_capi_test_base::SetUp(); + } + + void TearDown() override { + ov_capi_test_base::TearDown(); + } +}; + +INSTANTIATE_TEST_SUITE_P(device_name, ov_model_test, ::testing::Values("")); + +TEST_P(ov_model_test, ov_model_const_input) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* input_port = nullptr; @@ -21,13 +33,13 @@ TEST(ov_model, ov_model_const_input) { ov_core_free(core); } -TEST(ov_model, ov_model_const_input_by_name) { +TEST_P(ov_model_test, ov_model_const_input_by_name) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* input_port = nullptr; @@ -43,13 +55,13 @@ TEST(ov_model, ov_model_const_input_by_name) { ov_core_free(core); } -TEST(ov_model, ov_model_const_input_by_index) { +TEST_P(ov_model_test, ov_model_const_input_by_index) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* input_port = nullptr; @@ -65,13 +77,13 @@ TEST(ov_model, ov_model_const_input_by_index) { ov_core_free(core); } -TEST(ov_model, ov_model_input) { +TEST_P(ov_model_test, ov_model_input) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* input_port = nullptr; @@ -83,13 +95,13 @@ TEST(ov_model, ov_model_input) { ov_core_free(core); } -TEST(ov_model, ov_model_input_by_name) { +TEST_P(ov_model_test, ov_model_input_by_name) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* input_port = nullptr; @@ -105,13 +117,13 @@ TEST(ov_model, ov_model_input_by_name) { ov_core_free(core); } -TEST(ov_model, ov_model_input_by_index) { +TEST_P(ov_model_test, ov_model_input_by_index) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* input_port = nullptr; @@ -127,13 +139,13 @@ TEST(ov_model, ov_model_input_by_index) { ov_core_free(core); } -TEST(ov_model, ov_model_const_output) { +TEST_P(ov_model_test, ov_model_const_output) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* output_port = nullptr; @@ -145,13 +157,13 @@ TEST(ov_model, ov_model_const_output) { ov_core_free(core); } -TEST(ov_model, ov_model_const_output_by_index) { +TEST_P(ov_model_test, ov_model_const_output_by_index) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* output_port = nullptr; @@ -167,17 +179,17 @@ TEST(ov_model, ov_model_const_output_by_index) { ov_core_free(core); } -TEST(ov_model, ov_model_const_output_by_name) { +TEST_P(ov_model_test, ov_model_const_output_by_name) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* output_port = nullptr; - OV_EXPECT_OK(ov_model_const_output_by_name(model, "fc_out", &output_port)); + OV_EXPECT_OK(ov_model_const_output_by_name(model, "relu", &output_port)); EXPECT_NE(nullptr, output_port); ov_shape_t shape; @@ -189,13 +201,13 @@ TEST(ov_model, ov_model_const_output_by_name) { ov_core_free(core); } -TEST(ov_model, ov_model_output) { +TEST_P(ov_model_test, ov_model_output) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* output_port = nullptr; @@ -207,13 +219,13 @@ TEST(ov_model, ov_model_output) { ov_core_free(core); } -TEST(ov_model, ov_model_output_by_index) { +TEST_P(ov_model_test, ov_model_output_by_index) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* output_port = nullptr; @@ -229,17 +241,17 @@ TEST(ov_model, ov_model_output_by_index) { ov_core_free(core); } -TEST(ov_model, ov_model_output_by_name) { +TEST_P(ov_model_test, ov_model_output_by_name) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* output_port = nullptr; - OV_EXPECT_OK(ov_model_output_by_name(model, "fc_out", &output_port)); + OV_EXPECT_OK(ov_model_output_by_name(model, "relu", &output_port)); EXPECT_NE(nullptr, output_port); ov_shape_t shape; @@ -251,13 +263,13 @@ TEST(ov_model, ov_model_output_by_name) { ov_core_free(core); } -TEST(ov_model, ov_model_inputs_size) { +TEST_P(ov_model_test, ov_model_inputs_size) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); size_t input_size; @@ -268,13 +280,13 @@ TEST(ov_model, ov_model_inputs_size) { ov_core_free(core); } -TEST(ov_model, ov_model_outputs_size) { +TEST_P(ov_model_test, ov_model_outputs_size) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); size_t output_size; @@ -285,13 +297,13 @@ TEST(ov_model, ov_model_outputs_size) { ov_core_free(core); } -TEST(ov_model, ov_model_is_dynamic) { +TEST_P(ov_model_test, ov_model_is_dynamic) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); EXPECT_NO_THROW(ov_model_is_dynamic(model)); @@ -300,13 +312,13 @@ TEST(ov_model, ov_model_is_dynamic) { ov_core_free(core); } -TEST(ov_model, ov_model_reshape_input_by_name) { +TEST_P(ov_model_test, ov_model_reshape_input_by_name) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* input_port_1 = nullptr; @@ -339,13 +351,13 @@ TEST(ov_model, ov_model_reshape_input_by_name) { ov_core_free(core); } -TEST(ov_model, ov_model_reshape) { +TEST_P(ov_model_test, ov_model_reshape) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_const_port_t* input_port_1 = nullptr; @@ -379,13 +391,13 @@ TEST(ov_model, ov_model_reshape) { ov_core_free(core); } -TEST(ov_model, ov_model_reshape_by_port_indexes) { +TEST_P(ov_model_test, ov_model_reshape_by_port_indexes) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); size_t port_indexs[] = {0}; @@ -409,13 +421,13 @@ TEST(ov_model, ov_model_reshape_by_port_indexes) { ov_core_free(core); } -TEST(ov_model, ov_model_reshape_single_input) { +TEST_P(ov_model_test, ov_model_reshape_single_input) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_shape_t shape = {0, nullptr}; @@ -437,13 +449,13 @@ TEST(ov_model, ov_model_reshape_single_input) { ov_core_free(core); } -TEST(ov_model, ov_model_reshape_by_ports) { +TEST_P(ov_model_test, ov_model_reshape_by_ports) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); ov_output_port_t* input_port_1 = nullptr; @@ -471,13 +483,13 @@ TEST(ov_model, ov_model_reshape_by_ports) { ov_core_free(core); } -TEST(ov_model, ov_model_get_friendly_name) { +TEST_P(ov_model_test, ov_model_get_friendly_name) { ov_core_t* core = nullptr; OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); ov_model_t* model = nullptr; - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); char* friendly_name = nullptr; diff --git a/src/bindings/c/tests/ov_preprocess_test.cpp b/src/bindings/c/tests/ov_preprocess_test.cpp index b494ebbe5fd..2bf0d061d0c 100644 --- a/src/bindings/c/tests/ov_preprocess_test.cpp +++ b/src/bindings/c/tests/ov_preprocess_test.cpp @@ -3,7 +3,7 @@ // #include "ov_test.hpp" -class ov_preprocess : public ::testing::Test { +class ov_preprocess_test : public ::testing::Test { protected: void SetUp() override { core = nullptr; @@ -17,10 +17,14 @@ protected: output_tensor_info = nullptr; input_model = nullptr; + TestDataHelpers::generate_test_model(); + xml_file_name = TestDataHelpers::get_model_xml_file_name(); + bin_file_name = TestDataHelpers::get_model_bin_file_name(); + OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); } void TearDown() override { @@ -34,6 +38,7 @@ protected: ov_preprocess_prepostprocessor_free(preprocess); ov_model_free(model); ov_core_free(core); + TestDataHelpers::release_test_model(); } public: @@ -47,14 +52,15 @@ public: ov_preprocess_output_info_t* output_info; ov_preprocess_output_tensor_info_t* output_tensor_info; ov_preprocess_input_model_info_t* input_model; + std::string xml_file_name, bin_file_name; }; -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_create) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_create) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_input_info) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_get_input_info) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -62,7 +68,7 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_input_info) { EXPECT_NE(nullptr, input_info); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_input_info_by_name) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_get_input_info_by_name) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -70,7 +76,7 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_input_info_by_name) { EXPECT_NE(nullptr, input_info); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_input_info_by_index) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_get_input_info_by_index) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -78,7 +84,7 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_input_info_by_index) { EXPECT_NE(nullptr, input_info); } -TEST_F(ov_preprocess, ov_preprocess_input_info_get_tensor_info) { +TEST_F(ov_preprocess_test, ov_preprocess_input_info_get_tensor_info) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -89,7 +95,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_info_get_tensor_info) { EXPECT_NE(nullptr, input_tensor_info); } -TEST_F(ov_preprocess, ov_preprocess_input_info_get_preprocess_steps) { +TEST_F(ov_preprocess_test, ov_preprocess_input_info_get_preprocess_steps) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -100,7 +106,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_info_get_preprocess_steps) { EXPECT_NE(nullptr, input_process); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_resize) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_resize) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -113,7 +119,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_resize) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_resize(input_process, ov_preprocess_resize_algorithm_e::RESIZE_LINEAR)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_scale) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_scale) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -126,7 +132,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_scale) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_scale(input_process, 2.0f)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_mean) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_mean) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -139,7 +145,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_mean) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_mean(input_process, 2.0f)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_crop) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_crop) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -154,7 +160,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_crop) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_crop(input_process, begin, 4, end, 4)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_layout) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_convert_layout) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -172,7 +178,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_layout) { ov_layout_free(layout); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_reverse_channels) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_reverse_channels) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -185,7 +191,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_reverse_channels) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_reverse_channels(input_process)); } -TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_element_type) { +TEST_F(ov_preprocess_test, ov_preprocess_input_tensor_info_set_element_type) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -198,7 +204,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_element_type) { OV_EXPECT_OK(ov_preprocess_input_tensor_info_set_element_type(input_tensor_info, ov_element_type_e::F32)); } -TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_from) { +TEST_F(ov_preprocess_test, ov_preprocess_input_tensor_info_set_from) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -218,7 +224,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_from) { ov_shape_free(&shape); } -TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_layout) { +TEST_F(ov_preprocess_test, ov_preprocess_input_tensor_info_set_layout) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -236,7 +242,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_layout) { ov_layout_free(layout); } -TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_color_format) { +TEST_F(ov_preprocess_test, ov_preprocess_input_tensor_info_set_color_format) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -250,7 +256,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_color_format) { ov_preprocess_input_tensor_info_set_color_format(input_tensor_info, ov_color_format_e::NV12_SINGLE_PLANE)); } -TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_spatial_static_shape) { +TEST_F(ov_preprocess_test, ov_preprocess_input_tensor_info_set_spatial_static_shape) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -266,7 +272,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_tensor_info_set_spatial_static_shape) ov_preprocess_input_tensor_info_set_spatial_static_shape(input_tensor_info, input_height, input_width)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_element_type) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_convert_element_type) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -283,7 +289,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_element_type) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_convert_element_type(input_process, ov_element_type_e::F32)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_color) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_convert_color) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -304,7 +310,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_color) { OV_EXPECT_OK(ov_preprocess_preprocess_steps_convert_color(input_process, ov_color_format_e::BGR)); } -TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_color_rgb_to_gray) { +TEST_F(ov_preprocess_test, ov_preprocess_preprocess_steps_convert_color_rgb_to_gray) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -321,7 +327,7 @@ TEST_F(ov_preprocess, ov_preprocess_preprocess_steps_convert_color_rgb_to_gray) OV_EXPECT_OK(ov_preprocess_preprocess_steps_convert_color(input_process, ov_color_format_e::GRAY)); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_output_info) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_get_output_info) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -329,7 +335,7 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_output_info) { EXPECT_NE(nullptr, output_info); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_output_info_by_index) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_get_output_info_by_index) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -337,15 +343,15 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_output_info_by_index) { EXPECT_NE(nullptr, output_info); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_get_output_info_by_name) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_get_output_info_by_name) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); - OV_EXPECT_OK(ov_preprocess_prepostprocessor_get_output_info_by_name(preprocess, "fc_out", &output_info)); + OV_EXPECT_OK(ov_preprocess_prepostprocessor_get_output_info_by_name(preprocess, "relu", &output_info)); EXPECT_NE(nullptr, output_info); } -TEST_F(ov_preprocess, ov_preprocess_output_info_get_tensor_info) { +TEST_F(ov_preprocess_test, ov_preprocess_output_info_get_tensor_info) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -356,7 +362,7 @@ TEST_F(ov_preprocess, ov_preprocess_output_info_get_tensor_info) { EXPECT_NE(nullptr, output_tensor_info); } -TEST_F(ov_preprocess, ov_preprocess_output_set_element_type) { +TEST_F(ov_preprocess_test, ov_preprocess_output_set_element_type) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -369,7 +375,7 @@ TEST_F(ov_preprocess, ov_preprocess_output_set_element_type) { OV_EXPECT_OK(ov_preprocess_output_set_element_type(output_tensor_info, ov_element_type_e::F32)); } -TEST_F(ov_preprocess, ov_preprocess_input_info_get_model_info) { +TEST_F(ov_preprocess_test, ov_preprocess_input_info_get_model_info) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -380,7 +386,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_info_get_model_info) { EXPECT_NE(nullptr, input_model); } -TEST_F(ov_preprocess, ov_preprocess_input_model_info_set_layout) { +TEST_F(ov_preprocess_test, ov_preprocess_input_model_info_set_layout) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -398,7 +404,7 @@ TEST_F(ov_preprocess, ov_preprocess_input_model_info_set_layout) { ov_layout_free(layout); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_build) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_build) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -409,7 +415,7 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_build) { ov_model_free(new_model); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_build_apply) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_build_apply) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); @@ -459,7 +465,7 @@ TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_build_apply) { ov_model_free(new_model); } -TEST_F(ov_preprocess, ov_preprocess_prepostprocessor_for_nv12_input) { +TEST_F(ov_preprocess_test, ov_preprocess_prepostprocessor_for_nv12_input) { OV_EXPECT_OK(ov_preprocess_prepostprocessor_create(model, &preprocess)); EXPECT_NE(nullptr, preprocess); diff --git a/src/bindings/c/tests/ov_remote_context_test.cpp b/src/bindings/c/tests/ov_remote_context_test.cpp index 12e61ac0f1b..ace80ee8acf 100644 --- a/src/bindings/c/tests/ov_remote_context_test.cpp +++ b/src/bindings/c/tests/ov_remote_context_test.cpp @@ -5,7 +5,7 @@ #include "openvino/runtime/intel_gpu/ocl/ocl_wrapper.hpp" #include "ov_test.hpp" -class ov_remote_context_ocl : public ::testing::TestWithParam { +class ov_remote_context_ocl : public ov_capi_test_base { protected: void SetUp() override { core = nullptr; @@ -16,11 +16,12 @@ protected: remote_tensor = nullptr; out_tensor_name = nullptr; in_tensor_name = nullptr; + ov_capi_test_base::SetUp(); OV_EXPECT_OK(ov_core_create(&core)); EXPECT_NE(nullptr, core); - OV_EXPECT_OK(ov_core_read_model(core, xml, bin, &model)); + OV_EXPECT_OK(ov_core_read_model(core, xml_file_name.c_str(), bin_file_name.c_str(), &model)); EXPECT_NE(nullptr, model); char* info = nullptr; @@ -68,6 +69,7 @@ protected: ov_free(in_tensor_name); ov_remote_context_free(context); ov_core_free(core); + ov_capi_test_base::TearDown(); } public: diff --git a/src/bindings/c/tests/ov_test.cpp b/src/bindings/c/tests/ov_test.cpp index 2f3976a76e3..abafe06838d 100644 --- a/src/bindings/c/tests/ov_test.cpp +++ b/src/bindings/c/tests/ov_test.cpp @@ -3,14 +3,6 @@ // #include "ov_test.hpp" -#include "test_model_repo.hpp" - -std::string xml_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.xml"); -std::string bin_std = TestDataHelpers::generate_model_path("test_model", "test_model_fp32.bin"); - -const char* xml = xml_std.c_str(); -const char* bin = bin_std.c_str(); - std::map element_type_size_map = {{ov_element_type_e::BOOLEAN, 8}, {ov_element_type_e::BF16, 16}, {ov_element_type_e::F16, 16}, diff --git a/src/bindings/c/tests/ov_test.hpp b/src/bindings/c/tests/ov_test.hpp index e96649f5f82..db2f95563f5 100644 --- a/src/bindings/c/tests/ov_test.hpp +++ b/src/bindings/c/tests/ov_test.hpp @@ -11,11 +11,7 @@ #include "openvino/c/openvino.h" #include "openvino/openvino.hpp" - -extern const char* xml; -extern const char* bin; -extern const char* input_image; -extern const char* input_image_nv12; +#include "test_model_repo.hpp" #define OV_EXPECT_OK(...) EXPECT_EQ(ov_status_e::OK, __VA_ARGS__) #define OV_ASSERT_OK(...) ASSERT_EQ(ov_status_e::OK, __VA_ARGS__) @@ -40,6 +36,22 @@ extern const char* input_image_nv12; extern std::map element_type_size_map; #define GET_ELEMENT_TYPE_SIZE(a) element_type_size_map[a] +class ov_capi_test_base : public ::testing::TestWithParam { +public: + void SetUp() override { + TestDataHelpers::generate_test_model(); + xml_file_name = TestDataHelpers::get_model_xml_file_name(); + bin_file_name = TestDataHelpers::get_model_bin_file_name(); + } + + void TearDown() override { + TestDataHelpers::release_test_model(); + } + +public: + std::string xml_file_name, bin_file_name; +}; + inline size_t find_device(ov_available_devices_t avai_devices, const char* device_name) { for (size_t i = 0; i < avai_devices.size; ++i) { if (strstr(avai_devices.devices[i], device_name)) diff --git a/src/bindings/c/tests/test_model_repo.hpp b/src/bindings/c/tests/test_model_repo.hpp index e7f0ed6965f..674f3f44cb2 100644 --- a/src/bindings/c/tests/test_model_repo.hpp +++ b/src/bindings/c/tests/test_model_repo.hpp @@ -1,51 +1,54 @@ // Copyright (C) 2018-2023 Intel Corporation // SPDX-License-Identifier: Apache-2.0 // + +#pragma once + #include +#include + +#include "ngraph_functions/builders.hpp" +#include "ngraph_functions/subgraph_builders.hpp" +#include "openvino/pass/manager.hpp" namespace TestDataHelpers { -static const char kPathSeparator = -#if defined _WIN32 || defined __CYGWIN__ - '\\'; -#else - '/'; -#endif +static const std::string model_bin_name = "test_model.bin"; +static const std::string model_xml_name = "test_model.xml"; +static const std::string model_exported_name = "test_exported_model.blob"; -inline std::string getModelPathNonFatal() noexcept { - if (const auto envVar = std::getenv("MODELS_PATH")) { - return envVar; +inline void generate_test_model() { + ov::pass::Manager manager; + manager.register_pass(model_xml_name, model_bin_name); + auto function = ngraph::builder::subgraph::makeConvPoolReluNoReshapes({1, 3, 227, 227}); + manager.run_passes(function); +} + +inline std::string get_model_xml_file_name() { + return model_xml_name; +} + +inline std::string get_model_bin_file_name() { + return model_bin_name; +} + +inline std::string get_exported_blob_file_name() { + return model_exported_name; +} + +inline void release_test_model() { + std::remove(model_xml_name.c_str()); + std::remove(model_bin_name.c_str()); +} + +inline void fill_random_input_nv12_data(uint8_t* data, const size_t w, const size_t h) { + size_t size = w * h * 3 / 2; + std::mt19937 gen(0); + std::uniform_int_distribution<> distribution(0, 255); + for (size_t i = 0; i < size; i++) { + data[i] = static_cast(distribution(gen)); } - -#ifdef MODELS_PATH - return MODELS_PATH; -#else - return ""; -#endif -} - -inline std::string get_models_path() { - return getModelPathNonFatal() + kPathSeparator + std::string("models"); -}; - -inline std::string get_data_path() { - if (const auto envVar = std::getenv("DATA_PATH")) { - return envVar; - } - -#ifdef DATA_PATH - return DATA_PATH; -#else - return ""; -#endif -} - -inline std::string generate_model_path(std::string dir, std::string filename) { - return get_models_path() + kPathSeparator + dir + kPathSeparator + filename; -} - -inline std::string generate_image_path(std::string dir, std::string filename) { - return get_data_path() + kPathSeparator + "validation_set" + kPathSeparator + dir + kPathSeparator + filename; + return; } inline std::string generate_test_xml_file() {