summaryrefslogtreecommitdiff
path: root/test/src/gtest_master.cpp
diff options
context:
space:
mode:
author刘学利 <[email protected]>2023-02-07 09:33:49 +0000
committer刘学利 <[email protected]>2023-02-07 09:33:49 +0000
commit6756fcdf7a96cc56f3fb54241e5f3088ef2f162d (patch)
tree265acda936303e3473a0e28657dd20f47c15b769 /test/src/gtest_master.cpp
parentccf02881faee0879ad36ee09ee5e32de8758a731 (diff)
TSG-13421: 不再处理UNCATEGORIZED=8000的识别结果,保证Application Full Path填充为空,增加gtest测试用例
Diffstat (limited to 'test/src/gtest_master.cpp')
-rw-r--r--test/src/gtest_master.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/src/gtest_master.cpp b/test/src/gtest_master.cpp
index 7b5026b..b281b0c 100644
--- a/test/src/gtest_master.cpp
+++ b/test/src/gtest_master.cpp
@@ -7,6 +7,48 @@
#include "tsg_entry.h"
#include <gtest/gtest.h>
+TEST(TSGMaster, SetAPPIDHttp)
+{
+ struct streaminfo a_stream={0};
+ struct gather_app_result gather_result[ORIGIN_MAX]={0};
+
+ gather_result[ORIGIN_BASIC_PROTOCOL].app_num=1;
+ gather_result[ORIGIN_BASIC_PROTOCOL].origin=ORIGIN_BASIC_PROTOCOL;
+ gather_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id=67; //HTTP
+
+ project_req_add_struct(&a_stream, g_tsg_para.gather_app_project_id, (const void *)gather_result);
+ struct gather_app_result *get_result=(struct gather_app_result *)project_req_get_struct(&a_stream, g_tsg_para.gather_app_project_id);
+ EXPECT_NE(nullptr, get_result);
+ EXPECT_EQ(1, get_result[ORIGIN_BASIC_PROTOCOL].app_num);
+ EXPECT_EQ(67, get_result[ORIGIN_BASIC_PROTOCOL].attributes[0].app_id);
+ EXPECT_EQ(0, get_result[ORIGIN_BASIC_PROTOCOL].attributes[0].packet_sequence);
+ EXPECT_EQ(0, get_result[ORIGIN_BASIC_PROTOCOL].attributes[0].surrogate_id);
+ EXPECT_EQ(ORIGIN_BASIC_PROTOCOL, get_result[ORIGIN_BASIC_PROTOCOL].origin);
+
+ 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\"}", app_ids);
+
+
+ project_req_add_struct(&a_stream, g_tsg_para.gather_app_project_id, NULL);
+ get_result=(struct gather_app_result *)project_req_get_struct(&a_stream, g_tsg_para.gather_app_project_id);
+ EXPECT_EQ(nullptr, get_result);
+}
+
+TEST(TSGMaster, SetAPPIDUnknown)
+{
+ struct streaminfo a_stream={0};
+
+ 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\":\"unknown\",\"common_app_label\":\"unknown\"}", app_ids);
+}
+
+
TEST(TSGMaster, ShapingSetRuleIds)
{
const struct streaminfo a_stream={0};