CodeClear

Signed-off-by: wenlong_12 <wenlong12@huawei.com>
This commit is contained in:
wenlong_12 2024-01-16 16:31:30 +08:00
parent 8678dbc572
commit 990afcb3db
8 changed files with 27 additions and 28 deletions

View File

@ -88,8 +88,6 @@ HWTEST_F(HiviewSATest, CommonTest002, testing::ext::TestSize.Level3)
printf("hidumper -s 1201 fail!\r\n");
FAIL();
}
}
}
}

View File

@ -184,5 +184,5 @@ bool DomainRule::FindEvent(const std::string &eventName) const
return eventlist.find(eventName) == eventlist.end();
}
}
}// namespace HiviewDFX
}// namespace OHOS
} // namespace HiviewDFX
} // namespace OHOS

View File

@ -384,11 +384,11 @@ HWTEST_F(EventRawEncodedTest, RawDataBuilderJsonParserTest002, testing::ext::Tes
*/
HWTEST_F(EventRawEncodedTest, RawDataBuilderJsonParserTest003, testing::ext::TestSize.Level1)
{
std::string rawSysEventStr = R"~({"domain_":"KERNEL_VENDOR","name_":"POWER_KEY",
"type_":1,"time_":1502603794820,"tz_":"+0800","pid_":1751,"tid_":1751,"uid_":0,
"id_":"17835276947892625495","trace_flag_":3,"traceid_":"a92ab1ea12c7144",
"spanid_":"0","pspanid_":"0","key1":"-300","key2":[-300, 300],
"key3":3.4,"key4":"[3.4,-3.4]","info_":"","level_":"CRITICAL","seq_":972})~";
std::string rawSysEventStr = R"~({"domain_":"KERNEL_VENDOR", "name_":"POWER_KEY",
"type_":1, "time_":1502603794820, "tz_":"+0800", "pid_":1751, "tid_":1751, "uid_":0,
"id_":"17835276947892625495", "trace_flag_":3, "traceid_":"a92ab1ea12c7144",
"spanid_":"0", "pspanid_":"0", "key1":"-300", "key2":[-300, 300],
"key3":3.4, "key4":"[3.4,-3.4]", "info_":"", "level_":"CRITICAL", "seq_":972})~";
auto parser = std::make_shared<RawDataBuilderJsonParser>(rawSysEventStr);
ASSERT_TRUE(parser != nullptr);
auto eventBuilder = parser->Parse();

View File

