From 711607133fe0a8616b0ca263330ba050b3b54954 Mon Sep 17 00:00:00 2001 From: zhuqingxi Date: Tue, 28 Sep 2021 15:53:20 +0800 Subject: [PATCH] update hisysevent testcase Signed-off-by: zhuqingxi --- .../hisyseventcpptest/HiSysEventCPPTest.cpp | 98 +++++++++++-------- 1 file changed, 58 insertions(+), 40 deletions(-) diff --git a/hiviewdfx/hisyseventtest/hisyseventcpptest/HiSysEventCPPTest.cpp b/hiviewdfx/hisyseventtest/hisyseventcpptest/HiSysEventCPPTest.cpp index 7978a88b0..3d2ea2c3f 100755 --- a/hiviewdfx/hisyseventtest/hisyseventcpptest/HiSysEventCPPTest.cpp +++ b/hiviewdfx/hisyseventtest/hisyseventcpptest/HiSysEventCPPTest.cpp @@ -33,6 +33,7 @@ public: static void TearDownTestCase(); void SetUp(); void TearDown(); + void RedHiSysEventLog(std::string &hilogredirect, std::string &timeout); private: }; void HiSysEventCPPTest::SetUp() @@ -62,6 +63,23 @@ void HiSysEventCPPTest::TearDownTestCase() { std::cout << "TearDownTestCase" << std::endl; } +void HiSysEventCPPTest::RedHiSysEventLog(std::string &hilogredirect, std::string &timeout) +{ + unsigned long i; + std::vector cmdret; + unsigned long cmdretlen; + std::string cmd = "rm " + hilogredirect; + cmdretlen = ExecCmdWithRet(cmd, cmdret); + for (i = 0; i < cmdretlen; i++) { + std::cout<" + hilogredirect; + std::cout< para = {"AAFWK", "eventNameDemo", "\"event_type_\":1", "\"key\":0"}; + std::vector para = {"AAFWK", "eventNameDemo", "\"type_\":1", "\"key\":0"}; if (!fileinfo.empty()) { result = CheckInfo(para, fileinfo); } else { @@ -102,10 +120,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0200, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::APPEXECFWK; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"APPEXECFWK", "eventNameDemo", "\"event_type_\":1", "\"key\":1"}; + std::vector para = {"APPEXECFWK", "eventNameDemo", "\"type_\":1", "\"key\":1"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -129,10 +147,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0300, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::ACCOUNT; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"ACCOUNT", "eventNameDemo", "\"event_type_\":1", "\"key\":[0]"}; + std::vector para = {"ACCOUNT", "eventNameDemo", "\"type_\":1", "\"key\":[0]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -154,10 +172,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0400, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::OTHERS; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"OTHERS", "eventNameDemo", "\"event_type_\":1", "\"key\":97"}; + std::vector para = {"OTHERS", "eventNameDemo", "\"type_\":1", "\"key\":97"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -181,10 +199,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0500, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::WEARABLE; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"WEARABLE", "eventNameDemo", "\"event_type_\":1", "\"key\":[97]"}; + std::vector para = {"WEARABLE", "eventNameDemo", "\"type_\":1", "\"key\":[97]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -206,10 +224,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0600, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::WEARABLE_HARDWARE; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"WEARABLEHW", "eventNameDemo", "\"event_type_\":1", "\"key\":30949.4"}; + std::vector para = {"WEARABLEHW", "eventNameDemo", "\"type_\":1", "\"key\":30949.4"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -233,10 +251,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0700, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::USB; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"USB", "eventNameDemo", "\"event_type_\":1", "\"key\":[30949.4]"}; + std::vector para = {"USB", "eventNameDemo", "\"type_\":1", "\"key\":[30949.4]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -258,10 +276,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0800, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::UPDATE; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"UPDATE", "eventNameDemo", "\"event_type_\":1", "\"key\":230.47"}; + std::vector para = {"UPDATE", "eventNameDemo", "\"type_\":1", "\"key\":230.47"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -285,10 +303,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_0900, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::TELEPHONY; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"TELEPHONY", "eventNameDemo", "\"event_type_\":1", "\"key\":[230.47]"}; + std::vector para = {"TELEPHONY", "eventNameDemo", "\"type_\":1", "\"key\":[230.47]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -310,10 +328,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1000, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::STARTUP; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"STARTUP", "eventNameDemo", "\"event_type_\":1", "\"key\":100"}; + std::vector para = {"STARTUP", "eventNameDemo", "\"type_\":1", "\"key\":100"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -337,10 +355,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1100, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SOURCE_CODE_TRANSFORMER; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"SRCTRANSFORMER", "eventNameDemo", "\"event_type_\":1", "\"key\":[100]"}; + std::vector para = {"SRCTRANSFORMER", "eventNameDemo", "\"type_\":1", "\"key\":[100]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -362,10 +380,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1200, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SENSORS; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"SENSORS", "eventNameDemo", "\"event_type_\":1", "\"key\":1000000"}; + std::vector para = {"SENSORS", "eventNameDemo", "\"type_\":1", "\"key\":1000000"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -389,10 +407,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1300, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::SECURITY; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"SECURITY", "eventNameDemo", "\"event_type_\":1", "\"key\":[1000000]"}; + std::vector para = {"SECURITY", "eventNameDemo", "\"type_\":1", "\"key\":[1000000]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -414,10 +432,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1400, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::ROUTER; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::FAULT; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"ROUTER", "eventNameDemo", "\"event_type_\":1", "\"key\":10"}; + std::vector para = {"ROUTER", "eventNameDemo", "\"type_\":1", "\"key\":10"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -441,10 +459,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1500, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::POWERMGR; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"POWERMGR", "eventNameDemo", "\"event_type_\":2", "\"key\":[10]"}; + std::vector para = {"POWERMGR", "eventNameDemo", "\"type_\":2", "\"key\":[10]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -466,10 +484,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1600, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::NOTIFICATION; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::STATISTIC; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"NOTIFICATION", "eventNameDemo", "\"event_type_\":2", "\"key\":\"abc\""}; + std::vector para = {"NOTIFICATION", "eventNameDemo", "\"type_\":2", "\"key\":\"abc\""}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -493,10 +511,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1700, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MODAL_INPUT; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"MULTIMODALINPUT", "eventNameDemo", "\"event_type_\":3", "\"key\":[\"abc\"]"}; + std::vector para = {"MULTIMODALINPUT", "eventNameDemo", "\"type_\":3", "\"key\":[\"abc\"]"}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -528,10 +546,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_1800, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::MULTI_MEDIA; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::SECURITY; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, test); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"MULTIMEDIA", "eventNameDemo", "\"event_type_\":3", str}; + std::vector para = {"MULTIMEDIA", "eventNameDemo", "\"type_\":3", str}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -564,10 +582,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_2000, Function|M g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"MSDP", "eventNameDemo", "\"event_type_\":4", str}; + std::vector para = {"MSDP", "eventNameDemo", "\"type_\":4", str}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { @@ -592,10 +610,10 @@ HWTEST_F(HiSysEventCPPTest, DFX_DFT_HiviewKit_HiSysEvent_Native_2200, Function|M string domain = OHOS::HiviewDFX::HiSysEvent::Domain::LOCATION; OHOS::HiviewDFX::HiSysEvent::EventType eventtype = OHOS::HiviewDFX::HiSysEvent::EventType::BEHAVIOR; OHOS::HiviewDFX::HiSysEvent::Write(domain, "eventNameDemo", eventtype, g_key, param); - RedirecthiLog(g_hiLogRedirect, g_reDiRectTimeout); + RedHiSysEventLog(g_hiLogRedirect, g_reDiRectTimeout); string fileinfo = ""; fileinfo = ReadFile(g_hiLogRedirect); - std::vector para = {"LOCATION", "eventNameDemo", "\"event_type_\":4", g_key, param}; + std::vector para = {"LOCATION", "eventNameDemo", "\"type_\":4", g_key, param}; if (fileinfo != "") { result = CheckInfo(para, fileinfo); } else { -- GitLab