diff options
| author | liuxueli <[email protected]> | 2023-06-14 20:59:23 +0800 |
|---|---|---|
| committer | liuxueli <[email protected]> | 2023-06-14 20:59:23 +0800 |
| commit | 1e121ac169703766936c3c147361256009b0e1e7 (patch) | |
| tree | 0e254001f25ce815ef62336049252824865a3c70 /test/src/gtest_master.cpp | |
| parent | 1680dcede1b89aaac81faf52a7b85cdfe614f80d (diff) | |
修复笔误导致生成app_full_path错误v6.0.24
Diffstat (limited to 'test/src/gtest_master.cpp')
| -rw-r--r-- | test/src/gtest_master.cpp | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/test/src/gtest_master.cpp b/test/src/gtest_master.cpp index 4a59f8f..157e251 100644 --- a/test/src/gtest_master.cpp +++ b/test/src/gtest_master.cpp @@ -1008,6 +1008,102 @@ TEST(TSGMaster, SessionApplicationMetrics) } +extern int session_application_full_path_combine(struct gather_app_result * gather_result, char * out_full_path, int out_full_path_len); + +TEST(TSGMaster, SessionApplicationFullPath) +{ + char out_full_path[256]={0}; + int out_full_path_len=sizeof(out_full_path); + struct gather_app_result gather_result={0}; + + gather_result.l7_protocol_num=1; + struct app_attributes l7_protocol={68, 0, 4}; + gather_result.l7_protocol=&l7_protocol; + + gather_result.qm_engine_num=3; + gather_result.l7_qm_engine_num=2; + struct app_attributes qm_engine[3]={{199, 0, 6}, {68, 0, 4}, {240, 0, 6}}; + gather_result.qm_engine=qm_engine; + + int offset=session_application_full_path_combine(&gather_result, out_full_path, out_full_path_len); + EXPECT_NE(0, offset); + EXPECT_STREQ("ssl.https.youtube", out_full_path); + + // l7 protocol is empty + gather_result.l7_protocol_num=0; + gather_result.l7_protocol=NULL; + + gather_result.qm_engine_num=3; + gather_result.l7_qm_engine_num=0; + struct app_attributes qm_engine2[3]={{199, 0, 6}, {68, 0, 4}, {240, 0, 6}}; + gather_result.qm_engine=qm_engine2; + + offset=session_application_full_path_combine(&gather_result, out_full_path, out_full_path_len); + EXPECT_NE(0, offset); + EXPECT_STREQ("ssl.https.youtube", out_full_path); + + // matched application + gather_result.l7_protocol_num=1; + struct app_attributes l7_protocol_3={68, 0, 4}; + gather_result.l7_protocol=&l7_protocol_3; + + gather_result.qm_engine_num=3; + gather_result.l7_qm_engine_num=2; + struct app_attributes qm_engine3[3]={{199, 0, 6}, {68, 0, 4}, {240, 0, 6}}; + gather_result.qm_engine=qm_engine3; + + gather_result.matched_app_flag=1; + gather_result.matched_app={240, 0, 6}; + + struct app_attributes user_define_3={15009, 0, 4}; + gather_result.user_define_num=1; + gather_result.user_define=&user_define_3; + + offset=session_application_full_path_combine(&gather_result, out_full_path, out_full_path_len); + EXPECT_NE(0, offset); + EXPECT_STREQ("ssl.https.youtube", out_full_path); + + //userdefine application + gather_result.l7_protocol_num=1; + struct app_attributes l7_protocol_4={68, 0, 4}; + gather_result.l7_protocol=&l7_protocol_4; + + gather_result.qm_engine_num=3; + gather_result.l7_qm_engine_num=2; + struct app_attributes qm_engine4[3]={{199, 0, 6}, {68, 0, 4}, {240, 0, 6}}; + gather_result.qm_engine=qm_engine4; + + gather_result.matched_app_flag=0; + + struct app_attributes user_define_4={15009, 0, 4}; + gather_result.user_define_num=1; + gather_result.user_define=&user_define_4; + + offset=session_application_full_path_combine(&gather_result, out_full_path, out_full_path_len); + EXPECT_NE(0, offset); + EXPECT_STREQ("ssl.https.user_define_youtube", out_full_path); + + // built in application + gather_result.l7_protocol_num=1; + struct app_attributes l7_protocol_5={68, 0, 4}; + gather_result.l7_protocol=&l7_protocol_5; + + gather_result.qm_engine_num=3; + gather_result.l7_qm_engine_num=2; + struct app_attributes qm_engine5[3]={{199, 0, 6}, {68, 0, 4}, {240, 0, 6}}; + gather_result.qm_engine=qm_engine5; + + gather_result.matched_app_flag=0; + + struct app_attributes user_define_5={1500, 0, 4}; + gather_result.user_define_num=1; + gather_result.user_define=&user_define_5; + + offset=session_application_full_path_combine(&gather_result, out_full_path, out_full_path_len); + EXPECT_NE(0, offset); + EXPECT_STREQ("ssl.https.built_in_youtube", out_full_path); +} + int main(int argc, char *argv[]) { TSG_MASTER_INIT(); |
