Skip to content

Commit

Permalink
Common tests library for shared functionality (openvinotoolkit#6578)
Browse files Browse the repository at this point in the history
  • Loading branch information
ishariko authored and rnugmanx committed Aug 26, 2021
1 parent c64a67e commit b0300c9
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 167 deletions.
5 changes: 5 additions & 0 deletions tests/lib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

add_subdirectory(src)
15 changes: 15 additions & 0 deletions tests/lib/src/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
#

set (TARGET_NAME "tests_shared_lib")

file (GLOB SRC *.cpp)
add_library(${TARGET_NAME} STATIC ${SRC})

target_include_directories(${TARGET_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})

# Search OpenVINO Inference Engine installed
find_package(InferenceEngine REQUIRED)

target_link_libraries(${TARGET_NAME} PUBLIC ${InferenceEngine_LIBRARIES})
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
//

#include "ie_utils.h"
#include "common_utils.h"

#include <inference_engine.hpp>

Expand Down Expand Up @@ -32,7 +32,7 @@ void fillBlobs(InferenceEngine::InferRequest inferRequest,
} else if (item.second->getPrecision() == InferenceEngine::Precision::I32) {
fillBlobImInfo<int32_t>(inputBlob, batchSize, image_size);
} else {
IE_THROW() << "Input precision is not supported for image info!";
throw std::logic_error("Input precision is not supported for image info!");
}
continue;
}
Expand All @@ -52,7 +52,7 @@ void fillBlobs(InferenceEngine::InferRequest inferRequest,
} else if (item.second->getPrecision() == InferenceEngine::Precision::I16) {
fillBlobRandom<int16_t>(inputBlob);
} else {
IE_THROW() << "Input precision is not supported for " << item.first;
throw std::logic_error("Input precision is not supported for " + item.first);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ inline std::pair<size_t, size_t> getTensorHeightWidth(const InferenceEngine::Ten
// Regardless of layout, dimensions are stored in fixed order
return std::make_pair(dims.back(), dims.at(size - 2));
} else {
IE_THROW() << "Tensor does not have height and width dimensions";
throw std::logic_error("Tensor does not have height and width dimensions");
}
}

Expand Down Expand Up @@ -111,4 +111,4 @@ void fillBlobImInfo(Blob::Ptr& inputBlob,
*/
void fillBlobs(InferenceEngine::InferRequest inferRequest,
const InferenceEngine::ConstInputsDataMap& inputsInfo,
const size_t& batchSize);
const size_t& batchSize);
3 changes: 2 additions & 1 deletion tests/stress_tests/common/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,12 @@ if(EXISTS "${OpenVINO_SOURCE_DIR}/thirdparty/gflags")
add_gflags()
endif()

add_subdirectory("${OpenVINO_SOURCE_DIR}/tests/lib" tests_shared_lib)
target_link_libraries(${TARGET_NAME}
PUBLIC
IE::gtest
IE::pugixml
${InferenceEngine_LIBRARIES}
gflags
tests_shared_lib
PRIVATE
IE::gtest_main)
2 changes: 1 addition & 1 deletion tests/stress_tests/common/ie_pipelines/pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "pipelines.h"
#include "../utils.h"
#include "../ie_utils.h"
#include "common_utils.h"

#include <iostream>
#include <string>
Expand Down
2 changes: 1 addition & 1 deletion tests/stress_tests/memcheck_tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "tests_utils.h"
#include "../common/tests_utils.h"
#include "../common/ie_utils.h"
#include "common_utils.h"
#include "../common/managers/thread_manager.h"
#include "tests_pipelines/tests_pipelines.h"

Expand Down
2 changes: 1 addition & 1 deletion tests/stress_tests/memleaks_tests/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

#include "../common/tests_utils.h"
#include "../common/ie_utils.h"
#include "common_utils.h"
#include "../common/managers/thread_manager.h"
#include "tests_pipelines/tests_pipelines.h"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
//

#include "tests_pipelines.h"
#include "../common/ie_utils.h"
#include "common_utils.h"

#include <string>

Expand Down
4 changes: 3 additions & 1 deletion tests/time_tests/src/timetests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,13 @@ add_custom_target(time_tests)
# Test target name is source file name without extension.
FILE(GLOB tests "*.cpp")

add_subdirectory("${OpenVINO_SOURCE_DIR}/tests/lib" tests_shared_lib)

foreach(test_source ${tests})
get_filename_component(test_name ${test_source} NAME_WE)
add_executable(${test_name} ${test_source})

target_link_libraries(${test_name} PRIVATE IE::inference_engine timetests_helper)
target_link_libraries(${test_name} PRIVATE tests_shared_lib timetests_helper)

add_dependencies(time_tests ${test_name})

Expand Down
154 changes: 0 additions & 154 deletions tests/time_tests/src/timetests/common.h

This file was deleted.

2 changes: 1 addition & 1 deletion tests/time_tests/src/timetests/timetest_infer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <inference_engine.hpp>
#include <iostream>

#include "common.h"
#include "common_utils.h"
#include "timetests_helper/timer.h"
#include "timetests_helper/utils.h"
using namespace InferenceEngine;
Expand Down
2 changes: 1 addition & 1 deletion tests/time_tests/src/timetests/timetest_infer_cache.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <inference_engine.hpp>
#include <iostream>

#include "common.h"
#include "common_utils.h"
#include "timetests_helper/timer.h"
#include "timetests_helper/utils.h"
using namespace InferenceEngine;
Expand Down

0 comments on commit b0300c9

Please sign in to comment.