Add gtest_main_manifest target to avoid duplicates (#12438)

- Add gtest_main_manifest target as main application for google test using manifest file to ignore tests
- Use new target in frontends tests
This commit is contained in:
Pawel Raasz 2022-08-08 19:31:29 +02:00 committed by GitHub
parent b03e903621
commit 93dbffafd4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 57 additions and 56 deletions

View File

@ -8,7 +8,8 @@ file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_executable(${TARGET_NAME} ${SRC})
target_link_libraries(${TARGET_NAME} PRIVATE frontend_shared_test_classes openvino_onnx_frontend frontend_common)
target_link_libraries(${TARGET_NAME}
PRIVATE frontend_shared_test_classes openvino_onnx_frontend frontend_common gtest_main_manifest)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})

View File

@ -1,32 +0,0 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <fstream>
#include <string>
#include "gtest/gtest.h"
#include "utils.hpp"
std::string get_disabled_tests() {
std::string result = "-";
const std::string manifest_path = MANIFEST;
std::ifstream manifest_stream(manifest_path);
std::string line;
while (std::getline(manifest_stream, line)) {
if (line.empty()) {
continue;
}
if (line.size() > 0 && line[0] == '#') {
continue;
}
result += ":" + line;
}
manifest_stream.close();
return result;
}
int main(int argc, char** argv) {
::testing::GTEST_FLAG(filter) += get_disabled_tests();
return FrontEndTestUtils::run_tests(argc, argv);
}

View File

@ -9,7 +9,7 @@ file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_executable(${TARGET_NAME} ${SRC})
target_link_libraries(${TARGET_NAME} PRIVATE cnpy frontend_shared_test_classes
openvino_paddle_frontend openvino::runtime)
openvino_paddle_frontend openvino::runtime gtest_main_manifest)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})
@ -34,10 +34,10 @@ DownloadAndCheck(${PADDLEDET_OPS_URL} ${PADDLEDET_DIRNAME}/ops.py PADDLEDET_FATA
# but models will not be generated and tests will fail
# This is done this way for 'code style' and check cases - cmake shall pass, but CI machine doesn't need to have
# 'paddlepaddle' installed to check code style
if (paddlepaddle_FOUND AND ${PADDLEDET_RESULT} STREQUAL "ON")
if(paddlepaddle_FOUND AND ${PADDLEDET_RESULT} STREQUAL "ON")
set(TEST_PADDLE_MODELS ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/${TEST_PADDLE_MODELS_DIRNAME}/)
if (WIN32)
if(WIN32)
set(SETENV "set")
set(PATHSEP ";")
else()
@ -73,7 +73,7 @@ add_dependencies(${TARGET_NAME} paddle_test_models)
add_dependencies(${TARGET_NAME} openvino_paddle_frontend)
# Fuzzy tests for PaddlePaddle use IE_CPU engine
if (ENABLE_INTEL_CPU)
if(ENABLE_INTEL_CPU)
add_dependencies(${TARGET_NAME} openvino_intel_cpu_plugin)
endif()

View File

@ -1,9 +0,0 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "utils.hpp"
int main(int argc, char** argv) {
return FrontEndTestUtils::run_tests(argc, argv);
}

View File

@ -8,7 +8,8 @@ file(GLOB SRC ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
add_executable(${TARGET_NAME} ${SRC})
target_link_libraries(${TARGET_NAME} PRIVATE frontend_shared_test_classes openvino_tensorflow_frontend openvino::runtime)
target_link_libraries(${TARGET_NAME} PRIVATE
gtest_main_manifest frontend_shared_test_classes openvino_tensorflow_frontend openvino::runtime)
add_clang_format_target(${TARGET_NAME}_clang FOR_TARGETS ${TARGET_NAME})

View File

@ -1,9 +0,0 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include "utils.hpp"
int main(int argc, char** argv) {
return FrontEndTestUtils::run_tests(argc, argv);
}

View File

@ -9,6 +9,7 @@ file(GLOB_RECURSE LIBRARY_HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/include/*.hpp)
add_library(${TARGET_NAME} STATIC EXCLUDE_FROM_ALL ${LIBRARY_SRC} ${LIBRARY_HEADERS})
add_subdirectory(gtest_main_manifest)
add_subdirectory(test_builtin_extensions_1)
add_subdirectory(test_builtin_extensions_2)

View File

@ -0,0 +1,13 @@
# Copyright (C) 2018-2022 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#
set(TARGET_NAME "gtest_main_manifest")
# Make this library as interface (source) to build it for each test targets which can define
# ${MANIFEST} file path define.
add_library(${TARGET_NAME} INTERFACE)
target_sources(${TARGET_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/main.cpp)
target_include_directories(${TARGET_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
target_link_libraries(${TARGET_NAME} INTERFACE frontend_shared_test_classes)

View File

@ -0,0 +1,21 @@
// Copyright (C) 2018-2022 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <string>
#include "gtest/gtest.h"
#include "utils.hpp"
static const std::string manifest{
#ifdef MANIFEST
MANIFEST
#endif
};
int main(int argc, char** argv) {
if (!manifest.empty()) {
testing::GTEST_FLAG(filter) += FrontEndTestUtils::get_disabled_tests(manifest);
}
return FrontEndTestUtils::run_tests(argc, argv);
}

View File

@ -65,4 +65,6 @@ inline bool exists(const std::string& file) {
inline std::string make_model_path(const std::string& modelsRelativePath) {
return CommonTestUtils::getModelFromTestModelZoo(modelsRelativePath);
}
std::string get_disabled_tests(const std::string& manifest_path);
} // namespace FrontEndTestUtils

View File

@ -35,3 +35,15 @@ std::string FrontEndTestUtils::find_ov_path() {
# error "Unsupported OS"
#endif
}
std::string FrontEndTestUtils::get_disabled_tests(const std::string& manifest_path) {
std::string result = "-";
std::ifstream manifest_stream(manifest_path);
for (std::string line; std::getline(manifest_stream, line);) {
if (line.size() && (line[0] != '#')) {
result += ":" + line;
}
}
return result;
}