diff options
Diffstat (limited to 'gtest')
| -rw-r--r-- | gtest/CMakeLists.txt | 4 | ||||
| -rw-r--r-- | gtest/CheckHosClient.cpp | 2 | ||||
| -rw-r--r-- | gtest/conf/default.conf | 2 | ||||
| -rw-r--r-- | gtest/gtest_hos_close_fd.cpp | 16 | ||||
| -rw-r--r-- | gtest/gtest_hos_get_instance.cpp | 11 | ||||
| -rw-r--r-- | gtest/gtest_hos_init_instance.cpp | 67 | ||||
| -rw-r--r-- | gtest/gtest_hos_open_fd.cpp | 17 | ||||
| -rw-r--r-- | gtest/gtest_hos_shutdown_instance.cpp | 13 | ||||
| -rw-r--r-- | gtest/gtest_hos_upload_buff.cpp | 19 | ||||
| -rw-r--r-- | gtest/gtest_hos_upload_file.cpp | 24 | ||||
| -rw-r--r-- | gtest/gtest_hos_write.cpp | 38 |
11 files changed, 106 insertions, 107 deletions
diff --git a/gtest/CMakeLists.txt b/gtest/CMakeLists.txt index db8c5f56..3dabf565 100644 --- a/gtest/CMakeLists.txt +++ b/gtest/CMakeLists.txt @@ -13,7 +13,7 @@ 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_write.cpp) -#add_executable(gtest_hos_client ${SRCS}) +#add_executable(gtest_hos_client CheckHosClient.cpp gtest_hos_write.cpp) +add_executable(gtest_hos_client ${SRCS}) target_link_libraries(gtest_hos_client hos-client-cpp gtest gtest_main pthread) diff --git a/gtest/CheckHosClient.cpp b/gtest/CheckHosClient.cpp index b9f64d1d..644c4ab0 100644 --- a/gtest/CheckHosClient.cpp +++ b/gtest/CheckHosClient.cpp @@ -109,7 +109,7 @@ void CheckStructGHosFdContext(hos_fd_context_t *actual, hos_fd_context_t *expect void CheckHosInstance(hos_instance actual, hos_instance expect) { - EXPECT_EQ(actual->result, expect->result); + 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); diff --git a/gtest/conf/default.conf b/gtest/conf/default.conf index 8f4e081f..7715c654 100644 --- a/gtest/conf/default.conf +++ b/gtest/conf/default.conf @@ -97,7 +97,7 @@ hos_log_path="./hoslog" #default hos_log_level=30 #default -hos_poolsize=0 +hos_poolsize=10 #default hos_cache_size=102400 #default diff --git a/gtest/gtest_hos_close_fd.cpp b/gtest/gtest_hos_close_fd.cpp index 0311440a..bfbdc3b7 100644 --- a/gtest/gtest_hos_close_fd.cpp +++ b/gtest/gtest_hos_close_fd.cpp @@ -43,7 +43,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -71,7 +71,7 @@ TEST(hos_close_fd, normal) hos_fd_context_t expect_fd_info; int thread_num = 2; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -90,7 +90,7 @@ TEST(hos_close_fd, normal) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -114,7 +114,7 @@ TEST(hos_close_fd, paramer_error) hos_fd_context_t expect_fd_info; int thread_num = 2; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -133,7 +133,7 @@ TEST(hos_close_fd, paramer_error) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -164,7 +164,7 @@ TEST(hos_close_fd, fd_not_exits) hos_fd_context_t expect_fd_info; int thread_num = 2; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -177,7 +177,7 @@ TEST(hos_close_fd, fd_not_exits) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -193,4 +193,4 @@ TEST(hos_close_fd, fd_not_exits) memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); } -#endif
\ No newline at end of file +#endif diff --git a/gtest/gtest_hos_get_instance.cpp b/gtest/gtest_hos_get_instance.cpp index 03528aea..548d0b5e 100644 --- a/gtest/gtest_hos_get_instance.cpp +++ b/gtest/gtest_hos_get_instance.cpp @@ -43,7 +43,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -55,11 +55,10 @@ TEST(hos_get_instance, normal) hos_client_handle_t expect_hos_handle; hos_instance hos_instance = hos_get_instance(); - memset(&expect_hos_instance, 0, sizeof(hos_instance_s)); - expect_hos_instance.result = false; - CheckHosInstance(hos_instance, &expect_hos_instance); + ASSERT_EQ(hos_instance, nullptr); - hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET); + hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1); + 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, 1); @@ -77,7 +76,7 @@ TEST(hos_get_instance, normal) int ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + 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 bf27c431..2102e7a7 100644 --- a/gtest/gtest_hos_init_instance.cpp +++ b/gtest/gtest_hos_init_instance.cpp @@ -48,7 +48,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -59,7 +59,8 @@ TEST(hos_init_instance, normal) hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1); + ASSERT_NE(hos_instance, nullptr); gtest_hos_instance_init(&expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 1); CheckHosInstance(hos_instance, &expect_hos_instance); @@ -87,52 +88,60 @@ TEST(hos_init_instance, param_error) { hos_instance_s expect_hos_instance; - hos_instance hos_instance = hos_init_instance(NULL, "hos_default_conf", 1, HOS_BUCKET); - expect_hos_instance.result = false; + hos_instance hos_instance = hos_init_instance(NULL, "hos_default_conf", 1); + 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, bucket:firewall_hos_bucket"; + 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(hos_instance, &expect_hos_instance); -} - -TEST(hos_init_instance, bucket_not_exits) -{ - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1, "hos_bucket_not_exits"); - - hos_instance_s expect_hos_instance; - expect_hos_instance.result = false; - expect_hos_instance.error_code = HOS_BUCKET_NOT_EXIST; - const char *err_msg = "bucket:hos_bucket_not_exits not exits."; - memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1); - expect_hos_instance.hos_url_prefix = NULL; - CheckHosInstance(hos_instance, &expect_hos_instance); - - hos_client_handle_t expect_hos_handle; - memset(&expect_hos_handle, 0, sizeof(expect_hos_handle)); - CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); + CheckHosInstance(&g_hos_instance, &expect_hos_instance); } TEST(hos_init_instance, conf_error) { - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_conf", 1, "hos_bucket_not_exits"); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_conf", 1); + ASSERT_EQ(hos_instance, nullptr); hos_instance_s expect_hos_instance; - expect_hos_instance.result = false; + expect_hos_instance.status = INSTANCE_UNINIT_STATE; expect_hos_instance.error_code = HOS_CONF_ERROR; const char *err_msg = "hos param error:hos ip:, hos port:0, accesskeyid:, secretkey:"; memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1); expect_hos_instance.hos_url_prefix = NULL; - CheckHosInstance(hos_instance, &expect_hos_instance); + CheckHosInstance(&g_hos_instance, &expect_hos_instance); } TEST(hos_init_instance, server_conn_failed) { - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_server_conf", 1, "hos_bucket_not_exits"); hos_instance_s expect_hos_instance; - expect_hos_instance.result = false; + hos_client_handle_t expect_hos_handle; + + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_error_server_conf", 1); + memset(&expect_hos_instance, 0, sizeof(expect_hos_instance)); + expect_hos_instance.status = INSTANCE_ATTEMPT_STATE; expect_hos_instance.error_code = NETWORK_CONNECTION; const char *err_msg = "curlCode: 7, Couldn't connect to server"; memcpy(expect_hos_instance.error_message, err_msg, strlen(err_msg)+1); - expect_hos_instance.hos_url_prefix = NULL; + expect_hos_instance.hos_url_prefix = "http://192.168.40.146:9098/hos/"; + CheckHosInstance(hos_instance, &expect_hos_instance); + gtest_hos_handle_init(&expect_hos_handle, 1); + memcpy(expect_hos_handle.hos_config.ip, "192.168.40.146", INET_ADDRSTRLEN); + CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); + + int ret = hos_shutdown_instance(); + EXPECT_EQ(ret, HOS_CLIENT_OK); + memset(&expect_hos_instance, 0, sizeof(expect_hos_instance)); CheckHosInstance(hos_instance, &expect_hos_instance); + + Aws::Vector<Aws::S3::Model::Bucket>().swap(g_hos_handle.buckets); + data_info_t *data_info = (data_info_t *)expect_hos_handle.hos_func.fs2_info.reserved; + free(data_info->cache); + free(data_info->rx_bytes); + free(data_info->rx_pkts); + free(data_info->tx_bytes); + free(data_info->tx_pkts); + free(data_info->tx_failed_bytes); + free(data_info->tx_failed_pkts); + memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); + CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); }
\ No newline at end of file diff --git a/gtest/gtest_hos_open_fd.cpp b/gtest/gtest_hos_open_fd.cpp index 4fe22d13..401e2ed9 100644 --- a/gtest/gtest_hos_open_fd.cpp +++ b/gtest/gtest_hos_open_fd.cpp @@ -43,7 +43,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -70,7 +70,8 @@ TEST(hos_open_fd, normal) hos_client_handle_t expect_hos_handle; hos_fd_context_t expect_fd_info[2]; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); + 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, 2); @@ -100,7 +101,7 @@ TEST(hos_open_fd, normal) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -122,7 +123,7 @@ TEST(hos_open_fd, paramer_error) hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -135,7 +136,7 @@ TEST(hos_open_fd, paramer_error) int ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -157,7 +158,7 @@ TEST(hos_open_fd, over_threadnums) hos_instance_s expect_hos_instance; hos_client_handle_t expect_hos_handle; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -170,7 +171,7 @@ TEST(hos_open_fd, over_threadnums) int ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -190,5 +191,5 @@ TEST(hos_open_fd, over_threadnums) TEST(hos_open_fd, not_init_instance) { int fd = hos_open_fd(HOS_CONF, "object", NULL, NULL, 0); - EXPECT_EQ(fd, HOS_INSTANCE_NOT_INIT); + EXPECT_EQ(fd, 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 b371029a..dbebf8df 100644 --- a/gtest/gtest_hos_shutdown_instance.cpp +++ b/gtest/gtest_hos_shutdown_instance.cpp @@ -48,7 +48,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -61,7 +61,7 @@ TEST(hos_shutdown_instance, normal) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 1); @@ -69,7 +69,7 @@ TEST(hos_shutdown_instance, normal) int ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -84,7 +84,6 @@ TEST(hos_shutdown_instance, normal) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } TEST(hos_shutdown_instance, no_init) @@ -99,7 +98,7 @@ TEST(hos_shutdown_instance, shutdown_more) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 1); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 1); @@ -107,7 +106,7 @@ TEST(hos_shutdown_instance, shutdown_more) int ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -122,11 +121,9 @@ TEST(hos_shutdown_instance, shutdown_more) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT); CheckHosInstance(hos_instance, &expect_hos_instance); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } diff --git a/gtest/gtest_hos_upload_buff.cpp b/gtest/gtest_hos_upload_buff.cpp index 2edca10a..9ac78b06 100644 --- a/gtest/gtest_hos_upload_buff.cpp +++ b/gtest/gtest_hos_upload_buff.cpp @@ -44,7 +44,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -75,7 +75,7 @@ TEST(hos_upload_buff, normal) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -93,7 +93,7 @@ TEST(hos_upload_buff, normal) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -107,7 +107,6 @@ TEST(hos_upload_buff, normal) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } TEST(hos_upload_buff, bucket_not_exits) @@ -117,7 +116,7 @@ TEST(hos_upload_buff, bucket_not_exits) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -135,7 +134,7 @@ TEST(hos_upload_buff, bucket_not_exits) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -149,7 +148,6 @@ TEST(hos_upload_buff, bucket_not_exits) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } TEST(hos_upload_buff, param_error) @@ -159,7 +157,7 @@ TEST(hos_upload_buff, param_error) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -173,7 +171,7 @@ TEST(hos_upload_buff, param_error) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -187,11 +185,10 @@ TEST(hos_upload_buff, param_error) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } 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_INIT); + EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); } diff --git a/gtest/gtest_hos_upload_file.cpp b/gtest/gtest_hos_upload_file.cpp index 4f886fa3..57a22e72 100644 --- a/gtest/gtest_hos_upload_file.cpp +++ b/gtest/gtest_hos_upload_file.cpp @@ -44,7 +44,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -75,7 +75,7 @@ TEST(hos_upload_file, normal) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -95,7 +95,7 @@ TEST(hos_upload_file, normal) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -109,7 +109,6 @@ TEST(hos_upload_file, normal) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } TEST(hos_upload_file, param_error) @@ -119,7 +118,7 @@ TEST(hos_upload_file, param_error) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -133,7 +132,7 @@ TEST(hos_upload_file, param_error) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -147,7 +146,6 @@ TEST(hos_upload_file, param_error) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } TEST(hos_upload_file, file_not_exits) @@ -157,7 +155,7 @@ TEST(hos_upload_file, file_not_exits) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -171,7 +169,7 @@ TEST(hos_upload_file, file_not_exits) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -185,13 +183,12 @@ TEST(hos_upload_file, file_not_exits) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } 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_INIT); + EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); } TEST(hos_upload_file, bucket_not_exits) @@ -201,7 +198,7 @@ TEST(hos_upload_file, bucket_not_exits) 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, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", 2); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, 2); @@ -221,7 +218,7 @@ TEST(hos_upload_file, bucket_not_exits) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -235,5 +232,4 @@ TEST(hos_upload_file, bucket_not_exits) free(data_info->tx_failed_pkts); memset(&expect_hos_handle, 0, sizeof(hos_client_handle_s)); CheckStructGHosHandle(&g_hos_handle, &expect_hos_handle); - EXPECT_EQ((void *)g_fd_context, (void *)NULL); } diff --git a/gtest/gtest_hos_write.cpp b/gtest/gtest_hos_write.cpp index c84b1016..9f46d6f3 100644 --- a/gtest/gtest_hos_write.cpp +++ b/gtest/gtest_hos_write.cpp @@ -45,7 +45,7 @@ static void gtest_hos_handle_init(hos_client_handle_t *hos_handle, int thread_nu static void gtest_hos_instance_init(hos_instance instance) { memset(instance, 0, sizeof(hos_instance_s)); - instance->result = true; + instance->status = INSTANCE_ENABLE_STATE; instance->error_code = 0; instance->error_message[0] ='\0'; instance->hos_url_prefix = "http://127.0.0.1:9098/hos/"; @@ -110,7 +110,7 @@ TEST(hos_write, normal) hos_fd_context_t expect_fd_info[2]; data_info_t *data_info = NULL; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -187,7 +187,7 @@ TEST(hos_write, normal) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -211,7 +211,7 @@ TEST(hos_write, bucket_not_exits) int thread_num = 3; data_info_t *data_info = NULL; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -287,7 +287,7 @@ TEST(hos_write, bucket_not_exits) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -311,7 +311,7 @@ TEST(hos_write, sync_mode) int thread_num = 3; data_info_t * data_info = NULL; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -382,7 +382,7 @@ TEST(hos_write, sync_mode) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -406,7 +406,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) int thread_num = 3; data_info_t *data_info = NULL; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_sync_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -480,7 +480,7 @@ TEST(hos_write, sync_mode_bucket_not_exits) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -503,7 +503,7 @@ TEST(hos_write, paramer_error) hos_fd_context_t expect_fd_info; int thread_num = 2; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -524,7 +524,7 @@ TEST(hos_write, paramer_error) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -549,7 +549,7 @@ TEST(hos_write, fd_not_find) hos_fd_context_t expect_fd_info; int thread_num = 2; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -562,7 +562,7 @@ TEST(hos_write, fd_not_find) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -587,7 +587,7 @@ TEST(hos_write, over_threadnums) hos_fd_context_t expect_fd_info; int thread_num = 2; - hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); gtest_hos_instance_init(&expect_hos_instance); CheckHosInstance(hos_instance, &expect_hos_instance); gtest_hos_handle_init(&expect_hos_handle, thread_num); @@ -607,7 +607,7 @@ TEST(hos_write, over_threadnums) ret = hos_shutdown_instance(); EXPECT_EQ(ret, HOS_CLIENT_OK); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); @@ -627,7 +627,7 @@ TEST(hos_write, over_threadnums) TEST(hos_write, not_init_instance) { int ret = hos_write(3, HOS_BUFF, strlen(HOS_CONF), 0); - EXPECT_EQ(ret, HOS_INSTANCE_NOT_INIT); + EXPECT_EQ(ret, HOS_INSTANCE_NOT_ENABLE); } static void read_file(char *path, char **content, int *len) @@ -664,9 +664,9 @@ static void *hos_function(void *ptr) { hos_instance = hos_get_instance(); - if (hos_instance->result == false) + if (hos_instance == NULL) { - hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num, HOS_BUCKET); + hos_instance = hos_init_instance(HOS_CONF, "hos_default_conf", thread_num); } } gtest_hos_instance_init(&expect_hos_instance); @@ -723,7 +723,7 @@ static void *hos_function(void *ptr) ret = hos_shutdown_instance(); EXPECT_EQ(ret, 0); - expect_hos_instance.result = 0; + expect_hos_instance.status = 0; expect_hos_instance.hos_url_prefix = NULL; CheckHosInstance(hos_instance, &expect_hos_instance); |
