From 2a56c9e27c508bcefa9fdde3b44dc125ce2cdce4 Mon Sep 17 00:00:00 2001 From: youyouyuai Date: Wed, 14 Jul 2021 06:30:02 +0000 Subject: [PATCH] codeing style Signed-off-by: youyouyuai --- .../flowcontroltest/flowcontroltest.cpp | 66 ++++++------------- .../libhilogTooltest/libhilogTooltest.cpp | 34 ++++------ 2 files changed, 33 insertions(+), 67 deletions(-) diff --git a/hiviewdfx/hilogtest/libhilogtest/flowcontroltest/flowcontroltest.cpp b/hiviewdfx/hilogtest/libhilogtest/flowcontroltest/flowcontroltest.cpp index cf78f8309..78078cf1c 100755 --- a/hiviewdfx/hilogtest/libhilogtest/flowcontroltest/flowcontroltest.cpp +++ b/hiviewdfx/hilogtest/libhilogtest/flowcontroltest/flowcontroltest.cpp @@ -29,24 +29,23 @@ namespace { } static const long long NSEC_PER_SEC = 1000000000ULL; -class TestTool : public testing::Test { +class Flowcontroltest : public testing::Test { public: static void SetUpTestCase(); static void TearDownTestCase(); void SetUp(); void TearDown(); - char buff[RESULT_MAX_LEN]; std::string input, result, expect; }; -void TestTool::SetUp() +void Flowcontroltest::SetUp() { } -void TestTool::TearDown() +void Flowcontroltest::TearDown() { } -void TestTool::SetUpTestCase() +void Flowcontroltest::SetUpTestCase() { ExeCmd("hilog -p on"); ExeCmd("hilog -Q domainoff"); @@ -59,7 +58,7 @@ void TestTool::SetUpTestCase() ExeCmd("hilog -S -t all"); ExeCmd("hilog -S -D 218116608"); } -void TestTool::TearDownTestCase() +void Flowcontroltest::TearDownTestCase() { ExeCmd("hilog -p on"); ExeCmd("hilog -Q domainoff"); @@ -76,7 +75,6 @@ void TestTool::TearDownTestCase() static long long HiLogTimespecSub(struct timespec a, struct timespec b) { long long ret = NSEC_PER_SEC * b.tv_sec + b.tv_nsec; - ret -= NSEC_PER_SEC * a.tv_sec + a.tv_nsec; return ret; } @@ -87,7 +85,7 @@ static long long HiLogTimespecSub(struct timespec a, struct timespec b) * Flow control values can be independently set for trustlisted processes. * @tc.number DFX_DFT_HilogCPP_70 */ -HWTEST_F(TestTool, process_flowctrl_trustlist, TestSize.Level3) +HWTEST_F(Flowcontroltest, process_flowctrl_trustlist, TestSize.Level3) { #ifndef LOCALTEST int i = 0; @@ -136,7 +134,7 @@ HWTEST_F(TestTool, process_flowctrl_trustlist, TestSize.Level3) * Flow control values can be independently set for trustlisted processes. * @tc.number DFX_DFT_HilogCPP_71 */ -HWTEST_F(TestTool, process_flowctrl_trustlist2, TestSize.Level3) +HWTEST_F(Flowcontroltest, process_flowctrl_trustlist2, TestSize.Level3) { #ifndef LOCALTEST int i = 0; @@ -173,11 +171,8 @@ HWTEST_F(TestTool, process_flowctrl_trustlist2, TestSize.Level3) ExeCmd("hilog -r -t all"); ExeCmd("hilog -G 1m -t all"); } - - #else - -HWTEST_F(TestTool, process_flowctrl_open, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, process_flowctrl_open, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -221,8 +216,7 @@ HWTEST_F(TestTool, process_flowctrl_open, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - -HWTEST_F(TestTool, process_flowctrl_close, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, process_flowctrl_close, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -246,9 +240,7 @@ HWTEST_F(TestTool, process_flowctrl_close, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - - -HWTEST_F(TestTool, domain_flowctrl_open, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, domain_flowctrl_open, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -292,9 +284,7 @@ HWTEST_F(TestTool, domain_flowctrl_open, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - - -HWTEST_F(TestTool, domain_flowctrl_close, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, domain_flowctrl_close, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -318,9 +308,7 @@ HWTEST_F(TestTool, domain_flowctrl_close, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - - -HWTEST_F(TestTool, flowctrl_switch_illegal, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, flowctrl_switch_illegal, Function|MediumTest|Level4) { #ifndef LOCALTEST result = ExecuteCmd("hilog -Q abc"); @@ -334,10 +322,7 @@ HWTEST_F(TestTool, flowctrl_switch_illegal, Function|MediumTest|Level4) #endif } - - - -HWTEST_F(TestTool, process_flowctrl, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, process_flowctrl, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -367,18 +352,15 @@ HWTEST_F(TestTool, process_flowctrl, Function|MediumTest|Level4) result = ExecuteCmd("hilog -x -t core | wc -l"); expect = to_string(i); EXPECT_GE(stoi(result), stoi(expect)); // result include drop log ,may more than expect - #endif // test end close switch ExeCmd("hilog -Q domainoff"); ExeCmd("hilog -Q pidoff"); ExeCmd("hilog -r -t all"); ExeCmd("hilog -G 1m -t all"); - } - -HWTEST_F(TestTool, process_flowctrl2, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, process_flowctrl2, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -423,8 +405,7 @@ HWTEST_F(TestTool, process_flowctrl2, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - -HWTEST_F(TestTool, domain_flowctrl, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, domain_flowctrl, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -462,9 +443,7 @@ HWTEST_F(TestTool, domain_flowctrl, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - - -HWTEST_F(TestTool, domain_flowctrl2, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, domain_flowctrl2, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -509,12 +488,10 @@ HWTEST_F(TestTool, domain_flowctrl2, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - - -HWTEST_F(TestTool, domain_flowctrl_quit_info, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, domain_flowctrl_quit_info, Function|MediumTest|Level4) { #ifndef LOCALTEST - bool ret; + bool ret = true; int i = 0; struct timespec startTime = {0, 0}; struct timespec realTime = {0, 0}; @@ -560,8 +537,7 @@ HWTEST_F(TestTool, domain_flowctrl_quit_info, Function|MediumTest|Level4) } - -HWTEST_F(TestTool, flowctrl_logtype, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, flowctrl_logtype, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; @@ -605,9 +581,7 @@ HWTEST_F(TestTool, flowctrl_logtype, Function|MediumTest|Level4) ExeCmd("hilog -G 1m -t all"); } - - -HWTEST_F(TestTool, flowctrl_logtype2, Function|MediumTest|Level4) +HWTEST_F(Flowcontroltest, flowctrl_logtype2, Function|MediumTest|Level4) { #ifndef LOCALTEST int i = 0; diff --git a/hiviewdfx/hilogtest/libhilogtest/libhilogTooltest/libhilogTooltest.cpp b/hiviewdfx/hilogtest/libhilogtest/libhilogTooltest/libhilogTooltest.cpp index e55a70b53..42a72edc6 100755 --- a/hiviewdfx/hilogtest/libhilogtest/libhilogTooltest/libhilogTooltest.cpp +++ b/hiviewdfx/hilogtest/libhilogtest/libhilogTooltest/libhilogTooltest.cpp @@ -39,8 +39,6 @@ using namespace OHOS; using namespace HiviewDFX; using namespace testing::ext; using namespace std; -const int g_logPerThread = 1000; - class LibhilogTooltest : public testing::Test { public: @@ -49,10 +47,6 @@ public: static void TearDownTestCase(); void SetUp(); void TearDown(); - string gHilogtoolExecutable = "hilog "; - string g_logContent = "123456789_1234567890_public and private log test is:\ - %{public}d, %{private}lf, %{public}.2f, %s, %{private}c"; - string g_commonContent = "03200/HILOGTOOLTEST: 123456789_1234567890_public and private log test is:"; private: }; @@ -824,7 +818,7 @@ HWTEST_F(LibhilogTooltest, log_clear_illegal2, Function|MediumTest|Level4) */ HWTEST_F(LibhilogTooltest, log_leval_global_set, Function|MediumTest|Level2) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b fatal"); ExeCmd("hilog -r -t all"); @@ -853,7 +847,7 @@ HWTEST_F(LibhilogTooltest, log_leval_global_set, Function|MediumTest|Level2) */ HWTEST_F(LibhilogTooltest, log_level_global_set2, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; #ifndef LOCALTEST ExeCmd("hilog -b fatal"); @@ -883,7 +877,7 @@ HWTEST_F(LibhilogTooltest, log_level_global_set2, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_leveal_global_set3, Function|MediumTest|Level2) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b debug"); ExeCmd("hilog -r -t all"); @@ -911,7 +905,7 @@ HWTEST_F(LibhilogTooltest, log_leveal_global_set3, Function|MediumTest|Level2) */ HWTEST_F(LibhilogTooltest, log_leval_tag_set, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b fatal -T HILOGTOOLTEST"); ExeCmd("hilog -r -t all"); @@ -940,7 +934,7 @@ HWTEST_F(LibhilogTooltest, log_leval_tag_set, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_leval_tag_set2, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; #ifndef LOCALTEST ExeCmd("hilog -b fatal -T HILOGTOOLTEST"); @@ -971,7 +965,7 @@ HWTEST_F(LibhilogTooltest, log_leval_tag_set2, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_level_tag_set3, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b debug -T HILOGTOOLTEST"); ExeCmd("hilog -r -t all"); @@ -999,7 +993,7 @@ HWTEST_F(LibhilogTooltest, log_level_tag_set3, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_level_domain_set, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b fatal -D 218116608"); ExeCmd("hilog -r -t all"); @@ -1028,7 +1022,7 @@ HWTEST_F(LibhilogTooltest, log_level_domain_set, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_level_domain_set2, Function|MediumTest|Level4) { - bool ret; + bool ret = true; int i = 1; #ifndef LOCALTEST ExeCmd("hilog -b fatal -D 218116608"); @@ -1059,7 +1053,7 @@ HWTEST_F(LibhilogTooltest, log_level_domain_set2, Function|MediumTest|Level4) */ HWTEST_F(LibhilogTooltest, log_level_domain_set3, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b debug -D 218116608"); ExeCmd("hilog -r -t all"); @@ -1088,7 +1082,7 @@ HWTEST_F(LibhilogTooltest, log_level_domain_set3, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_level_all_set, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -b info"); ExeCmd("hilog -b warn -D 218116608"); @@ -1119,7 +1113,7 @@ HWTEST_F(LibhilogTooltest, log_level_all_set, Function|MediumTest|Level3) */ HWTEST_F(LibhilogTooltest, log_level_all_set2, Function|MediumTest|Level3) { - bool ret; + bool ret = true; int i = 1; #ifndef LOCALTEST ExeCmd("hilog -b info"); @@ -1162,7 +1156,7 @@ HWTEST_F(LibhilogTooltest, log_level_set_illegal, Function|MediumTest|Level4) HWTEST_F(LibhilogTooltest, private_open, Function|MediumTest|Level4) { - bool ret; + bool ret = true; int i = 1; #ifndef LOCALTEST ExeCmd("hilog -p on"); @@ -1186,7 +1180,7 @@ HWTEST_F(LibhilogTooltest, private_open, Function|MediumTest|Level4) HWTEST_F(LibhilogTooltest, private_close, Function|MediumTest|Level4) { - bool ret; + bool ret = true; int i = 1; ExeCmd("hilog -p off"); ExeCmd("hilog -r -t all"); @@ -1212,5 +1206,3 @@ HWTEST_F(LibhilogTooltest, private_switch_illegal, Function|MediumTest|Level4) expect = "set private switch operation error!\n"; EXPECT_EQ(result, expect); } - - -- GitLab