summaryrefslogtreecommitdiff
path: root/test/src/gtest_master.cpp
diff options
context:
space:
mode:
authorliuxueli <[email protected]>2023-06-12 15:42:46 +0800
committerliuxueli <[email protected]>2023-06-12 15:42:46 +0800
commit03b39fc31431a60c411aa8455a636110ca1eeb4e (patch)
tree61a99e070057504062d4c1c7be85097619907d1f /test/src/gtest_master.cpp
parent3dea0f5399f2d749e188de9bfb94cd02f93f8a02 (diff)
优化存储application的空间
Diffstat (limited to 'test/src/gtest_master.cpp')
-rw-r--r--test/src/gtest_master.cpp45
1 files changed, 23 insertions, 22 deletions
diff --git a/test/src/gtest_master.cpp b/test/src/gtest_master.cpp
index 0a2b20c..047aa9f 100644
--- a/test/src/gtest_master.cpp
+++ b/test/src/gtest_master.cpp
@@ -20,31 +20,32 @@ extern void session_segment_id_free(const struct streaminfo * a_stream, int brid
TEST(TSGMaster, SetAPPIDHttp)
{
const struct streaminfo a_stream={0};
- struct gather_app_result async_gather_result[ORIGIN_MAX]={0};
-
- async_gather_result[ORIGIN_BASIC_PROTOCOL].app_num=1;
- async_gather_result[ORIGIN_BASIC_PROTOCOL].origin=ORIGIN_BASIC_PROTOCOL;
- async_gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id=67; //HTTP
-
- session_gather_app_results_async(&a_stream, (void *)async_gather_result);
- struct gather_app_result *gather_result=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
- EXPECT_NE(nullptr, gather_result);
- EXPECT_EQ(1, gather_result[ORIGIN_BASIC_PROTOCOL].app_num);
- EXPECT_EQ(67, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id);
- EXPECT_EQ(0, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].packet_sequence);
- EXPECT_EQ(0, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].surrogate_id);
- EXPECT_EQ(ORIGIN_BASIC_PROTOCOL, gather_result[ORIGIN_BASIC_PROTOCOL].origin);
+ struct gather_app_result *gather_result_in=(struct gather_app_result *)dictator_malloc(0, sizeof(struct gather_app_result));
+ memset(gather_result_in, 0, sizeof(struct gather_app_result));
+
+ gather_result_in->l7_protocol_num=1;
+ gather_result_in->l7_protocol=(struct app_attributes *)dictator_malloc(0, sizeof(struct app_attributes));
+ gather_result_in->l7_protocol[0].app_id=67; //HTTP
+ gather_result_in->l7_protocol[0].surrogate_id=0; //HTTP
+ gather_result_in->l7_protocol[0].packet_sequence=1; //HTTP
+
+ session_gather_app_results_async(&a_stream, (void *)gather_result_in);
+ struct gather_app_result *gather_result_out=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
+ EXPECT_NE(nullptr, gather_result_out);
+ EXPECT_EQ(1, gather_result_out->l7_protocol_num);
+ EXPECT_EQ(67, gather_result_out->l7_protocol[0].app_id);
+ EXPECT_EQ(0, gather_result_out->l7_protocol[0].surrogate_id);
+ EXPECT_EQ(1, gather_result_out->l7_protocol[0].packet_sequence);
struct TLD_handle_t *handle=TLD_create(0);
set_app_id(g_tsg_log_instance, handle, (struct streaminfo *)&a_stream);
char app_ids[256]={0};
TLD_convert_json(handle, app_ids, sizeof(app_ids));
- EXPECT_STREQ("{\"common_app_full_path\":\"http\",\"common_app_label\":\"http\",\"common_app_id\":{\"LPI_L7\":[{\"app_name\":\"http\",\"app_id\":67,\"surrogate_id\":0,\"packet_sequence\":0}]}}", app_ids);
+ EXPECT_STREQ("{\"common_app_full_path\":\"http\",\"common_app_label\":\"http\",\"common_app_id\":{\"LPI_L7\":[{\"app_name\":\"http\",\"app_id\":67,\"surrogate_id\":0,\"packet_sequence\":1}]}}", app_ids);
-
+ dictator_free(0, gather_result_out);
session_gather_app_results_async(&a_stream, NULL);
- gather_result=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
- EXPECT_EQ(nullptr, gather_result);
+ EXPECT_EQ(nullptr, session_gather_app_results_get(&a_stream));
}
TEST(TSGMaster, SetAPPIDUnknown)
@@ -989,11 +990,11 @@ TEST(TSGMaster, SessionDealStatePending)
struct gather_app_result *gather_result=(struct gather_app_result *)session_gather_app_results_get(&a_stream);
EXPECT_NE(nullptr, gather_result);
- EXPECT_EQ(1, gather_result[ORIGIN_BASIC_PROTOCOL].app_num);
- EXPECT_EQ(45, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id);
- EXPECT_EQ(0, gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].surrogate_id);
+ EXPECT_EQ(1, gather_result->l7_protocol_num);
+ EXPECT_EQ(45, gather_result->l7_protocol[0].app_id);
+ EXPECT_EQ(0, gather_result->l7_protocol[0].surrogate_id);
- free(gather_result);
+ dictator_free(0, gather_result);
session_gather_app_results_async(&a_stream, NULL);
EXPECT_EQ(nullptr, session_gather_app_results_get(&a_stream));