mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 10:59:32 +08:00
Fix compatibility of Gtest
Signed-off-by: FluorineDog <guilin.gou@zilliz.com>
This commit is contained in:
parent
996c591088
commit
3c4a9f38b0
@ -2,8 +2,7 @@ project(sulvim_core)
|
||||
cmake_minimum_required(VERSION 3.16)
|
||||
set( CMAKE_CXX_STANDARD 17 )
|
||||
set( CMAKE_CXX_STANDARD_REQUIRED on )
|
||||
|
||||
|
||||
set (CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
|
||||
include_directories(src)
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(unittest)
|
||||
|
43
core/cmake/FindGTest.cmake
Normal file
43
core/cmake/FindGTest.cmake
Normal file
@ -0,0 +1,43 @@
|
||||
########################### GTEST
|
||||
# Enable ExternalProject CMake module
|
||||
INCLUDE(ExternalProject)
|
||||
|
||||
# Set default ExternalProject root directory
|
||||
SET_DIRECTORY_PROPERTIES(PROPERTIES EP_PREFIX ${CMAKE_BINARY_DIR}/third_party)
|
||||
|
||||
# Add gtest
|
||||
# http://stackoverflow.com/questions/9689183/cmake-googletest
|
||||
ExternalProject_Add(
|
||||
googletest
|
||||
URL http://ss2.fluorinedog.com/data/gtest_v1.10.x.zip
|
||||
# TIMEOUT 10
|
||||
# # Force separate output paths for debug and release builds to allow easy
|
||||
# # identification of correct lib in subsequent TARGET_LINK_LIBRARIES commands
|
||||
# CMAKE_ARGS -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_DEBUG:PATH=DebugLibs
|
||||
# -DCMAKE_ARCHIVE_OUTPUT_DIRECTORY_RELEASE:PATH=ReleaseLibs
|
||||
# -Dgtest_force_shared_crt=ON
|
||||
# Disable install step
|
||||
INSTALL_COMMAND ""
|
||||
# Wrap download, configure and build steps in a script to log output
|
||||
LOG_DOWNLOAD ON
|
||||
LOG_CONFIGURE ON
|
||||
LOG_BUILD ON)
|
||||
|
||||
# Specify include dir
|
||||
ExternalProject_Get_Property(googletest source_dir)
|
||||
set(GTEST_INCLUDE_DIR ${source_dir}/include)
|
||||
|
||||
# Library
|
||||
ExternalProject_Get_Property(googletest binary_dir)
|
||||
|
||||
# set(GTEST_LIBRARY_PATH ${binary_dir}/lib/${CMAKE_FIND_LIBRARY_PREFIXES}gtest.a)
|
||||
# set(GTEST_LIBRARY gtest)
|
||||
# add_library(${GTEST_LIBRARY} UNKNOWN IMPORTED)
|
||||
# set_property(TARGET ${GTEST_LIBRARY} PROPERTY IMPORTED_LOCATION
|
||||
# ${GTEST_LIBRARY_PATH} )
|
||||
# add_dependencies(${GTEST_LIBRARY} googletest)
|
||||
set(GTEST_LIBRARY_PATH ${binary_dir}/lib)
|
||||
add_library(gtest UNKNOWN IMPORTED)
|
||||
add_library(gtest_main UNKNOWN IMPORTED)
|
||||
set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARY_PATH}/libgtest.a)
|
||||
set_property(TARGET gtest_main PROPERTY IMPORTED_LOCATION ${GTEST_LIBRARY_PATH}/libgtest_main.a)
|
@ -7,4 +7,4 @@ add_library(milvus_dog_segment
|
||||
${DOG_SEGMENT_FILES}
|
||||
)
|
||||
#add_dependencies( segment sqlite mysqlpp )
|
||||
target_link_libraries(milvus_dog_segment tbb milvus_utils)
|
||||
target_link_libraries(milvus_dog_segment tbb milvus_utils pthread)
|
@ -0,0 +1,15 @@
|
||||
enable_testing()
|
||||
find_package(GTest REQUIRED)
|
||||
set(MILVUS_TEST_FILES
|
||||
test_dog_segment.cpp
|
||||
)
|
||||
add_executable(all_tests
|
||||
${MILVUS_TEST_FILES}
|
||||
)
|
||||
|
||||
target_link_libraries(all_tests
|
||||
gtest
|
||||
gtest_main
|
||||
milvus_dog_segment
|
||||
pthread
|
||||
)
|
@ -26,14 +26,16 @@
|
||||
// #include "segment/SegmentWriter.h"
|
||||
// #include "src/dog_segment/SegmentBase.h"
|
||||
// #include "utils/Json.h"
|
||||
#include <random>
|
||||
#include <gtest/gtest.h>
|
||||
#include "dog_segment/SegmentBase.h"
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
|
||||
using SegmentVisitor = milvus::engine::SegmentVisitor;
|
||||
// using SegmentVisitor = milvus::engine::SegmentVisitor;
|
||||
|
||||
namespace {
|
||||
// namespace {
|
||||
// milvus::Status
|
||||
// CreateCollection(std::shared_ptr<DB> db, const std::string& collection_name, const LSN_TYPE& lsn) {
|
||||
// CreateCollectionContext context;
|
||||
@ -73,7 +75,7 @@ namespace {
|
||||
// }
|
||||
// } // namespace
|
||||
|
||||
TEST_F(DogSegmentTest, TestABI) {
|
||||
TEST(DogSegmentTest, TestABI) {
|
||||
using namespace milvus::engine;
|
||||
using namespace milvus::dog_segment;
|
||||
ASSERT_EQ(TestABI(), 42);
|
||||
@ -135,7 +137,7 @@ TEST_F(DogSegmentTest, TestABI) {
|
||||
|
||||
|
||||
|
||||
TEST_F(DogSegmentTest, MockTest) {
|
||||
TEST(DogSegmentTest, MockTest) {
|
||||
using namespace milvus::dog_segment;
|
||||
using namespace milvus::engine;
|
||||
auto schema = std::make_shared<Schema>();
|
||||
|
Loading…
Reference in New Issue
Block a user