diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3661c375..7d39c50f 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,8 +7,20 @@ variables: TESTING_VERSION_BUILD: 0 stages: +- analysis +- test - build +run_cppcheck: + stage: analysis + script: + - mkdir build || true + - cd build + - cmake3 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON .. + - cppcheck --project=compile_commands.json --enable=all --error-exitcode=1 --suppress=unusedFunction --suppress=missingInclude --suppress=uselessAssignmentPtrArg --suppress=unmatchedSuppression + tags: + - share + .build_by_travis: before_script: - mkdir -p $BUILD_PADDING_PREFIX/$CI_PROJECT_NAMESPACE/ @@ -22,6 +34,18 @@ stages: tags: - share +# run_test: +# stage: test +# extends: .build_by_travis +# variables: +# HOS_MOCK: "ON" +# HOS_MESA_LOG: "OFF" +# script: +# - yum makecache +# - ./ci/travis.sh +# - cd build +# - ctest --verbose + branch_build_debug: stage: build extends: .build_by_travis diff --git a/CMakeLists.txt b/CMakeLists.txt index 78d82f3e..91b38eef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,9 +15,28 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g -Wall ") set(CMAKE_INSTALL_PREFIX /opt/MESA) set(SUPPORT_INSTALL_PREFIX /usr/local/lib64) +find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck) +if (CMAKE_CXX_CPPCHECK) + list( + APPEND CMAKE_CXX_CPPCHECK + "--enable=all" + "--error-exitcode=0" + "--suppress=unusedFunction" + "--suppress=missingInclude" + "--suppress=uselessAssignmentPtrArg" + "--suppress=unmatchedSuppression" + ) + set(CMAKE_C_CPPCHECK ${CMAKE_CXX_CPPCHECK}) +else() + message(FATAL_ERROR "Could not find the program cppcheck.") +endif() + add_subdirectory(support) add_subdirectory(src) +enable_testing() +add_subdirectory(gtest) + install(FILES ${CMAKE_CURRENT_BINARY_DIR}/src/libhos-client-cpp.so DESTINATION ${CMAKE_INSTALL_PREFIX}/lib COMPONENT LIBRARIES) install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/hos_client.h DESTINATION ${CMAKE_INSTALL_PREFIX}/include COMPONENT HEADER) #install(FILES ${CMAKE_CURRENT_SOURCE_DIR}/conf/hos.conf DESTINATION /etc/ld.so.conf.d COMPONENT PROFILE) diff --git a/ci/travis.sh b/ci/travis.sh index 40a2780c..faadc35c 100644 --- a/ci/travis.sh +++ b/ci/travis.sh @@ -44,6 +44,7 @@ cmake3 -DCMAKE_CXX_FLAGS=$CXX_FLAGS \ -DCMAKE_BUILD_TYPE=$BUILD_TYPE \ -DCMAKE_INSTALL_PREFIX=$INSTALL_PREFIX \ -DENABLE_DEVEL=$ENABLE_DEVEL_SWITCH \ + -DHOS_MOCK=$HOS_MOCK \ .. make @@ -57,8 +58,9 @@ if [ -n "${UPLOAD}" ]; then python3 rpm_upload_tools.py ${PULP3_REPO_NAME} ${PULP3_DIST_NAME} *.rpm fi -#if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then -# rpm -i tfe*debuginfo*.rpm -# cp /usr/lib/debug/opt/tsg/tfe/bin/tfe.debug /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA} -# sentry-cli upload-dif -t elf /tmp/tfe.debuginfo.${CI_COMMIT_SHORT_SHA} -#fi +if [ -n "${UPLOAD_SYMBOL_FILES}" ]; then + rpm -i $SYMBOL_TARGE*debuginfo*.rpm + _symbol_file=`find /usr/lib/debug/ -name "$SYMBOL_TARGET*.so*.debug"` + cp $_symbol_file ${_symbol_file}info.${CI_COMMIT_SHORT_SHA} + sentry-cli upload-dif -t elf ${_symbol_file}info.${CI_COMMIT_SHORT_SHA} +fi \ No newline at end of file diff --git a/gtest/CMakeLists.txt b/gtest/CMakeLists.txt index aaa322a7..23e6865c 100644 --- a/gtest/CMakeLists.txt +++ b/gtest/CMakeLists.txt @@ -5,6 +5,9 @@ aux_source_directory(${CMAKE_CURRENT_SOURCE_DIR} SRCS) include_directories("/opt/MESA/include") include_directories("/opt/MESA/include/MESA") link_directories("/opt/MESA/lib") +link_directories("${CMAKE_BINARY_DIR}/support/GoogleTest/include/") +link_directories("${CMAKE_BINARY_DIR}/src/") +link_directories("${CMAKE_BINARY_DIR}/support/GoogleTest/lib/") #link_libraries(hos-client-cpp gtest gtest_main pthread) # coverage @@ -14,7 +17,12 @@ SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-cove add_definitions(-g -W -Wall -std=c++11) #add_executable(gtest_hos_client gtest_hos_init_instance.cpp gtest_hos_get_instance.cpp gtest_hos_close_fd.cpp gtest_hos_open_fd.cpp) -#add_executable(gtest_hos_client CheckHosClient.cpp gtest_hos_close_fd.cpp) +#add_executable(gtest_hos_client CheckHosClient.cpp gtest_hos_init_instance.cpp) add_executable(gtest_hos_client ${SRCS}) +add_dependencies(gtest_hos_client ${lib_name}_shared gtest) target_link_libraries(gtest_hos_client hos-client-cpp gtest gtest_main pthread) +add_test(NAME SOFT_LINK COMMAND sh -c "ln -sf ${CMAKE_CURRENT_SOURCE_DIR}/conf ${CMAKE_BINARY_DIR}/conf") +add_test(NAME MKDIR COMMAND sh -c "cd ${CMAKE_CURRENT_BINARY_DIR} && mkdir log") +add_test(NAME HOS_TEST COMMAND gtest_hos_client) + diff --git a/gtest/CheckHosClient.cpp b/gtest/CheckHosClient.cpp index 644c4ab0..296f16a7 100644 --- a/gtest/CheckHosClient.cpp +++ b/gtest/CheckHosClient.cpp @@ -2,22 +2,22 @@ void CheckStructHosConfigT(hos_config_t *actual, hos_config_t *expect) { - EXPECT_STREQ(actual->accesskeyid, expect->accesskeyid); - EXPECT_STREQ(actual->secretkey, expect->secretkey); - EXPECT_STREQ(actual->log_path, expect->log_path); - EXPECT_EQ(actual->log_level, expect->log_level); - EXPECT_EQ(actual->pool_thread_size, expect->pool_thread_size); - EXPECT_EQ(actual->cache_count, expect->cache_count); - EXPECT_EQ(actual->cache_size, expect->cache_size); - EXPECT_EQ(actual->fs2_fmt, expect->fs2_fmt); - EXPECT_STREQ(actual->fs2_ip, expect->fs2_ip); - EXPECT_STREQ(actual->fs2_path, expect->fs2_path); - EXPECT_EQ(actual->fs2_port, expect->fs2_port); - EXPECT_STREQ(actual->ip, expect->ip); - EXPECT_EQ(actual->port, expect->port); - EXPECT_EQ(actual->thread_num, expect->thread_num); - EXPECT_EQ(actual->max_request_context, expect->max_request_context); - EXPECT_EQ(actual->max_request_num, expect->max_request_num); + ASSERT_STREQ(actual->accesskeyid, expect->accesskeyid); + ASSERT_STREQ(actual->secretkey, expect->secretkey); + ASSERT_STREQ(actual->log_path, expect->log_path); + ASSERT_EQ(actual->log_level, expect->log_level); + ASSERT_EQ(actual->pool_thread_size, expect->pool_thread_size); + ASSERT_EQ(actual->cache_count, expect->cache_count); + ASSERT_EQ(actual->cache_size, expect->cache_size); + ASSERT_EQ(actual->fs2_fmt, expect->fs2_fmt); + ASSERT_STREQ(actual->fs2_ip, expect->fs2_ip); + ASSERT_STREQ(actual->fs2_path, expect->fs2_path); + ASSERT_EQ(actual->fs2_port, expect->fs2_port); + ASSERT_STREQ(actual->ip, expect->ip); + ASSERT_EQ(actual->port, expect->port); + ASSERT_EQ(actual->thread_num, expect->thread_num); + ASSERT_EQ(actual->max_request_context, expect->max_request_context); + ASSERT_EQ(actual->max_request_num, expect->max_request_num); } void CheckStructFs2DataInfo(data_info_t *actual, data_info_t *expect, int thread_num) @@ -28,59 +28,59 @@ void CheckStructFs2DataInfo(data_info_t *actual, data_info_t *expect, int thread { if (actual->cache) { - EXPECT_EQ(actual->cache[i], expect->cache[i]); + ASSERT_EQ(actual->cache[i], expect->cache[i]); } if (actual->rx_bytes) { - EXPECT_EQ(actual->rx_bytes[i], expect->rx_bytes[i]); + ASSERT_EQ(actual->rx_bytes[i], expect->rx_bytes[i]); } if (actual->rx_pkts) { - EXPECT_EQ(actual->rx_pkts[i], expect->rx_pkts[i]); + ASSERT_EQ(actual->rx_pkts[i], expect->rx_pkts[i]); } if (actual->tx_bytes) { - EXPECT_EQ(actual->tx_bytes[i], expect->tx_bytes[i]); + ASSERT_EQ(actual->tx_bytes[i], expect->tx_bytes[i]); } if (actual->tx_pkts) { - EXPECT_EQ(actual->tx_pkts[i], expect->tx_pkts[i]); + ASSERT_EQ(actual->tx_pkts[i], expect->tx_pkts[i]); } if (actual->tx_failed_bytes) { - EXPECT_EQ(actual->tx_failed_bytes[i], expect->tx_failed_bytes[i]); + ASSERT_EQ(actual->tx_failed_bytes[i], expect->tx_failed_bytes[i]); } if (actual->tx_failed_pkts) { - EXPECT_EQ(actual->tx_failed_pkts[i], expect->tx_failed_pkts[i]); + ASSERT_EQ(actual->tx_failed_pkts[i], expect->tx_failed_pkts[i]); } } } void CheckStructHosFunc(hos_func_thread_t *actual, hos_func_thread_t *expect, int thread_num) { - //EXPECT_EQ(actual->fd_thread, expect->fd_thread); - EXPECT_EQ(actual->fd_thread_status, expect->fd_thread_status); + //ASSERT_EQ(actual->fd_thread, expect->fd_thread); + ASSERT_EQ(actual->fd_thread_status, expect->fd_thread_status); if (actual->fs2_info.reserved != NULL) { CheckStructFs2DataInfo((data_info_t *)actual->fs2_info.reserved, (data_info_t *)expect->fs2_info.reserved, thread_num); } - EXPECT_EQ(actual->fs2_status, expect->fs2_status); - //EXPECT_EQ(actual->fs2_thread, expect->fs2_thread); + ASSERT_EQ(actual->fs2_status, expect->fs2_status); + //ASSERT_EQ(actual->fs2_thread, expect->fs2_thread); } void CheckStructGHosHandle(hos_client_handle_t *actual, hos_client_handle_t *expect) { - //EXPECT_STREQ(actual->buckets.c_str(), expect->buckets.c_str()); + //ASSERT_STREQ(actual->buckets.c_str(), expect->buckets.c_str()); int bucketNum = actual->buckets.size() > expect->buckets.size() ? expect->buckets.size() : actual->buckets.size(); for (int i = 0; i < bucketNum; i++) { - EXPECT_STREQ(actual->buckets.at(i).GetName().c_str(), expect->buckets.at(i).GetName().c_str()); + ASSERT_STREQ(actual->buckets.at(i).GetName().c_str(), expect->buckets.at(i).GetName().c_str()); } - EXPECT_EQ(actual->count, expect->count); - //EXPECT_TRUE(actual->log != NULL); - //EXPECT_TRUE(actual->S3Client != NULL); + ASSERT_EQ(actual->count, expect->count); + //ASSERT_TRUE(actual->log != NULL); + //ASSERT_TRUE(actual->S3Client != NULL); CheckStructHosConfigT(&actual->hos_config, &expect->hos_config); CheckStructHosFunc(&actual->hos_func, &expect->hos_func, actual->hos_config.thread_num); } @@ -89,28 +89,28 @@ void CheckStructGHosFdContext(hos_fd_context_t *actual, hos_fd_context_t *expect { if (actual == NULL || expect == NULL) { - EXPECT_TRUE(actual == expect); + ASSERT_TRUE(actual == expect); } else { - EXPECT_STREQ(actual->bucket, expect->bucket); - //EXPECT_TRUE(actual->cache == NULL); - EXPECT_EQ(actual->cache_count, expect->cache_count); - EXPECT_EQ(actual->cache_rest, expect->cache_rest); - EXPECT_EQ(actual->callback, expect->callback); - EXPECT_EQ(actual->fd_status, expect->fd_status); - EXPECT_EQ(actual->mode, expect->mode); - EXPECT_STREQ(actual->object, expect->object); - EXPECT_EQ(actual->position, expect->position); - EXPECT_EQ(actual->recive_cnt, expect->recive_cnt); - EXPECT_EQ(actual->userdata, expect->userdata); + ASSERT_STREQ(actual->bucket, expect->bucket); + //ASSERT_TRUE(actual->cache == NULL); + ASSERT_EQ(actual->cache_count, expect->cache_count); + ASSERT_EQ(actual->cache_rest, expect->cache_rest); + ASSERT_EQ(actual->callback, expect->callback); + ASSERT_EQ(actual->fd_status, expect->fd_status); + ASSERT_EQ(actual->mode, expect->mode); + ASSERT_STREQ(actual->object, expect->object); + ASSERT_EQ(actual->position, expect->position); + ASSERT_EQ(actual->recive_cnt, expect->recive_cnt); + ASSERT_EQ(actual->userdata, expect->userdata); } } void CheckHosInstance(hos_instance actual, hos_instance expect) { - EXPECT_EQ(actual->status, expect->status); - EXPECT_EQ(actual->error_code, expect->error_code); - EXPECT_STREQ(actual->error_message, expect->error_message); - EXPECT_STREQ(actual->hos_url_prefix, expect->hos_url_prefix); + ASSERT_EQ(actual->status, expect->status); + ASSERT_EQ(actual->error_code, expect->error_code); + ASSERT_STREQ(actual->error_message, expect->error_message); + ASSERT_STREQ(actual->hos_url_prefix, expect->hos_url_prefix); } \ No newline at end of file diff --git a/gtest/conf/conf b/gtest/conf/conf new file mode 120000 index 00000000..6535e3aa --- /dev/null +++ b/gtest/conf/conf @@ -0,0 +1 @@ +/root/project/hos_client_cpp_module/gtest/conf \ No newline at end of file diff --git a/gtest/gtest_hos_close_fd.cpp b/gtest/gtest_hos_close_fd.cpp index 7d953521..262e7dd9 100644 --- a/gtest/gtest_hos_close_fd.cpp +++ b/gtest/gtest_hos_close_fd.cpp @@ -51,9 +51,10 @@ static void gtest_hos_instance_init(hos_instance instance) static void gtest_hos_fd_init(hos_fd_context_t *fd_info) { - memset(fd_info, 0, sizeof(hos_fd_context_t)); + fd_info->mode = 0; fd_info->bucket = (char *)HOS_BUCKET; fd_info->object = (char *)"object"; + fd_info->cache = NULL; fd_info->cache_count = 10; fd_info->cache_rest = g_hos_handle.hos_config.cache_size; fd_info->callback = NULL; @@ -62,6 +63,10 @@ static void gtest_hos_fd_init(hos_fd_context_t *fd_info) fd_info->position = 0; fd_info->recive_cnt = 0; fd_info->userdata = NULL; + fd_info->reslut = false; + fd_info->error = NULL; + fd_info->errorcode = 0; + fd_info->thread_id = 0; } TEST(hos_close_fd, normal) @@ -72,25 +77,26 @@ TEST(hos_close_fd, normal) int thread_num = 2; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); + ASSERT_NE(hos_instance, nullptr); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); + hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info); CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info); int ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -123,7 +129,7 @@ TEST(hos_close_fd, paramer_error) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); + hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info); @@ -131,12 +137,12 @@ TEST(hos_close_fd, paramer_error) ((hos_fd_context_t *)fd)->thread_id = thread_num + 1; int ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_PARAMETER_ERROR); + ASSERT_EQ(ret, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -157,7 +163,7 @@ TEST(hos_close_fd, paramer_error) TEST(hos_close_fd, not_init_instance) { int ret = hos_close_fd(1); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT); + ASSERT_EQ(ret, HOS_INSTANCE_NOT_INIT); } #if 0 @@ -175,12 +181,12 @@ TEST(hos_close_fd, fd_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_close_fd(7, 0); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); diff --git a/gtest/gtest_hos_get_instance.cpp b/gtest/gtest_hos_get_instance.cpp index 548d0b5e..2d3ee0eb 100644 --- a/gtest/gtest_hos_get_instance.cpp +++ b/gtest/gtest_hos_get_instance.cpp @@ -75,7 +75,7 @@ TEST(hos_get_instance, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); diff --git a/gtest/gtest_hos_init_instance.cpp b/gtest/gtest_hos_init_instance.cpp index 2102e7a7..a021de2f 100644 --- a/gtest/gtest_hos_init_instance.cpp +++ b/gtest/gtest_hos_init_instance.cpp @@ -67,7 +67,7 @@ TEST(hos_init_instance, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); memset(&expect_hos_instance, 0, sizeof(expect_hos_instance)); CheckHosInstance(hos_instance, &expect_hos_instance); @@ -92,7 +92,7 @@ TEST(hos_init_instance, param_error) ASSERT_EQ(hos_instance, nullptr); expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.error_code = HOS_PARAMETER_ERROR; - const char *err_msg = "param error:conf_path:(null), module:hos_default_conf, thread_num:1"; + const char *err_msg = "param error:conf_path:NULL, module:hos_default_conf, thread_num:1"; memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1); expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(&g_hos_instance, &expect_hos_instance); @@ -129,7 +129,7 @@ TEST(hos_init_instance, server_conn_failed) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); memset(&expect_hos_instance, 0, sizeof(expect_hos_instance)); CheckHosInstance(hos_instance, &expect_hos_instance); diff --git a/gtest/gtest_hos_open_fd.cpp b/gtest/gtest_hos_open_fd.cpp index ade49852..05752f62 100644 --- a/gtest/gtest_hos_open_fd.cpp +++ b/gtest/gtest_hos_open_fd.cpp @@ -51,9 +51,10 @@ static void gtest_hos_instance_init(hos_instance instance) static void gtest_hos_fd_init(hos_fd_context_t *fd_info) { - memset(fd_info, 0, sizeof(hos_fd_context_t)); + fd_info->mode = 0; fd_info->bucket = (char *)HOS_BUCKET; fd_info->object = (char *)"object"; + fd_info->cache = NULL; fd_info->cache_count = 10; fd_info->cache_rest = g_hos_handle.hos_config.cache_size; fd_info->callback = NULL; @@ -62,6 +63,10 @@ static void gtest_hos_fd_init(hos_fd_context_t *fd_info) fd_info->position = 0; fd_info->recive_cnt = 0; fd_info->userdata = NULL; + fd_info->reslut = false; + fd_info->error = NULL; + fd_info->errorcode = 0; + fd_info->thread_id = 0; } TEST(hos_open_fd, normal) @@ -78,31 +83,31 @@ TEST(hos_open_fd, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); + hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[0]); CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info[0]); size_t fd1 = 0; - err = hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 1, &fd1); + hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 1, &fd1); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[1]); CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); int ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_close_fd(fd1); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -133,12 +138,12 @@ TEST(hos_open_fd, paramer_error) size_t fd = 0; int err = hos_open_fd(NULL, "object", NULL, NULL, 0, &fd); - EXPECT_EQ(err, HOS_PARAMETER_ERROR); + ASSERT_EQ(err, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -169,12 +174,12 @@ TEST(hos_open_fd, over_threadnums) size_t fd = 0; int err = hos_open_fd(HOS_CONF, "object", NULL, NULL, 3, &fd); - EXPECT_EQ(err, HOS_PARAMETER_ERROR); + ASSERT_EQ(err, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -196,5 +201,5 @@ TEST(hos_open_fd, not_init_instance) { size_t fd = 0; int err = hos_open_fd(HOS_CONF, "object", NULL, NULL, 0, &fd); - EXPECT_EQ(err, HOS_INSTANCE_NOT_ENABLE); + ASSERT_EQ(err, HOS_INSTANCE_NOT_ENABLE); } \ No newline at end of file diff --git a/gtest/gtest_hos_shutdown_instance.cpp b/gtest/gtest_hos_shutdown_instance.cpp index dbebf8df..5688ced6 100644 --- a/gtest/gtest_hos_shutdown_instance.cpp +++ b/gtest/gtest_hos_shutdown_instance.cpp @@ -59,7 +59,6 @@ TEST(hos_shutdown_instance, normal) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1); gtest_hos_instance_init(&expect_hos_instance); @@ -68,7 +67,7 @@ TEST(hos_shutdown_instance, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -89,14 +88,13 @@ TEST(hos_shutdown_instance, normal) TEST(hos_shutdown_instance, no_init) { int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT); + ASSERT_EQ(ret, HOS_INSTANCE_NOT_INIT); } TEST(hos_shutdown_instance, shutdown_more) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1); gtest_hos_instance_init(&expect_hos_instance); @@ -105,7 +103,7 @@ TEST(hos_shutdown_instance, shutdown_more) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -123,7 +121,7 @@ TEST(hos_shutdown_instance, shutdown_more) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT); + ASSERT_EQ(ret, HOS_INSTANCE_NOT_INIT); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); } diff --git a/gtest/gtest_hos_upload_buff.cpp b/gtest/gtest_hos_upload_buff.cpp index c12eaf26..276ff410 100644 --- a/gtest/gtest_hos_upload_buff.cpp +++ b/gtest/gtest_hos_upload_buff.cpp @@ -53,29 +53,28 @@ static void gtest_hos_instance_init(hos_instance instance) static void hos_callback(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, true); - EXPECT_STREQ(bucket, HOS_BUCKET); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, NULL); - EXPECT_EQ(error, nullptr); - EXPECT_EQ(errorcode, 0); + ASSERT_EQ(result, true); + ASSERT_STREQ(bucket, HOS_BUCKET); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, NULL); + ASSERT_EQ(error, nullptr); + ASSERT_EQ(errorcode, 0); } static void hos_bucket_not_exits_cb(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, false); - EXPECT_STREQ(bucket, "bucket_not_exits"); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, "The specified bucket does not exist."); - EXPECT_EQ(errorcode, NO_SUCH_BUCKET); + ASSERT_EQ(result, false); + ASSERT_STREQ(bucket, "bucket_not_exits"); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, "The specified bucket does not exist."); + ASSERT_EQ(errorcode, NO_SUCH_BUCKET); } TEST(hos_upload_buff, normal) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -86,7 +85,7 @@ TEST(hos_upload_buff, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_buf(HOS_BUCKET, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[0] += strlen(HOS_BUFF); data_info->rx_pkts[0] += 1; data_info->tx_bytes[0] += strlen(HOS_BUFF); @@ -95,7 +94,7 @@ TEST(hos_upload_buff, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -116,7 +115,6 @@ TEST(hos_upload_buff, bucket_not_exits) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -127,7 +125,7 @@ TEST(hos_upload_buff, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_buf("bucket_not_exits", "object", HOS_BUFF, strlen(HOS_BUFF), hos_bucket_not_exits_cb, (void *)"object", 0); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[0] += strlen(HOS_BUFF); data_info->rx_pkts[0] += 1; data_info->tx_failed_bytes[0] += strlen(HOS_BUFF); @@ -136,7 +134,7 @@ TEST(hos_upload_buff, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -157,7 +155,6 @@ TEST(hos_upload_buff, param_error) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -168,12 +165,12 @@ TEST(hos_upload_buff, param_error) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_buf(NULL, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0); - EXPECT_EQ(ret, HOS_PARAMETER_ERROR); + ASSERT_EQ(ret, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -193,5 +190,5 @@ TEST(hos_upload_buff, param_error) TEST(hos_upload_buff, not_init_instance) { int ret = hos_upload_buf(HOS_BUCKET, "object", HOS_BUFF, strlen(HOS_BUFF), hos_callback, (void *)"object", 0); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); + ASSERT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); } diff --git a/gtest/gtest_hos_upload_file.cpp b/gtest/gtest_hos_upload_file.cpp index 23c47010..0c6bb150 100644 --- a/gtest/gtest_hos_upload_file.cpp +++ b/gtest/gtest_hos_upload_file.cpp @@ -53,29 +53,28 @@ static void gtest_hos_instance_init(hos_instance instance) static void hos_callback(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, true); - EXPECT_STREQ(bucket, HOS_BUCKET); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, NULL); - EXPECT_EQ(error, nullptr); - EXPECT_EQ(errorcode, 0); + ASSERT_EQ(result, true); + ASSERT_STREQ(bucket, HOS_BUCKET); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, NULL); + ASSERT_EQ(error, nullptr); + ASSERT_EQ(errorcode, 0); } static void hos_bucket_not_exits_cb(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, false); - EXPECT_STREQ(bucket, HOS_CONF); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, "The specified bucket does not exist."); - EXPECT_EQ(errorcode, NO_SUCH_BUCKET); + ASSERT_EQ(result, false); + ASSERT_STREQ(bucket, HOS_CONF); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, "The specified bucket does not exist."); + ASSERT_EQ(errorcode, NO_SUCH_BUCKET); } TEST(hos_upload_file, normal) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -86,7 +85,7 @@ TEST(hos_upload_file, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_file(HOS_BUCKET, HOS_BUFF, hos_callback, (void *)HOS_BUFF, 0); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); struct stat buffer; stat(HOS_BUFF, &buffer); data_info->rx_bytes[0] += buffer.st_size; @@ -97,7 +96,7 @@ TEST(hos_upload_file, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -118,7 +117,6 @@ TEST(hos_upload_file, param_error) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -129,12 +127,12 @@ TEST(hos_upload_file, param_error) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_file(NULL, "object", hos_callback, (void *)"object", 0); - EXPECT_EQ(ret, HOS_PARAMETER_ERROR); + ASSERT_EQ(ret, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -155,7 +153,6 @@ TEST(hos_upload_file, file_not_exits) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -166,12 +163,12 @@ TEST(hos_upload_file, file_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_file(HOS_BUCKET, "file_not_exits", hos_callback, (void *)"object", 0); - EXPECT_EQ(ret, HOS_FILE_NOT_EXIST); + ASSERT_EQ(ret, HOS_FILE_NOT_EXIST); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -191,14 +188,13 @@ TEST(hos_upload_file, file_not_exits) TEST(hos_upload_file, not_init_instance) { int ret = hos_upload_file(HOS_BUCKET, HOS_BUFF, hos_callback, (void *)"object", 0); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); + ASSERT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); } TEST(hos_upload_file, bucket_not_exits) { hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_fd_context_t expect_fd_info; data_info_t *data_info = NULL; hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); @@ -209,7 +205,7 @@ TEST(hos_upload_file, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_upload_file(HOS_CONF, HOS_CONF, hos_bucket_not_exits_cb, (void *)HOS_CONF, 0); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); struct stat buffer; stat(HOS_CONF, &buffer); data_info->rx_bytes[0] += buffer.st_size; @@ -220,7 +216,7 @@ TEST(hos_upload_file, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); diff --git a/gtest/gtest_hos_write.cpp b/gtest/gtest_hos_write.cpp index a987a165..574bb004 100644 --- a/gtest/gtest_hos_write.cpp +++ b/gtest/gtest_hos_write.cpp @@ -53,9 +53,10 @@ static void gtest_hos_instance_init(hos_instance instance) static void gtest_hos_fd_init(hos_fd_context_t *fd_info) { - memset(fd_info, 0, sizeof(hos_fd_context_t)); + fd_info->mode = 0; fd_info->bucket = (char *)HOS_BUCKET; fd_info->object = (char *)"object"; + fd_info->cache = NULL; fd_info->cache_count = 10; fd_info->cache_rest = g_hos_handle.hos_config.cache_size; fd_info->callback = NULL; @@ -64,46 +65,50 @@ static void gtest_hos_fd_init(hos_fd_context_t *fd_info) fd_info->position = 0; fd_info->recive_cnt = 0; fd_info->userdata = NULL; + fd_info->reslut = false; + fd_info->error = NULL; + fd_info->errorcode = 0; + fd_info->thread_id = 0; } static void hos_callback(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, true); - EXPECT_STREQ(bucket, HOS_BUCKET); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, NULL); - EXPECT_EQ(errorcode, 0); + ASSERT_EQ(result, true); + ASSERT_STREQ(bucket, HOS_BUCKET); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, NULL); + ASSERT_EQ(errorcode, 0); } static void hos_write_buff_cb(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, true); - EXPECT_STREQ(bucket, HOS_BUCKET); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, NULL); - EXPECT_EQ(errorcode, 0); + ASSERT_EQ(result, true); + ASSERT_STREQ(bucket, HOS_BUCKET); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, NULL); + ASSERT_EQ(errorcode, 0); } static void hos_write_append_cb(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, true); - EXPECT_STREQ(bucket, HOS_BUCKET); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, NULL); - EXPECT_EQ(errorcode, 0); + ASSERT_EQ(result, true); + ASSERT_STREQ(bucket, HOS_BUCKET); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, NULL); + ASSERT_EQ(errorcode, 0); } static void hos_bucket_not_exits_cb(bool result, const char *bucket, const char *object, const char *error, size_t errorcode, void *userdata) { SUCCEED(); - EXPECT_EQ(result, false); - EXPECT_STREQ(bucket, "bucket_not_exits"); - EXPECT_STREQ(object, (char *)userdata); - EXPECT_STREQ(error, "The specified bucket does not exist."); - EXPECT_EQ(errorcode, NO_SUCH_BUCKET); + ASSERT_EQ(result, false); + ASSERT_STREQ(bucket, "bucket_not_exits"); + ASSERT_STREQ(object, (char *)userdata); + ASSERT_STREQ(error, "The specified bucket does not exist."); + ASSERT_EQ(errorcode, NO_SUCH_BUCKET); } TEST(hos_write, normal) @@ -122,7 +127,7 @@ TEST(hos_write, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object_buff", hos_write_buff_cb, (void *)"object_buff", 0, &fd); + hos_open_fd(HOS_BUCKET, "object_buff", hos_write_buff_cb, (void *)"object_buff", 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[0]); @@ -132,7 +137,7 @@ TEST(hos_write, normal) CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info[0]); int ret = hos_write(fd, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_fd_info[0].fd_status = 2; data_info->rx_bytes[0] += strlen(HOS_BUFF); data_info->rx_pkts[0] +=1; @@ -142,7 +147,7 @@ TEST(hos_write, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd1 = 0; - err = hos_open_fd(HOS_BUCKET, "object_append", hos_write_append_cb, (void *)"object_append", 1, &fd1); + hos_open_fd(HOS_BUCKET, "object_append", hos_write_append_cb, (void *)"object_append", 1, &fd1); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[1]); @@ -152,7 +157,7 @@ TEST(hos_write, normal) CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] +=1; data_info->cache[1] += strlen(HOS_BUFF); @@ -161,10 +166,10 @@ TEST(hos_write, normal) expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); expect_fd_info[1].cache_count--; CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] +=1; data_info->cache[1] += strlen(HOS_BUFF); @@ -173,18 +178,18 @@ TEST(hos_write, normal) expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); expect_fd_info[1].cache_count--; CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_bytes[0] += data_info->cache[0]; data_info->tx_pkts[0] += 1; data_info->cache[0] = 0; CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_close_fd(fd1); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_bytes[1] += data_info->cache[1]; data_info->tx_pkts[1] += 1; data_info->cache[1] = 0; @@ -192,7 +197,7 @@ TEST(hos_write, normal) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -225,7 +230,7 @@ TEST(hos_write, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd("bucket_not_exits", "object_buff", hos_bucket_not_exits_cb, (void *)"object_buff", 0, &fd); + hos_open_fd("bucket_not_exits", "object_buff", hos_bucket_not_exits_cb, (void *)"object_buff", 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[0]); @@ -236,7 +241,7 @@ TEST(hos_write, bucket_not_exits) CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info[0]); int ret = hos_write(fd, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[0] = strlen(HOS_BUFF); data_info->rx_pkts[0] += 1; data_info->cache[0] = strlen(HOS_BUFF); @@ -244,7 +249,7 @@ TEST(hos_write, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd1 = 0; - err = hos_open_fd("bucket_not_exits", "object_append", hos_bucket_not_exits_cb, (void *)"object_append", 1, &fd1); + hos_open_fd("bucket_not_exits", "object_append", hos_bucket_not_exits_cb, (void *)"object_append", 1, &fd1); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[1]); @@ -255,7 +260,7 @@ TEST(hos_write, bucket_not_exits) CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->cache[1] += strlen(HOS_BUFF); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] += 1; @@ -264,10 +269,10 @@ TEST(hos_write, bucket_not_exits) expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); expect_fd_info[1].cache_count--; CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->cache[1] += strlen(HOS_BUFF); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] += 1; @@ -276,17 +281,17 @@ TEST(hos_write, bucket_not_exits) expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); expect_fd_info[1].cache_count--; CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_failed_bytes[0] += data_info->cache[0]; data_info->tx_failed_pkts[0] += 1; data_info->cache[0] = 0; CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_close_fd(fd1); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_failed_bytes[1] += data_info->cache[1]; data_info->tx_failed_pkts[1] += 1; data_info->cache[1] = 0; @@ -294,7 +299,7 @@ TEST(hos_write, bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -328,7 +333,7 @@ TEST(hos_write, sync_mode) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object_buff", NULL, NULL, 0, &fd); + hos_open_fd(HOS_BUCKET, "object_buff", NULL, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[0]); @@ -336,7 +341,7 @@ TEST(hos_write, sync_mode) CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info[0]); int ret = hos_write(fd, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[0] += strlen(HOS_BUFF); data_info->rx_pkts[0] += 1; data_info->cache[0] += strlen(HOS_BUFF); @@ -344,7 +349,7 @@ TEST(hos_write, sync_mode) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd1 = 0; - err = hos_open_fd(HOS_BUCKET, "object_append", NULL, NULL, 1, &fd1); + hos_open_fd(HOS_BUCKET, "object_append", NULL, NULL, 1, &fd1); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[1]); @@ -352,7 +357,7 @@ TEST(hos_write, sync_mode) CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] += 1; data_info->cache[1] += strlen(HOS_BUFF); @@ -361,10 +366,10 @@ TEST(hos_write, sync_mode) expect_fd_info[1].cache_count--; expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] += 1; data_info->cache[1] += strlen(HOS_BUFF); @@ -373,17 +378,17 @@ TEST(hos_write, sync_mode) expect_fd_info[1].cache_count--; expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_bytes[0] += data_info->cache[0]; data_info->tx_pkts[0] += 1; data_info->cache[0] = 0; CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_close_fd(fd1); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_bytes[1] += data_info->cache[1]; data_info->tx_pkts[1] += 1; data_info->cache[1] = 0; @@ -391,7 +396,7 @@ TEST(hos_write, sync_mode) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -425,7 +430,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_CONF, "object_buff", NULL, NULL, 0, &fd); + hos_open_fd(HOS_CONF, "object_buff", NULL, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[0]); @@ -434,7 +439,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info[0]); int ret = hos_write(fd, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_fd_info[0].fd_status = 2; data_info->rx_bytes[0] += strlen(HOS_BUFF); data_info->rx_pkts[0] += 1; @@ -443,7 +448,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd1 = 0; - err = hos_open_fd(HOS_CONF, "object_append", NULL, NULL, 1, &fd1); + hos_open_fd(HOS_CONF, "object_append", NULL, NULL, 1, &fd1); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info[1]); @@ -452,7 +457,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] += 1; data_info->cache[1] += strlen(HOS_BUFF); @@ -461,10 +466,10 @@ TEST(hos_write, sync_mode_bucket_not_exits) expect_fd_info[1].cache_count--; expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_write(fd1, HOS_BUFF, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->rx_bytes[1] += strlen(HOS_BUFF); data_info->rx_pkts[1] += 1; data_info->cache[1] += strlen(HOS_BUFF); @@ -473,17 +478,17 @@ TEST(hos_write, sync_mode_bucket_not_exits) expect_fd_info[1].cache_count--; expect_fd_info[1].cache_rest -= strlen(HOS_BUFF); CheckStructGHosFdContext((hos_fd_context_t *)fd1, &expect_fd_info[1]); - EXPECT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); + ASSERT_TRUE(((hos_fd_context_t *)fd1)->cache != NULL); ret = hos_close_fd(fd); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_failed_bytes[0] += data_info->cache[0]; data_info->tx_failed_pkts[0] += 1; data_info->cache[0] = 0; CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_close_fd(fd1); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); data_info->tx_failed_bytes[1] += data_info->cache[1]; data_info->tx_failed_pkts[1] += 1; data_info->cache[1] = 0; @@ -491,7 +496,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -522,7 +527,7 @@ TEST(hos_write, paramer_error) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object_buff", hos_callback, NULL, 0, &fd); + hos_open_fd(HOS_BUCKET, "object_buff", hos_callback, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info); @@ -531,12 +536,12 @@ TEST(hos_write, paramer_error) CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info); int ret = hos_write(fd, NULL, strlen(HOS_BUFF)); - EXPECT_EQ(ret, HOS_PARAMETER_ERROR); + ASSERT_EQ(ret, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -569,12 +574,12 @@ TEST(hos_write, fd_not_find) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); int ret = hos_write(3, HOS_BUFF, strlen(HOS_CONF), 0); - EXPECT_EQ(ret, HOS_HASH_NOT_FIND); + ASSERT_EQ(ret, HOS_HASH_NOT_FIND); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -607,7 +612,7 @@ TEST(hos_write, over_threadnums) CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); size_t fd = 0; - int err = hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); + hos_open_fd(HOS_BUCKET, "object", NULL, NULL, 0, &fd); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); gtest_hos_fd_init(&expect_fd_info); @@ -615,12 +620,12 @@ TEST(hos_write, over_threadnums) CheckStructGHosFdContext((hos_fd_context_t *)fd, &expect_fd_info); int ret = hos_write(fd, NULL, strlen(HOS_CONF)); - EXPECT_EQ(ret, HOS_PARAMETER_ERROR); + ASSERT_EQ(ret, HOS_PARAMETER_ERROR); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); ret = hos_shutdown_instance(); - EXPECT_EQ(ret, HOS_CLIENT_OK); + ASSERT_EQ(ret, HOS_CLIENT_OK); expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -641,7 +646,7 @@ TEST(hos_write, over_threadnums) TEST(hos_write, not_init_instance) { int ret = hos_write(3, HOS_BUFF, strlen(HOS_CONF)); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); + ASSERT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); } static void read_file(char *path, char **content, int *len) @@ -675,7 +680,6 @@ static void *hos_function(void *ptr) hos_fd_context_t expect_fd_info[32][20]; int thread_num = 32; data_info_t *data_info = NULL; - int err = 0; { hos_instance = hos_get_instance(); @@ -693,8 +697,8 @@ static void *hos_function(void *ptr) for (i = 0; i < HOS_FD_NUMS_LOCAL; i++) { - snprintf(object[i], 1024, "object_%lu_%d", thread_id, i); - err = hos_open_fd(HOS_BUCKET, object[i], hos_callback, object[i], 0, &fd[i]); + snprintf(object[i], 1024, "object_%zu_%d", thread_id, i); + int err = hos_open_fd(HOS_BUCKET, object[i], hos_callback, object[i], 0, &fd[i]); EXPECT_EQ(err, i + 1); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index fb59c10f..218e8400 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -20,22 +20,6 @@ if (HOS_MESA_LOG) add_definitions(-DHOS_MESA_LOG) endif() -find_program(CMAKE_CXX_CPPCHECK NAMES cppcheck) -if (CMAKE_CXX_CPPCHECK) - list( - APPEND CMAKE_CXX_CPPCHECK - "--enable=all" - "--error-exitcode=1" - "--suppress=unusedFunction" - "--suppress=missingInclude" - "--suppress=uselessAssignmentPtrArg" - "--suppress=unmatchedSuppression" - ) - set(CMAKE_C_CPPCHECK ${CMAKE_CXX_CPPCHECK}) -else() - message(FATAL_ERROR "Could not find the program cppcheck.") -endif() - file(GLOB HOS_SRC ${HOS_SOURCE} ${HOS_HEADERS} diff --git a/support/CMakeLists.txt b/support/CMakeLists.txt index a094c04b..e877de13 100644 --- a/support/CMakeLists.txt +++ b/support/CMakeLists.txt @@ -22,3 +22,20 @@ ExternalProject_Add(aws-sdk-cpp-master add_dependencies(aws-sdk-cpp-master-static aws-sdk-cpp-master) set_property(TARGET aws-sdk-cpp-master-static PROPERTY IMPORTED_LOCATION ${SUPPORT_INSTALL_PREFIX}) +#### GoogleTest +ExternalProject_Add(GoogleTest + PREFIX GoogleTest + URL ${CMAKE_CURRENT_SOURCE_DIR}/googletest-release-1.8.0.tar.gz + URL_MD5 16877098823401d1bf2ed7891d7dce36 + CMAKE_ARGS -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DBUILD_SHARED_LIBS=ON) + +ExternalProject_Get_Property(GoogleTest INSTALL_DIR) +file(MAKE_DIRECTORY ${INSTALL_DIR}/include) +add_library(gtest SHARED IMPORTED GLOBAL) +add_dependencies(gtest GoogleTest) +set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgtest.so) +#set_property(TARGET gtest PROPERTY IMPORTED_LOCATION ${INSTALL_DIR}/lib/libgtest_main.so) +set_property(TARGET gtest PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${INSTALL_DIR}/include) +set_property(TARGET gtest PROPERTY INTERFACE_LINK_LIBRARIES pthread) + + diff --git a/support/googletest-release-1.8.0.tar.gz b/support/googletest-release-1.8.0.tar.gz new file mode 100644 index 00000000..a40df33f Binary files /dev/null and b/support/googletest-release-1.8.0.tar.gz differ