@ -239,9 +239,9 @@ HWTEST_F(SysEventTest, TestSysEventValueParse003, testing::ext::TestSize.Level3)
/**
* @tc.steps: step1. create base sys event
*/
std::string jsonStr = R"~({"domain_":"DEMO","name_":"VALUE_PARSE001","type_":1,"tz_":"+0800","time_":1620271291188,
"pid_":6527,"tid_":6527,"traceid_":"f0ed5160bb2df4b","spanid_":"10","pspanid_":"20","trace_flag_":4,
"FLOAT_VAL1":-1.0,"FLOAT_VAL2":1.0})~";
std::string jsonStr = R"~({"domain_":"DEMO", "name_":"VALUE_PARSE001", "type_":1, "tz_":"+0800",
"time_":1620271291188, "pid_":6527, "tid_":6527, "traceid_":"f0ed5160bb2df4b", "spanid_":"10",
"pspanid_":"20", "trace_flag_":4, "FLOAT_VAL1":-1.0, "FLOAT_VAL2":1.0})~";
auto sysEvent = std::make_shared<SysEvent>("SysEventSource", nullptr, jsonStr);
ASSERT_TRUE(sysEvent != nullptr);
@ -262,9 +262,9 @@ HWTEST_F(SysEventTest, TestSysEventValueParse004, testing::ext::TestSize.Level3)
/**
* @tc.steps: step1. create base sys event
*/
std::string jsonStr = R"~({"domain_":"DEMO","name_":"VALUE_PARSE001","type_":1,"tz_":"+0800","time_":1620271291188,
"pid_":6527,"tid_":-6527,"traceid_":"f0ed5160bb2df4b","spanid_":"10","pspanid_":"20","trace_flag_":4,
"FLOAT_VAL1":-1.0,"FLOAT_VAL2":1.0,)~";
std::string jsonStr = R"~({"domain_":"DEMO", "name_":"VALUE_PARSE001", "type_":1, "tz_":"+0800",
"time_":1620271291188, "pid_":6527, "tid_":-6527, "traceid_":"f0ed5160bb2df4b", "spanid_":"10",
"pspanid_":"20", "trace_flag_":4, "FLOAT_VAL1":-1.0, "FLOAT_VAL2":1.0,)~";
jsonStr.append(R"~("FLOAT_VAL3":)~");
jsonStr.append(std::to_string((static_cast<double>(std::numeric_limits<int64_t>::min()) * SCALE_FACTOR)));
jsonStr.append(R"~("FLOAT_VAL4":)~");
@ -308,9 +308,9 @@ HWTEST_F(SysEventTest, TestSysEventValueParse005, testing::ext::TestSize.Level3)
/**
* @tc.steps: step1. create base sys event
*/
std::string jsonStr = R"~({"domain_":"DEMO","name_":"VALUE_PARSE001","type_":1,"tz_":"+0800","time_":1620271291188,
"pid_":6527,"tid_":6527,"traceid_":"f0ed5160bb2df4b","spanid_":"10","pspanid_":"20","trace_flag_":4,
"FLOAT_VAL1":-1.0,"FLOAT_VAL2":1.0,)~";
std::string jsonStr = R"~({"domain_":"DEMO", "name_":"VALUE_PARSE001", "type_":1, "tz_":"+0800",
"time_":1620271291188, "pid_":6527, "tid_":6527, "traceid_":"f0ed5160bb2df4b", "spanid_":"10",
"pspanid_":"20", "trace_flag_":4, "FLOAT_VAL1":-1.0, "FLOAT_VAL2":1.0,)~";
jsonStr.append(R"~("FLOAT_VAL3":)~");
jsonStr.append(std::to_string((static_cast<double>(std::numeric_limits<uint64_t>::min()) * SCALE_FACTOR)));
jsonStr.append(R"~("FLOAT_VAL4":)~");
@ -354,9 +354,9 @@ HWTEST_F(SysEventTest, TestSysEventValueParse006, testing::ext::TestSize.Level3)
/**
* @tc.steps: step1. create base sys event
*/
std::string jsonStr = R"~({"domain_":"DEMO","name_":"VALUE_PARSE001","type_":1,"tz_":"+0800","time_":1620271291188,
"pid_":6527,"tid_":6527,"traceid_":"f0ed5160bb2df4b","spanid_":"10","pspanid_":"20","trace_flag_":4,
"FLOAT_VAL1":-1.0,"FLOAT_VAL2":1.0})~";
std::string jsonStr = R"~({"domain_":"DEMO", "name_":"VALUE_PARSE001", "type_":1, "tz_":"+0800",
"time_":1620271291188, "pid_":6527, "tid_":6527, "traceid_":"f0ed5160bb2df4b", "spanid_":"10",
"pspanid_":"20", "trace_flag_":4, "FLOAT_VAL1":-1.0, "FLOAT_VAL2":1.0})~";
auto sysEvent = std::make_shared<SysEvent>("SysEventSource", nullptr, jsonStr);
ASSERT_TRUE(sysEvent != nullptr);
@ -389,9 +389,9 @@ HWTEST_F(SysEventTest, TestSysEventValueParse007, testing::ext::TestSize.Level3)
/**
* @tc.steps: step1. create base sys event
*/
std::string jsonStr = R"~({"domain_":"DEMO","name_":"VALUE_PARSE001","type_":1,"tz_":"+0800","time_":1620271291188,
"pid_":6527,"tid_":6527,"traceid_":"f0ed5160bb2df4b","spanid_":"10","pspanid_":"20","trace_flag_":4,
"FLOAT_VAL1":-1.0,"FLOAT_VAL2":1.0})~";
std::string jsonStr = R"~({"domain_":"DEMO", "name_":"VALUE_PARSE001", "type_":1, "tz_":"+0800",
"time_":1620271291188, "pid_":6527, "tid_":6527, "traceid_":"f0ed5160bb2df4b", "spanid_":"10",
"pspanid_":"20", "trace_flag_":4, "FLOAT_VAL1":-1.0, "FLOAT_VAL2":1.0})~";
auto sysEvent = std::make_shared<SysEvent>("SysEventSource", nullptr, jsonStr);
ASSERT_TRUE(sysEvent != nullptr);

View File

@ -106,7 +106,7 @@ bool IsTheProcessExist(pid_t pid)
{
int ret = syscall(SYS_tgkill, pid, pid, 0);
if (ret != 0 && errno == ESRCH) {
return false;
return false;
}
return true;
}

View File

@ -62,7 +62,7 @@ public:
/* 可以通过hidumper命令行查询当前插件的dump信息该接口就是实现能dump出来那些内容 */
virtual void Dump(int fd, const std::vector<std::string>& cmds);
/* 当前插件为一个事件动态订阅者,接收通过动态订阅来的外部驱动事件,并且处理事件 */
/* 当前插件为一个事件动态订阅者,接收通过动态订阅来的外部驱动事件,并且处理事件 */
virtual void OnEventListeningCallback(const Event &msg);
// 以下为接口

View File

@ -166,7 +166,7 @@ static void ShowUsage(int fd, const std::vector<std::string>& cmds)
void SysEventSource::Dump(int fd, const std::vector<std::string>& cmds)
{
if (cmds.size() >= 2) { // args from the second item
if (cmds.size() >= 2) { // 2args from the second item
std::string arg1 = cmds[1];
if (arg1 == "sum") {
sysEventStat_->StatSummary(fd);

View File

@ -128,7 +128,8 @@ bool LogUtil::IsTestModel(const string& sourceFile, const string& name,
HIVIEW_LOGI("test dir exist.");
std::string sourceFileName = StringUtil::GetRrightSubstr(sourceFile, "/");
std::string dirOrFileName = StringUtil::GetRrightSubstr(name, "/");
std::string fileName = pattern.find("/") != std::string::npos ? StringUtil::GetRrightSubstr(pattern, "/") : pattern;
std::string fileName = pattern.find("/") != std::string::npos ?
StringUtil::GetRrightSubstr(pattern, "/") : pattern;
smatch result;
if (regex_match(sourceFileName, result, regex(dirOrFileName)) ||
regex_match(sourceFileName, result, regex(fileName))) {