From 60b6f60c06e203d48d8f2c1e09cd2f29adcb6870 Mon Sep 17 00:00:00 2001 From: yudechen Date: Thu, 3 Mar 2022 17:49:19 +0800 Subject: [PATCH 01/11] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E7=BC=96=E8=AF=91?= =?UTF-8?q?=E5=8D=95=E5=85=83=E6=8C=87=E5=AE=9A=E9=83=A8=E4=BB=B6=E5=92=8C?= =?UTF-8?q?=E5=AD=90=E7=B3=BB=E7=BB=9F=E5=90=8D=E7=A7=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: yudechen Change-Id: I0088afb62e23336405d80c57e4933281d21021f7 --- aw/cxx/hwext/BUILD.gn | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/aw/cxx/hwext/BUILD.gn b/aw/cxx/hwext/BUILD.gn index 379f4ff..c8b709b 100755 --- a/aw/cxx/hwext/BUILD.gn +++ b/aw/cxx/hwext/BUILD.gn @@ -28,5 +28,7 @@ ohos_static_library("performance_test_static") { "//utils/native/base:utils", ] public_deps = [ "//third_party/libxml2:libxml2" ] - public_configs = [":performance_test_config"] + public_configs = [ ":performance_test_config" ] + subsystem_name = "developertest" + part_name = "developertest" } -- Gitee From 76f41cb9457cd8ae6d39d7dbb49ef0727a583f3c Mon Sep 17 00:00:00 2001 From: stivn Date: Tue, 15 Mar 2022 19:23:55 +0800 Subject: [PATCH 02/11] Modified the file Signed-off-by: stivn --- aw/cxx/distributed/distributed.h | 12 +++--- aw/cxx/distributed/distributed_agent.cpp | 10 ++--- aw/cxx/distributed/distributed_cfg.h | 2 +- aw/cxx/distributed/distributed_major.cpp | 12 +++--- aw/cxx/hwext/perf.h | 2 +- bundle.json | 37 +++++++++++++++++++ examples/calculator/include/calculator.h | 4 +- examples/calculator/src/calculator.cpp | 1 - .../common/parse_fuzzer/parse_fuzzer.cpp | 6 +-- .../common/parse_fuzzer/parse_fuzzer.h | 10 ++--- examples/detector/include/detector.h | 4 ++ examples/sleep/include/sleep_ex.h | 7 ++-- examples/sleep/src/sleep_ex.cpp | 8 ++-- ohos.build | 22 ----------- src/core/config/config_manager.py | 2 +- 15 files changed, 79 insertions(+), 60 deletions(-) create mode 100644 bundle.json delete mode 100644 ohos.build diff --git a/aw/cxx/distributed/distributed.h b/aw/cxx/distributed/distributed.h index 9e4d3b0..857e263 100644 --- a/aw/cxx/distributed/distributed.h +++ b/aw/cxx/distributed/distributed.h @@ -21,12 +21,12 @@ namespace OHOS { namespace DistributeSystemTest { -static const int MAX_BUFF_LEN = 1024; -static const int DST_COMMAND_NOTIFY = 0; -static const int DST_COMMAND_CALL = 1; -static const int DST_COMMAND_MSG = 2; -static const int DST_COMMAND_END = 3; -static const int DEFAULT_AGENT_PORT = 6789; +constexpr int MAX_BUFF_LEN = 1024; +constexpr int DST_COMMAND_NOTIFY = 0; +constexpr int DST_COMMAND_CALL = 1; +constexpr int DST_COMMAND_MSG = 2; +constexpr int DST_COMMAND_END = 3; +constexpr int DEFAULT_AGENT_PORT = 6789; struct DistributedCmd { int no; // record command no, as return no. diff --git a/aw/cxx/distributed/distributed_agent.cpp b/aw/cxx/distributed/distributed_agent.cpp index 400847e..fc1d7af 100644 --- a/aw/cxx/distributed/distributed_agent.cpp +++ b/aw/cxx/distributed/distributed_agent.cpp @@ -94,7 +94,7 @@ int DistributedAgent::InitAgentServer() } addr.sin_port = htons(agentPort_); - int err = ::bind(serverSockFd, (struct sockaddr *)&addr, sizeof(addr)); + int err = ::bind(serverSockFd, reinterpret_cast(&addr), sizeof(addr)); if (err < 0) { HiLog::Error(DistributedAgent::LABEL, "agent bind error.\n"); close(serverSockFd); @@ -132,7 +132,7 @@ int DistributedAgent::DoCmdServer(int serverSockFd) while (receiveLen > 0) { HiLog::Info(DistributedAgent::LABEL, "wait client .......\n"); - if ((clientSockFd = accept(serverSockFd, (struct sockaddr *)&clientAddr, &sinSize)) > 0) { + if ((clientSockFd = accept(serverSockFd, reinterpret_cast(&clientAddr), &sinSize)) > 0) { break; } receiveLen--; @@ -153,9 +153,9 @@ int DistributedAgent::DoCmdServer(int serverSockFd) return -1; } // every cmd length less than MAX_BUFF_LEN bytes; - int cmdLen = recv(clientSockFd_, buff, DST_COMMAND_HEAD_LEN, 0); - if (static_cast(cmdLen) < DST_COMMAND_HEAD_LEN) { - if (cmdLen == 0) { + int recvCmdLen = recv(clientSockFd_, buff, DST_COMMAND_HEAD_LEN, 0); + if (static_cast(recvCmdLen) < DST_COMMAND_HEAD_LEN) { + if (recvCmdLen == 0) { HiLog::Info(DistributedAgent::LABEL, "agent connect socket closed, IP:%s .\n", inet_ntoa(clientAddr.sin_addr)); mbStop_ = true; diff --git a/aw/cxx/distributed/distributed_cfg.h b/aw/cxx/distributed/distributed_cfg.h index 1c6a6ab..e8fb0a1 100644 --- a/aw/cxx/distributed/distributed_cfg.h +++ b/aw/cxx/distributed/distributed_cfg.h @@ -41,7 +41,7 @@ public: ~DistributedCfg(); bool OpenCfg(std::string fileName); bool GetCfgVal(std::string key, std::string &value); - std::string GetValueInString(std::string str, size_t devNO); + std::string GetValueInString(std::string str, size_t devNo); std::string GetDeviceIp(std::string fileName, size_t devNo); std::string GetDeviceUuid(std::string fileName, size_t devNo); static std::unique_ptr& GetInstance(); diff --git a/aw/cxx/distributed/distributed_major.cpp b/aw/cxx/distributed/distributed_major.cpp index 1638b82..771aec9 100644 --- a/aw/cxx/distributed/distributed_major.cpp +++ b/aw/cxx/distributed/distributed_major.cpp @@ -130,7 +130,7 @@ int DistributeTestEnvironment::ConnectAgent(size_t devNo) addr.sin_port = htons(serverPort_); int connectCount = 0; for (connectCount = 0; connectCount < CONNECT_TIME; connectCount++) { // try connect to agent 3 times. - if (connect(clientSockFd, (struct sockaddr *)&addr, sizeof(addr)) == 0) { + if (connect(clientSockFd, reinterpret(&addr), sizeof(addr)) == 0) { break; } std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME)); // delay 10ms @@ -184,11 +184,11 @@ bool DistributeTestEnvironment::SendToAgent(size_t devNo, int cmdType, void *pst } globalCommandNo++; char szrbuf[MAX_BUFF_LEN] = {0}; - auto pCmdTest = reinterpret_cast(pstrMsg); - pCmdTest->no = globalCommandNo; - pCmdTest->cmdTestType = htons(cmdType); - pCmdTest->len = htons(len); - int rlen = send(clientList_[devNo].fd, pCmdTest, static_cast(len + DST_COMMAND_HEAD_LEN), 0); + auto pCmdMsg = reinterpret_cast(pstrMsg); + pCmdMsg->no = globalCommandNo; + pCmdMsg->cmdTestType = htons(cmdType); + pCmdMsg->len = htons(len); + int rlen = send(clientList_[devNo].fd, pCmdMsg, static_cast(len + DST_COMMAND_HEAD_LEN), 0); if (rlen <= 0) { HiLog::Error(LABEL, "agent socket is closed."); return breturn; diff --git a/aw/cxx/hwext/perf.h b/aw/cxx/hwext/perf.h index 662dd91..9cc894c 100644 --- a/aw/cxx/hwext/perf.h +++ b/aw/cxx/hwext/perf.h @@ -19,7 +19,7 @@ #include #include #include -#include +#include #include "securec.h" #include diff --git a/bundle.json b/bundle.json new file mode 100644 index 0000000..678ab5f --- /dev/null +++ b/bundle.json @@ -0,0 +1,37 @@ +{ + "name": "@openharmony/developertest", + "version": "3.1.0", + "description": "developertest", + "license": "Apache License 2.0", + "publishAs": "code-segment", + "scripts": {}, + "repository": "", + "dirs": {}, + "component": { + "name": "developertest", + "subsystem": "developertest", + "features" :[], + "adapted_system_type": [ "standard" ], + "rom": "0KB", + "ram": "0KB", + "deps": {}, + "build": { + "sub_component": [ + "//test/developertest/examples/app_info:app_info", + "//test/developertest/examples/detector:detector", + "//test/developertest/examples/calculator:calculator", + "//test/developertest/examples/calculator:calculator_static" + ], + "inner_kits": [], + "test": [ + "//test/developertest/examples/app_info/test:unittest", + "//test/developertest/examples/calculator/test:unittest", + "//test/developertest/examples/calculator/test:fuzztest", + "//test/developertest/examples/calculator/test:benchmarktest", + "//test/developertest/examples/detector/test:unittest", + "//test/developertest/examples/sleep/test:performance", + "//test/developertest/examples/distributedb/test:distributedtest" + ] + } + } +} diff --git a/examples/calculator/include/calculator.h b/examples/calculator/include/calculator.h index 9b8168f..4f39f2f 100644 --- a/examples/calculator/include/calculator.h +++ b/examples/calculator/include/calculator.h @@ -12,10 +12,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#include +#ifndef _EXAMPLE_CALCULATOR_H_ +#define _EXAMPLE_CALCULATOR_H_ int Add(int e1, int e2); int Sub(int e1, int e2); int Mul(int e1, int e2); int Div(int e1, int e2); +#endif // _EXAMPLE_CALCULATOR_H_ \ No newline at end of file diff --git a/examples/calculator/src/calculator.cpp b/examples/calculator/src/calculator.cpp index e71a031..63cd5de 100644 --- a/examples/calculator/src/calculator.cpp +++ b/examples/calculator/src/calculator.cpp @@ -13,7 +13,6 @@ * limitations under the License. */ -#include int Add(int e1, int e2) { diff --git a/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp index 576457a..e09b54e 100644 --- a/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp +++ b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp @@ -13,10 +13,8 @@ * limitations under the License. */ -#include "parse_fuzzer.h" - -#include -#include +#include +#include const int FUZZ_DATA_LEN = 3; const int FUZZ_FST_DATA = 0; diff --git a/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.h b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.h index bf3acfc..9089dfa 100644 --- a/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.h +++ b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.h @@ -13,11 +13,9 @@ * limitations under the License. */ -#include -#include -#include -#include -#include -#include +#ifndef _EXAMPLE_CALCULATOR_PARSE_FUZZER_H_ +#define _EXAMPLE_CALCULATOR_PARSE_FUZZER_H_ #define FUZZ_PROJECT_NAME "parse_fuzzer" + +#endif // _EXAMPLE_CALCULATOR_PARSE_FUZZER_H_ \ No newline at end of file diff --git a/examples/detector/include/detector.h b/examples/detector/include/detector.h index 26d0a1b..a4c0327 100644 --- a/examples/detector/include/detector.h +++ b/examples/detector/include/detector.h @@ -13,7 +13,11 @@ * limitations under the License. */ +#ifndef _EXAMPLE_DETECTOR_H_ +#define _EXAMPLE_DETECTOR_H_ #include bool IsPrime(int n); bool FileExist(const char* fileName); + +#endif // _EXAMPLE_DETECTOR_H_ \ No newline at end of file diff --git a/examples/sleep/include/sleep_ex.h b/examples/sleep/include/sleep_ex.h index d6ca5b3..0b7939d 100644 --- a/examples/sleep/include/sleep_ex.h +++ b/examples/sleep/include/sleep_ex.h @@ -13,10 +13,11 @@ * limitations under the License. */ -#include -#include -#include +#ifndef EXAMPLE_SLEEP_H_ +#define EXAMPLE_SLEEP_H_ typedef void (*time_callback)(void *); int Msleep(unsigned long milisec); double ElapsedTime(time_callback func, void* arg); + +#endif // EXAMPLE_SLEEP_H_ \ No newline at end of file diff --git a/examples/sleep/src/sleep_ex.cpp b/examples/sleep/src/sleep_ex.cpp index 5c21328..46444f1 100644 --- a/examples/sleep/src/sleep_ex.cpp +++ b/examples/sleep/src/sleep_ex.cpp @@ -32,8 +32,10 @@ static double TimeDiff(struct timeval *x , struct timeval *y) return 0; } - double xUs = (double)x->tv_sec * SleepTest::ID_MS_TO_NS_LEVEL + (double)x->tv_usec; - double yUs = (double)y->tv_sec * SleepTest::ID_MS_TO_NS_LEVEL + (double)y->tv_usec; + double xUs = reinterpret_cast(x->tv_sec * SleepTest::ID_MS_TO_NS_LEVEL) + + reinterpret_cast(x->tv_usec); + double yUs = reinterpret_cast(y->tv_sec * SleepTest::ID_MS_TO_NS_LEVEL) + + reinterpret_cast(y->tv_usec); return (yUs - xUs); } @@ -52,7 +54,7 @@ int Msleep(unsigned long miliSec) { struct timespec req = {0, 0}; struct timespec rem = {0, 0}; - time_t sec = (int)(miliSec / SleepTest::ID_SE_TO_MS_LEVEL); + time_t sec = reinterpret_cast(miliSec / SleepTest::ID_SE_TO_MS_LEVEL); miliSec = miliSec - (sec * SleepTest::ID_SE_TO_MS_LEVEL); req.tv_sec = sec; req.tv_nsec = miliSec * SleepTest::ID_MS_TO_NS_LEVEL; diff --git a/ohos.build b/ohos.build deleted file mode 100644 index e2efca2..0000000 --- a/ohos.build +++ /dev/null @@ -1,22 +0,0 @@ -{ - "subsystem": "developertest", - "parts": { - "developertest": { - "module_list": [ - "//test/developertest/examples/app_info:app_info", - "//test/developertest/examples/detector:detector", - "//test/developertest/examples/calculator:calculator", - "//test/developertest/examples/calculator:calculator_static" - ], - "test_list": [ - "//test/developertest/examples/app_info/test:unittest", - "//test/developertest/examples/calculator/test:unittest", - "//test/developertest/examples/calculator/test:fuzztest", - "//test/developertest/examples/calculator/test:benchmarktest", - "//test/developertest/examples/detector/test:unittest", - "//test/developertest/examples/sleep/test:performance", - "//test/developertest/examples/distributedb/test:distributedtest" - ] - } - } -} diff --git a/src/core/config/config_manager.py b/src/core/config/config_manager.py index c8224e0..3b463f6 100755 --- a/src/core/config/config_manager.py +++ b/src/core/config/config_manager.py @@ -92,7 +92,7 @@ class FilterConfigManager(object): if child.tag != target_name: continue for child2 in child: - if child2.tag != product_form.lower(): + if child2.tag.lower() != product_form.lower(): continue for child3 in child2: if child3.text != "" and child3.text is not None: -- Gitee From 259e051710d96ca096aefb68e962ae95a97c0791 Mon Sep 17 00:00:00 2001 From: zhangchunbao Date: Wed, 23 Mar 2022 01:41:51 +0000 Subject: [PATCH 03/11] update aw/cxx/distributed/distributed_agent.cpp. Signed-off-by: zhangchunbao --- aw/cxx/distributed/distributed_agent.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/aw/cxx/distributed/distributed_agent.cpp b/aw/cxx/distributed/distributed_agent.cpp index fc1d7af..9440674 100644 --- a/aw/cxx/distributed/distributed_agent.cpp +++ b/aw/cxx/distributed/distributed_agent.cpp @@ -103,12 +103,12 @@ int DistributedAgent::InitAgentServer() } if (listen(serverSockFd, 1) < 0) { - HiLog::Error(DistributedAgent::LABEL, "%s agent listen error.\n", agentIpAddr_.c_str()); + HiLog::Error(DistributedAgent::LABEL, "agent listen error.\n"); close(serverSockFd); serverSockFd = -1; return serverSockFd; } - HiLog::Info(DistributedAgent::LABEL, "listen %s .......", agentIpAddr_.c_str()); + mpthCmdProcess_ = std::make_unique([=]() { DoCmdServer(serverSockFd); }); @@ -196,6 +196,8 @@ int DistributedAgent::DoCmdServer(int serverSockFd) int nresult = OnProcessCmd(pAlignmentCmd, cmdLen, pszEValue, eValueLen); ret = memset_s(returnValue, sizeof(returnValue), 0, MAX_BUFF_LEN); if (ret != EOK) { + delete []pAlignmentCmd; + delete []pszEValue; return -1; } auto pclinereturn = reinterpret_cast(returnValue); -- Gitee From 7056219291f2eb7b6f791f8772791998230fb0b3 Mon Sep 17 00:00:00 2001 From: stivn Date: Thu, 24 Mar 2022 17:50:26 +0800 Subject: [PATCH 04/11] Modified the file Signed-off-by: stivn --- libs/benchmark/template/benchmark_detail.html | 4 ++-- libs/benchmark/template/benchmark_summary.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libs/benchmark/template/benchmark_detail.html b/libs/benchmark/template/benchmark_detail.html index 4599395..1e39923 100644 --- a/libs/benchmark/template/benchmark_detail.html +++ b/libs/benchmark/template/benchmark_detail.html @@ -7,7 +7,7 @@ - + @@ -135,4 +135,4 @@ height: 600px; } - \ No newline at end of file + diff --git a/libs/benchmark/template/benchmark_summary.html b/libs/benchmark/template/benchmark_summary.html index 13d829f..2d5224e 100644 --- a/libs/benchmark/template/benchmark_summary.html +++ b/libs/benchmark/template/benchmark_summary.html @@ -115,7 +115,7 @@ - + -- Gitee From 063ce27ba3a743077706c161356c62da63acfac3 Mon Sep 17 00:00:00 2001 From: stivn Date: Tue, 29 Mar 2022 09:21:55 +0800 Subject: [PATCH 05/11] Modified Signed-off-by: stivn --- aw/cxx/distributed/distributed_agent.cpp | 6 +++--- aw/cxx/distributed/distributed_major.cpp | 4 ++-- aw/cxx/distributed/utils/csv_transform_xml.h | 4 ++-- aw/cxx/hwext/perf.cpp | 6 +++--- examples/calculator/src/calculator.cpp | 4 ++-- .../fuzztest/common/parse_fuzzer/corpus/init | 13 ++++++++++++- examples/detector/src/detector.cpp | 6 +++--- .../distributedtest/common/distribute_demo.cpp | 2 +- .../common/distribute_demo_agent.cpp | 6 +++--- examples/lite/c_demo/include/calc_multi.h | 2 +- examples/lite/c_demo/source/BUILD.gn | 2 +- libs/benchmark/README_zh.md | 11 ++++++----- libs/benchmark/template/benchmark_detail.html | 14 ++++++++++++++ libs/benchmark/template/benchmark_summary.html | 14 ++++++++++++++ libs/fuzzlib/README_zh.md | 4 ++-- libs/fuzzlib/fuzzer_helper.py | 4 ++-- libs/fuzzlib/tools/__init__.py | 16 ++++++++++++++++ src/core/build/build_manager.py | 2 +- src/core/build/build_testcases.py | 6 +++--- src/core/build/select_targets.py | 2 +- src/core/command/run.py | 2 +- src/core/config/resource_manager.py | 2 +- src/core/driver/drivers.py | 2 +- src/core/utils.py | 2 +- 24 files changed, 96 insertions(+), 40 deletions(-) diff --git a/aw/cxx/distributed/distributed_agent.cpp b/aw/cxx/distributed/distributed_agent.cpp index fc1d7af..9310b45 100644 --- a/aw/cxx/distributed/distributed_agent.cpp +++ b/aw/cxx/distributed/distributed_agent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -78,7 +78,7 @@ int DistributedAgent::InitAgentServer() } int num = 1; - if (setsockopt(serverSockFd, SOL_SOCKET, SO_REUSEADDR, &num, sizeof(num)) != 0) { + if (setsockopt(serverSockFd, SOL_SOCKET, SO_REUSEADDR, &num, sizeof(num))) { close(serverSockFd); serverSockFd = -1; return serverSockFd; @@ -155,7 +155,7 @@ int DistributedAgent::DoCmdServer(int serverSockFd) // every cmd length less than MAX_BUFF_LEN bytes; int recvCmdLen = recv(clientSockFd_, buff, DST_COMMAND_HEAD_LEN, 0); if (static_cast(recvCmdLen) < DST_COMMAND_HEAD_LEN) { - if (recvCmdLen == 0) { + if (!recvCmdLen) { HiLog::Info(DistributedAgent::LABEL, "agent connect socket closed, IP:%s .\n", inet_ntoa(clientAddr.sin_addr)); mbStop_ = true; diff --git a/aw/cxx/distributed/distributed_major.cpp b/aw/cxx/distributed/distributed_major.cpp index 771aec9..98d2d67 100644 --- a/aw/cxx/distributed/distributed_major.cpp +++ b/aw/cxx/distributed/distributed_major.cpp @@ -130,7 +130,7 @@ int DistributeTestEnvironment::ConnectAgent(size_t devNo) addr.sin_port = htons(serverPort_); int connectCount = 0; for (connectCount = 0; connectCount < CONNECT_TIME; connectCount++) { // try connect to agent 3 times. - if (connect(clientSockFd, reinterpret(&addr), sizeof(addr)) == 0) { + if (!connect(clientSockFd, reinterpret(&addr), sizeof(addr))) { break; } std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME)); // delay 10ms @@ -223,7 +223,7 @@ bool DistributeTestEnvironment::SendToAgent(size_t devNo, int cmdType, void *pst HiLog::Error(LABEL, "get error message. type is :%d", pCmdTest->cmdTestType); } } else { - if (rlen == 0) { + if (!rlen) { // peer socket is closed. HiLog::Error(LABEL, "device socket close."); break; diff --git a/aw/cxx/distributed/utils/csv_transform_xml.h b/aw/cxx/distributed/utils/csv_transform_xml.h index 2802b02..89b2088 100644 --- a/aw/cxx/distributed/utils/csv_transform_xml.h +++ b/aw/cxx/distributed/utils/csv_transform_xml.h @@ -67,7 +67,7 @@ public: int testCaseSum = vecLines_.size() / 3; // one item case_result from csv includes 3 strings int failCaseSum = 0; for (std::string s : vecLines_) { - if (s.compare("FAILED") == 0) { + if (!s.compare("FAILED")) { failCaseSum++; } } @@ -78,7 +78,7 @@ public: << "\" failures=\""<< failCaseSum << "\" disabled=\"0\" errors=\"0\" time=\"192.553\">" << std::endl; unsigned long i = 0; while (i < vecLines_.size()) { - if (vecLines_.at(i + 2).compare("FAILED") == 0) { // the result of every case intervals 2 string + if (!(vecLines_.at(i + 2).compare("FAILED"))) { // the result of every case intervals 2 string xmlOut << " " << std::endl; xmlOut << " "<< std::endl; diff --git a/aw/cxx/hwext/perf.cpp b/aw/cxx/hwext/perf.cpp index e1414a5..5e59bf4 100644 --- a/aw/cxx/hwext/perf.cpp +++ b/aw/cxx/hwext/perf.cpp @@ -103,7 +103,7 @@ bool BaseLineManager::ReadXmlFile(string baselinePath) xmlNodePtr ptrRootNode = xmlDocGetRootElement(ptrXmlDoc); if (ptrRootNode == nullptr || ptrRootNode->name == nullptr || - xmlStrcmp(ptrRootNode->name, reinterpret_cast(XML_TAG_ROOT)) != 0) { + xmlStrcmp(ptrRootNode->name, reinterpret_cast(XML_TAG_ROOT))) { xmlFreeDoc(ptrXmlDoc); return false; } @@ -138,7 +138,7 @@ bool BaseLineManager::IsNoBaseline() return m_bNoBaseline; } -double BaseLineManager::StrToDouble(const string& str) +double BaseLineManager::StrtoDouble(const string& str) { istringstream iss(str); double num; @@ -157,7 +157,7 @@ bool BaseLineManager::GetExtraValueDouble(const string testcaseName, const strin map properties = *iter; if (properties.count(XML_TAG_CASENAME) == 1 && properties[XML_TAG_CASENAME] == testcaseName) { if (properties.count(extra) == 1) { - value = StrToDouble(properties[extra]); + value = StrtoDouble(properties[extra]); } break; } diff --git a/examples/calculator/src/calculator.cpp b/examples/calculator/src/calculator.cpp index 63cd5de..dd942ac 100644 --- a/examples/calculator/src/calculator.cpp +++ b/examples/calculator/src/calculator.cpp @@ -32,7 +32,7 @@ int Sub(int e1, int e2) int Mul(int e1, int e2) { int result = e1 * e2; - if (e1 == 0) { + if (!e1) { return 0; } if ((result / e1) != e2) { @@ -43,7 +43,7 @@ int Mul(int e1, int e2) int Div(int e1, int e2) { - if (e2 == 0) { + if (!e2) { return -1; } diff --git a/examples/calculator/test/fuzztest/common/parse_fuzzer/corpus/init b/examples/calculator/test/fuzztest/common/parse_fuzzer/corpus/init index 6b7212c..4dc63c8 100644 --- a/examples/calculator/test/fuzztest/common/parse_fuzzer/corpus/init +++ b/examples/calculator/test/fuzztest/common/parse_fuzzer/corpus/init @@ -1 +1,12 @@ -FUZZ \ No newline at end of file +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. \ No newline at end of file diff --git a/examples/detector/src/detector.cpp b/examples/detector/src/detector.cpp index 368603f..7392964 100644 --- a/examples/detector/src/detector.cpp +++ b/examples/detector/src/detector.cpp @@ -32,7 +32,7 @@ bool IsPrime(int n) return false; } - if (n % DetectorTest::HALF == 0) { + if (!(n % DetectorTest::HALF)) { return n == DetectorTest::HALF; } @@ -40,7 +40,7 @@ bool IsPrime(int n) if (i > (n / i)) { break; } - if (n % i == 0) { + if (!(n % i)) { return false; } } @@ -51,5 +51,5 @@ bool IsPrime(int n) bool FileExist(const char* fileName) { struct stat myStat; - return (stat(fileName, &myStat) == 0); + return (!stat(fileName, &myStat)); } diff --git a/examples/distributedb/test/distributedtest/common/distribute_demo.cpp b/examples/distributedb/test/distributedtest/common/distribute_demo.cpp index c0f0e51..eec2dff 100644 --- a/examples/distributedb/test/distributedtest/common/distribute_demo.cpp +++ b/examples/distributedb/test/distributedtest/common/distribute_demo.cpp @@ -151,7 +151,7 @@ HWTEST_F(DistributeDemo, getkvstore_001, TestSize.Level0) { Options options; options.createIfMissing = true; options.encrypt = false; - options.persistant = true; + options.persistent = true; std::string appId = "com.ohos.nb.service.user1_test"; std::string storeId = "student_1"; manager = AppDistributedKvDataManager::GetInstance(appId, "/data/test"); diff --git a/examples/distributedb/test/distributedtest/common/distribute_demo_agent.cpp b/examples/distributedb/test/distributedtest/common/distribute_demo_agent.cpp index 478c6f8..50886b9 100644 --- a/examples/distributedb/test/distributedtest/common/distribute_demo_agent.cpp +++ b/examples/distributedb/test/distributedtest/common/distribute_demo_agent.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021-2022 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -83,7 +83,7 @@ bool DistributeDemoAgent::SetUp() Options options; options.createIfMissing = true; options.encrypt = false; - options.persistant = true; + options.persistent = true; std::string storeId = g_storeId; Status status = g_manager->GetKvStore(options, storeId, [&](std::unique_ptr kvStore) { g_kvStorePtr = std::move(kvStore); @@ -115,7 +115,7 @@ int DistributeDemoAgent::OnProcessMsg(const std::string &strMsg, int len, nret = returnBufLen; } else { HiLog::Info(LABEL, "receive message=%s.", strMsg.c_str()); - if (strncmp(strMsg.c_str(), "recall", MSG_CALL_LEN) == 0) { + if (!strncmp(strMsg.c_str(), "recall", MSG_CALL_LEN)) { returnStr = "I get recall message."; int ptrlen = returnStr.size(); if (ptrlen > returnBufLen) { diff --git a/examples/lite/c_demo/include/calc_multi.h b/examples/lite/c_demo/include/calc_multi.h index 919b046..439809c 100644 --- a/examples/lite/c_demo/include/calc_multi.h +++ b/examples/lite/c_demo/include/calc_multi.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * Copyright (c) 2020-2021 Huawei Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at diff --git a/examples/lite/c_demo/source/BUILD.gn b/examples/lite/c_demo/source/BUILD.gn index c32c1b2..1d3e8a8 100755 --- a/examples/lite/c_demo/source/BUILD.gn +++ b/examples/lite/c_demo/source/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/libs/benchmark/README_zh.md b/libs/benchmark/README_zh.md index 0d859d6..8265e1c 100644 --- a/libs/benchmark/README_zh.md +++ b/libs/benchmark/README_zh.md @@ -6,7 +6,7 @@ ``` /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 XXXX Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -158,7 +158,7 @@ BENCHMARK_MAIN(); ``` /* - * Copyright (c) 2021 Huawei Device Co., Ltd. + * Copyright (c) 2021 XXXX Device Co., Ltd. * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at @@ -242,10 +242,11 @@ BENCHMARK_MAIN(); benchmark还支持其他多种参数,具体介绍和使用参考[benchmark](https://gitee.com/openharmony/third_party_benchmark/blob/master/README.md) -## 用例编译 + +## 用例编译 ``` -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021 XXXX Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -283,7 +284,7 @@ group("unittest") { 1. 添加文件头注释信息 ``` - # Copyright (c) 2021 Huawei Device Co., Ltd. + # Copyright (c) 2021 XXXX Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/libs/benchmark/template/benchmark_detail.html b/libs/benchmark/template/benchmark_detail.html index 1e39923..0a289a1 100644 --- a/libs/benchmark/template/benchmark_detail.html +++ b/libs/benchmark/template/benchmark_detail.html @@ -1,3 +1,17 @@ + diff --git a/libs/benchmark/template/benchmark_summary.html b/libs/benchmark/template/benchmark_summary.html index 2d5224e..7a40913 100644 --- a/libs/benchmark/template/benchmark_summary.html +++ b/libs/benchmark/template/benchmark_summary.html @@ -1,3 +1,17 @@ + diff --git a/libs/fuzzlib/README_zh.md b/libs/fuzzlib/README_zh.md index b4ca911..3d52e2c 100644 --- a/libs/fuzzlib/README_zh.md +++ b/libs/fuzzlib/README_zh.md @@ -138,7 +138,7 @@ Fuzzing测试框架使用了LLVM编译器框架中的[libFuzzer](https://llvm.or 2. BUILD.gn编写 - 基于[ohos_fuzztest] # 配置Fuzz模板,例如: + 基于[ohos_fuzztest]配置Fuzz模板,例如: ``` ohos_fuzztest("CalculatorFuzzTest") { #定义测试套名称CalculatorFuzzTest @@ -155,7 +155,7 @@ Fuzzing测试框架使用了LLVM编译器框架中的[libFuzzer](https://llvm.or } ``` - [group] # 引用测试套,例如: + [group]引用测试套,例如: ``` group("fuzztest") { diff --git a/libs/fuzzlib/fuzzer_helper.py b/libs/fuzzlib/fuzzer_helper.py index 7bfb2f4..b8c6217 100644 --- a/libs/fuzzlib/fuzzer_helper.py +++ b/libs/fuzzlib/fuzzer_helper.py @@ -112,8 +112,8 @@ def generate(args): template_args = { 'project_name': args.project_name, - 'author': "@fixme", - 'email': "@fixme" + 'author': "", + 'email': "" } project_dir_path = os.path.join(args.project_path, args.project_name) diff --git a/libs/fuzzlib/tools/__init__.py b/libs/fuzzlib/tools/__init__.py index e69de29..74e555a 100644 --- a/libs/fuzzlib/tools/__init__.py +++ b/libs/fuzzlib/tools/__init__.py @@ -0,0 +1,16 @@ +#!/usr/bin/env python +# -*- coding:utf-8 -*- +# +# Copyright (c) 2021 Huawei Device Co., Ltd. +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# \ No newline at end of file diff --git a/src/core/build/build_manager.py b/src/core/build/build_manager.py index f2d437f..0f95c6d 100755 --- a/src/core/build/build_manager.py +++ b/src/core/build/build_manager.py @@ -2,7 +2,7 @@ # coding=utf-8 # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/src/core/build/build_testcases.py b/src/core/build/build_testcases.py index 2189a1b..3d07569 100755 --- a/src/core/build/build_testcases.py +++ b/src/core/build/build_testcases.py @@ -2,7 +2,7 @@ # coding=utf-8 # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -44,8 +44,8 @@ class BuildTestcases(object): user_manager = UserConfigManager() self.is_build_example = user_manager.get_user_config_flag( "build", "example") - self.build_paramter_dic = user_manager.get_user_config( - "build", "paramter") + self.build_parameter_dic = user_manager.get_user_config( + "build", "parameter") @classmethod def _copy_folder(cls, source_dir, target_dir): diff --git a/src/core/build/select_targets.py b/src/core/build/select_targets.py index 756a022..912a6d9 100755 --- a/src/core/build/select_targets.py +++ b/src/core/build/select_targets.py @@ -2,7 +2,7 @@ # coding=utf-8 # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/src/core/command/run.py b/src/core/command/run.py index 8b5cb5d..d89d657 100755 --- a/src/core/command/run.py +++ b/src/core/command/run.py @@ -2,7 +2,7 @@ # coding=utf-8 # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/src/core/config/resource_manager.py b/src/core/config/resource_manager.py index e6780c2..538b813 100755 --- a/src/core/config/resource_manager.py +++ b/src/core/config/resource_manager.py @@ -2,7 +2,7 @@ # coding=utf-8 # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 224fb81..5a160f4 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -2,7 +2,7 @@ # coding=utf-8 # -# Copyright (c) 2020 Huawei Device Co., Ltd. +# Copyright (c) 2020-2021 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at diff --git a/src/core/utils.py b/src/core/utils.py index 379afb9..45d10b2 100755 --- a/src/core/utils.py +++ b/src/core/utils.py @@ -155,7 +155,7 @@ def parse_product_info(product_form): def is_32_bit_test(): manager = UserConfigManager() - para_dic = manager.get_user_config("build", "paramter") + para_dic = manager.get_user_config("build", "parameter") target_cpu = para_dic.get("target_cpu", "") if target_cpu == "arm": return True -- Gitee From e38c26b3d702b6879c4b2750bc688873148f94a7 Mon Sep 17 00:00:00 2001 From: stivn Date: Tue, 29 Mar 2022 11:24:53 +0800 Subject: [PATCH 06/11] Modified Signed-off-by: stivn --- aw/cxx/hwext/perf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aw/cxx/hwext/perf.h b/aw/cxx/hwext/perf.h index 9cc894c..2ce7611 100644 --- a/aw/cxx/hwext/perf.h +++ b/aw/cxx/hwext/perf.h @@ -63,7 +63,7 @@ public: private: bool ReadXmlFile(std::string path); - double StrToDouble(const std::string &str); + double StrtoDouble(const std::string &str); private: BaselineConfig m_bastCfg; -- Gitee From 597323bcdaf654922e82929096b79652abbe7160 Mon Sep 17 00:00:00 2001 From: stivn Date: Tue, 29 Mar 2022 18:23:52 +0800 Subject: [PATCH 07/11] Modified the code Signed-off-by: stivn --- aw/cxx/distributed/distributed.h | 6 ++-- aw/cxx/distributed/distributed_agent.cpp | 12 ++++++-- aw/cxx/distributed/distributed_agent.h | 9 +++--- aw/cxx/distributed/distributed_cfg.cpp | 2 +- aw/cxx/distributed/distributed_cfg.h | 7 +++-- aw/cxx/distributed/distributed_major.cpp | 2 +- aw/cxx/distributed/distributed_major.h | 14 ++++----- aw/cxx/distributed/utils/csv_transform_xml.h | 10 ++++--- aw/cxx/hwext/perf.cpp | 20 ++++++------- aw/cxx/hwext/perf.h | 13 ++++---- .../common/parse_fuzzer/parse_fuzzer.cpp | 6 +++- examples/detector/src/detector.cpp | 3 ++ .../common/distribute_demo.cpp | 10 +++---- examples/lite/c_demo/include/calc_multi.h | 6 ++-- .../performance/common/spent_time_test.cpp | 12 ++++---- libs/benchmark/README_zh.md | 30 +++++++++---------- 16 files changed, 89 insertions(+), 73 deletions(-) diff --git a/aw/cxx/distributed/distributed.h b/aw/cxx/distributed/distributed.h index 857e263..44c712f 100644 --- a/aw/cxx/distributed/distributed.h +++ b/aw/cxx/distributed/distributed.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef _DISTRIBUTED_H_ -#define _DISTRIBUTED_H_ +#ifndef AW_CXX_DISTRIBUTED_DISTRIBUTED_H_ +#define AW_CXX_DISTRIBUTED_DISTRIBUTED_H_ #include #include "securec.h" @@ -50,4 +50,4 @@ using DistDeviceInfo = DistDevInfo; } // namespace DistributeSystemTest } // namespace OHOS -#endif // _DISTRIBUTED_H_ +#endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_H_ diff --git a/aw/cxx/distributed/distributed_agent.cpp b/aw/cxx/distributed/distributed_agent.cpp index 3734a5e..e07f9bb 100644 --- a/aw/cxx/distributed/distributed_agent.cpp +++ b/aw/cxx/distributed/distributed_agent.cpp @@ -85,7 +85,11 @@ int DistributedAgent::InitAgentServer() } struct sockaddr_in addr; - memset_s(&addr, sizeof(addr), 0, sizeof(addr)); + errno_t ret = EOK; + ret = memset_s(&addr, sizeof(addr), 0, sizeof(addr)); + if (ret != EOK) { + return -1; + } addr.sin_family = AF_INET; if (agentIpAddr_ != "") { inet_pton(AF_INET, agentIpAddr_.c_str(), &addr.sin_addr); @@ -203,7 +207,9 @@ int DistributedAgent::DoCmdServer(int serverSockFd) auto pclinereturn = reinterpret_cast(returnValue); pclinereturn->no = pcline->no; pclinereturn->cmdTestType = htons(DST_COMMAND_CALL); - sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), "%d", nresult); + if (sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), "%d", nresult) < 0) { + return -1; + } rlen = strlen(pclinereturn->alignmentCmd) + 1; pclinereturn->len = htons(rlen); HiLog::Info(DistributedAgent::LABEL, "agent get message :%s .\n", @@ -413,4 +419,4 @@ int DistributedAgent::Stop() return 0; } } // namespace DistributeSystemTest -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/aw/cxx/distributed/distributed_agent.h b/aw/cxx/distributed/distributed_agent.h index 2a5aced..cb5af1d 100644 --- a/aw/cxx/distributed/distributed_agent.h +++ b/aw/cxx/distributed/distributed_agent.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef DISTRIBUTED_AGENT_H -#define DISTRIBUTED_AGENT_H +#ifndef AW_CXX_DISTRIBUTED_DISTRIBUTED_AGENT_H_ +#define AW_CXX_DISTRIBUTED_DISTRIBUTED_AGENT_H_ #include #include @@ -47,7 +47,7 @@ public: protected: virtual bool SetUp(); virtual bool TearDown(); - virtual void OnLocalInit() {}; + virtual void OnLocalInit() {} virtual int OnProcessCmd(const std::string &strCommand, int cmdLen, const std::string &strArgs, int argsLen, const std::string &strExpectValue, int expectValueLen); virtual int OnProcessMsg(const std::string &strMsg, int msgLen, std::string &strReturnValue, int returnBufLen); @@ -69,4 +69,5 @@ private: } // namespace DistributeSystemTest } // namespace OHOS -#endif // DISTRIBUTED_AGENT_H +#endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_AGENT_H_ + diff --git a/aw/cxx/distributed/distributed_cfg.cpp b/aw/cxx/distributed/distributed_cfg.cpp index ad64fc6..3addc39 100644 --- a/aw/cxx/distributed/distributed_cfg.cpp +++ b/aw/cxx/distributed/distributed_cfg.cpp @@ -160,4 +160,4 @@ std::unique_ptr& DistributedCfg::GetInstance() std::unique_ptr DistributedCfg::getCfg_ = nullptr; } // namespace DistributeSystemTest -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/aw/cxx/distributed/distributed_cfg.h b/aw/cxx/distributed/distributed_cfg.h index e8fb0a1..e9766e4 100644 --- a/aw/cxx/distributed/distributed_cfg.h +++ b/aw/cxx/distributed/distributed_cfg.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef DISTRIBUTED_CFG_H -#define DISTRIBUTED_CFG_H +#ifndef AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_ +#define AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_ #include #include @@ -52,4 +52,5 @@ private: }; } // namespace DistributeSystemTest } // namespace OHOS -#endif \ No newline at end of file + +#endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_ diff --git a/aw/cxx/distributed/distributed_major.cpp b/aw/cxx/distributed/distributed_major.cpp index 98d2d67..43c2f89 100644 --- a/aw/cxx/distributed/distributed_major.cpp +++ b/aw/cxx/distributed/distributed_major.cpp @@ -504,4 +504,4 @@ bool DistributeTest::Notify(AGENT_NO devNo, const std::string ¬ifyType, const return false; } } // namespace DistributeSystemTest -} // namespace OHOS \ No newline at end of file +} // namespace OHOS diff --git a/aw/cxx/distributed/distributed_major.h b/aw/cxx/distributed/distributed_major.h index 1acb3dd..cb913a6 100644 --- a/aw/cxx/distributed/distributed_major.h +++ b/aw/cxx/distributed/distributed_major.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef DISTRIBUTED_MAJOR_H -#define DISTRIBUTED_MAJOR_H +#ifndef AW_CXX_DISTRIBUTED_DISTRIBUTED_MAJOR_H_ +#define AW_CXX_DISTRIBUTED_DISTRIBUTED_MAJOR_H_ #include #include @@ -92,7 +92,7 @@ protected: int GetReturnVal(); private: - void OnProcessNotify() {}; + void OnProcessNotify() {} int returnVal_; static void SetUpTestCase(void); @@ -101,14 +101,14 @@ private: // init network environment, obtain all the address of agent and connect int InitEnv(std::vector clientList); - virtual void SetUp() {}; - virtual void TearDown() {}; + virtual void SetUp() {} + virtual void TearDown() {} - virtual void OnNotify() {}; + virtual void OnNotify() {} virtual bool OnProcessValue(const std::string &szbuf, int len); virtual bool OnMsgProc(const std::string &szbuf, int len); }; } // namespace DistributeSystemTest } // namespace OHOS -#endif // DISTRIBUTED_MAJOR_H \ No newline at end of file +#endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_MAJOR_H_ diff --git a/aw/cxx/distributed/utils/csv_transform_xml.h b/aw/cxx/distributed/utils/csv_transform_xml.h index 89b2088..abb59a2 100644 --- a/aw/cxx/distributed/utils/csv_transform_xml.h +++ b/aw/cxx/distributed/utils/csv_transform_xml.h @@ -13,8 +13,9 @@ * limitations under the License. */ -#ifndef UNTITLED_CSV_TO_XML_H -#define UNTITLED_CSV_TO_XML_H +#ifndef AW_CXX_DISTRIBUTED_UTILS_CSV_TRANSFORM_XML_H_ +#define AW_CXX_DISTRIBUTED_UTILS_CSV_TRANSFORM_XML_H_ + #include #include #include @@ -35,7 +36,7 @@ class CsvTransformXml { public: - CsvTransformXml(std::string targetFile) + explicit CsvTransformXml(std::string targetFile) { SetFileName(targetFile); SetCvsFileName(); @@ -137,4 +138,5 @@ public: } }; -#endif // UNTITLED_CVS_TO_XML_H +#endif // AW_CXX_DISTRIBUTED_UTILS_CSV_TRANSFORM_XML_H_ + diff --git a/aw/cxx/hwext/perf.cpp b/aw/cxx/hwext/perf.cpp index 5e59bf4..728e522 100644 --- a/aw/cxx/hwext/perf.cpp +++ b/aw/cxx/hwext/perf.cpp @@ -32,8 +32,6 @@ namespace TestAW { #define ID_LARGER_IS_BETTER true #define ID_SMALLER_IS_BETTER false -#define _max(a,b) (((a)>=(b)) ? (a) : (b) ) -#define _min(a,b) (((a)<=(b)) ? (a) : (b)) namespace { const auto XML_TAG_ROOT = "configuration"; @@ -182,7 +180,7 @@ GtestPerfTestCase::GtestPerfTestCase(BaseLineManager* pManager, // get test case name from GTEST API. // should be use tester->XXX() instead of this. - if (tester != nullptr) { + if (tester != nullptr && ::testing::UnitTest::GetInstance() != nullptr) { m_strCaseName = string(::testing::UnitTest::GetInstance()->current_test_info()->name()); } @@ -284,11 +282,11 @@ bool GtestPerfTestCase::ExpectValue(double testValue, bool isLargerBetter) } else { double baseValue = -1; if (isLargerBetter) { - baseValue = _max(m_dbLastValue, m_dbBaseLine); + baseValue = (m_dbLastValue >= m_dbBaseLine) ? m_dbLastValue : m_dbBaseLine; EXPECT_GE(testValue, (baseValue * (1.0 - m_dbFloatRange))); m_bTestResult = (testValue >= (baseValue * (1.0 - m_dbFloatRange))) ? true : false; } else { - baseValue = _min(m_dbLastValue, m_dbBaseLine); + baseValue = (m_dbLastValue <= m_dbBaseLine) ? m_dbLastValue : m_dbBaseLine; EXPECT_LE(testValue, (baseValue * (1.0 + m_dbFloatRange))); m_bTestResult = (testValue <= (baseValue * (1.0 + m_dbFloatRange))) ? true : false; } @@ -311,22 +309,22 @@ bool GtestPerfTestCase::SaveResult(double testValue) INF_MSG("[ PERF ] %s: baseline:%f, test_result: %f\n", m_strCaseName.c_str(), m_dbBaseLine, testValue); - memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); + (void)memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, "%g", m_dbBaseLine) > 0) { m_pTester->RecordProperty("baseline", buffer); } - memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); + (void)memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, "%d", m_dCaseVersion) > 0) { m_pTester->RecordProperty("tc_version", buffer); } - memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); + (void)memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, "%g", m_dbLastValue) > 0) { m_pTester->RecordProperty("lastvalue", m_bHasLastValue ? buffer : ""); } - memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); + (void)memset_s(buffer, sizeof(buffer), 0, sizeof(buffer)); if (snprintf_s(buffer, sizeof(buffer), sizeof(buffer) - 1, "%g", testValue) > 0) { m_pTester->RecordProperty("value", buffer); } @@ -337,5 +335,5 @@ bool GtestPerfTestCase::SaveResult(double testValue) return true; } -} // TestAW -} // OHOS \ No newline at end of file +} // namespace TestAW +} // namespace OHOS diff --git a/aw/cxx/hwext/perf.h b/aw/cxx/hwext/perf.h index 2ce7611..8dabe4f 100644 --- a/aw/cxx/hwext/perf.h +++ b/aw/cxx/hwext/perf.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef TEST_AW_CXX_HWEXT_PERF_H -#define TEST_AW_CXX_HWEXT_PERF_H +#ifndef AW_CXX_HWEXT_PERF_H_ +#define AW_CXX_HWEXT_PERF_H_ #include #include @@ -80,7 +80,7 @@ public: std::string testClassName = "", std::string testInterfaceName = ""); - ~GtestPerfTestCase() {}; + ~GtestPerfTestCase() {} // expect result is larger than or equal baseline*(1.0-float_range). bool ExpectLarger(double testValue); @@ -164,6 +164,7 @@ private: bool m_bTestResult; double m_dbTestResult; }; -} // TestAW -} // OHOS -#endif // TEST_AW_CXX_HWEXT_PERF_H \ No newline at end of file +} // namespace TestAW +} // namespace OHOS + +#endif // AW_CXX_HWEXT_PERF_H_ diff --git a/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp index e09b54e..beead98 100644 --- a/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp +++ b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp @@ -25,6 +25,10 @@ const int FUZZ_FTH_DATA = 3; namespace OHOS { bool DoSomethingInterestingWithMyAPI(const uint8_t* data, size_t size) { + if (data == nullptr) { + return false; + } + bool result = false; if (size >= FUZZ_DATA_LEN) { result = data[FUZZ_FST_DATA] == 'F' && @@ -34,7 +38,7 @@ namespace OHOS { } return result; } -} +} // namespace.OHOS /* Fuzzer entry point */ extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) diff --git a/examples/detector/src/detector.cpp b/examples/detector/src/detector.cpp index 7392964..9f84764 100644 --- a/examples/detector/src/detector.cpp +++ b/examples/detector/src/detector.cpp @@ -50,6 +50,9 @@ bool IsPrime(int n) bool FileExist(const char* fileName) { + if (fileName == nullptr) { + return false; + } struct stat myStat; return (!stat(fileName, &myStat)); } diff --git a/examples/distributedb/test/distributedtest/common/distribute_demo.cpp b/examples/distributedb/test/distributedtest/common/distribute_demo.cpp index eec2dff..f485b7f 100644 --- a/examples/distributedb/test/distributedtest/common/distribute_demo.cpp +++ b/examples/distributedb/test/distributedtest/common/distribute_demo.cpp @@ -45,11 +45,11 @@ public: DistributeDemo() = default; ~DistributeDemo() = default; - static void SetUpTestCase(void) {}; - static void TearDownTestCase(void) {}; + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} - virtual void SetUp() {}; - virtual void TearDown() {}; + virtual void SetUp() {} + virtual void TearDown() {} }; /** @@ -252,4 +252,4 @@ int main(int argc, char *argv[]) testing::GTEST_FLAG(output) = "xml:./"; testing::InitGoogleTest(&argc, argv); return RUN_ALL_TESTS(); -} \ No newline at end of file +} diff --git a/examples/lite/c_demo/include/calc_multi.h b/examples/lite/c_demo/include/calc_multi.h index 439809c..1bbda7f 100644 --- a/examples/lite/c_demo/include/calc_multi.h +++ b/examples/lite/c_demo/include/calc_multi.h @@ -13,8 +13,8 @@ * limitations under the License. */ -#ifndef SERVICEDEMO_CALC_MULTI_H -#define SERVICEDEMO_CALC_MULTI_H +#ifndef EXAMPLE_LITE_C_DEMO_INCLUDE_CALC_MULTI_H_ +#define EXAMPLE_LITE_C_DEMO_INCLUDE_CALC_MULTI_H_ #ifdef __cplusplus #if __cplusplus @@ -30,4 +30,4 @@ int calc_multi(int a, int b); #endif #endif -#endif // SERVICEDEMO_CALC_MULTI_H +#endif // EXAMPLE_LITE_C_DEMO_INCLUDE_CALC_MULTI_H_ diff --git a/examples/sleep/test/performance/common/spent_time_test.cpp b/examples/sleep/test/performance/common/spent_time_test.cpp index b96b947..421ffde 100644 --- a/examples/sleep/test/performance/common/spent_time_test.cpp +++ b/examples/sleep/test/performance/common/spent_time_test.cpp @@ -24,19 +24,19 @@ using namespace OHOS::TestAW; static BaseLineManager m_baseline(PERF_BASELINE_CONFIG_PATH); class SpentTimeTest : public testing::Test { public: - static void SetUpTestCase(void) {}; - static void TearDownTestCase(void) {}; - void SetUp() {}; - void TearDown() {}; + static void SetUpTestCase(void) {} + static void TearDownTestCase(void) {} + void SetUp() {} + void TearDown() {} }; static void LoopMsleep(void* pMsec) { - if (pMsec == NULL) { + if (pMsec == nullptr) { return; } - int msec = *(int*)pMsec; + int msec = *reinterpret_cast (pMsec); for (int index = 0; index < msec; index++) { Msleep(1); } diff --git a/libs/benchmark/README_zh.md b/libs/benchmark/README_zh.md index 8265e1c..ad5cb62 100644 --- a/libs/benchmark/README_zh.md +++ b/libs/benchmark/README_zh.md @@ -263,20 +263,20 @@ import("//build/test.gni") module_output_path = "developertest/calculator" -ohos_unittest("BenchmarkDemoTest") { - module_out_path = module_output_path - sources = [ "benchmark_demo_test.cpp" ] +ohos_benchmarktest("BenchmarkDemoTest") { + module_out_path = module_output_path + sources = [ "benchmark_demo_test.cpp" ] } -group("unittest") { - testonly = true - deps = [] - - deps += [ - # deps file - ":BenchmarkDemoTest", - ] -} +group("benchmarktest") { + testonly = true + deps = [] + + deps += [ + # deps file + ":BenchmarkDemoTest", + ] +} ``` 详细内容如下: @@ -315,9 +315,9 @@ group("unittest") { 4. 指定测试套名称 ``` - ohos_unittest("BenchmarkDemoTest") { # benchmark测试编译模板 - module_out_path = module_output_path - sources = [ "benchmark_demo_test.cpp" ] # 指定测试用例文件 + ohos_benchmarktest("BenchmarkDemoTest") { + module_out_path = module_output_path + sources = [ "benchmark_demo_test.cpp" ] } ``` -- Gitee From c721689891d51702515dac772b5359c891ab9488 Mon Sep 17 00:00:00 2001 From: stivn Date: Tue, 29 Mar 2022 19:47:51 +0800 Subject: [PATCH 08/11] Modified Signed-off-by: stivn --- aw/cxx/distributed/distributed_agent.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aw/cxx/distributed/distributed_agent.cpp b/aw/cxx/distributed/distributed_agent.cpp index e07f9bb..d1a3aa0 100644 --- a/aw/cxx/distributed/distributed_agent.cpp +++ b/aw/cxx/distributed/distributed_agent.cpp @@ -207,9 +207,8 @@ int DistributedAgent::DoCmdServer(int serverSockFd) auto pclinereturn = reinterpret_cast(returnValue); pclinereturn->no = pcline->no; pclinereturn->cmdTestType = htons(DST_COMMAND_CALL); - if (sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), "%d", nresult) < 0) { - return -1; - } + (void)sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), + "%d", nresult) < 0); rlen = strlen(pclinereturn->alignmentCmd) + 1; pclinereturn->len = htons(rlen); HiLog::Info(DistributedAgent::LABEL, "agent get message :%s .\n", -- Gitee From 2cde3b8d922f8aaa95b2b5371c93f4dea8595e98 Mon Sep 17 00:00:00 2001 From: stivn Date: Tue, 29 Mar 2022 19:54:56 +0800 Subject: [PATCH 09/11] Modified Signed-off-by: stivn --- aw/cxx/distributed/distributed_agent.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aw/cxx/distributed/distributed_agent.cpp b/aw/cxx/distributed/distributed_agent.cpp index d1a3aa0..72a90a9 100644 --- a/aw/cxx/distributed/distributed_agent.cpp +++ b/aw/cxx/distributed/distributed_agent.cpp @@ -207,7 +207,7 @@ int DistributedAgent::DoCmdServer(int serverSockFd) auto pclinereturn = reinterpret_cast(returnValue); pclinereturn->no = pcline->no; pclinereturn->cmdTestType = htons(DST_COMMAND_CALL); - (void)sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), + (void)sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), "%d", nresult) < 0); rlen = strlen(pclinereturn->alignmentCmd) + 1; pclinereturn->len = htons(rlen); -- Gitee From ccbae029d8bee4285d050c3fa15b105233f7b71a Mon Sep 17 00:00:00 2001 From: stivn Date: Wed, 6 Apr 2022 18:00:26 +0800 Subject: [PATCH 10/11] modified Signed-off-by: stivn --- src/core/driver/drivers.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/core/driver/drivers.py b/src/core/driver/drivers.py index 5a160f4..ac93f2b 100755 --- a/src/core/driver/drivers.py +++ b/src/core/driver/drivers.py @@ -462,11 +462,13 @@ class CppTestDriver(IDriver): self.config.device.stop_catch_device_log() def _init_gtest(self): - self.config.device.hdc_command("remount") + self.config.device.hdc_command("target mount") self.config.device.execute_shell_command( "rm -rf %s" % self.config.target_test_path) self.config.device.execute_shell_command( "mkdir -p %s" % self.config.target_test_path) + self.config.device.execute_shell_command( + "mount -o rw,remount,rw /") if "fuzztest" == self.config.testtype[0]: self.config.device.execute_shell_command( "mkdir -p %s" % os.path.join(self.config.target_test_path, @@ -648,7 +650,7 @@ class JSUnitTestDriver(IDriver): self.config.device.execute_shell_command( "mkdir -p %s" % self.config.target_test_path) self.config.device.execute_shell_command( - "mount -o rw,remount,rw /%s" % "system") + "mount -o rw,remount,rw /") def _run_jsunit(self, suite_file): -- Gitee From 7619804882a2775de3488fbeda3361c33054311f Mon Sep 17 00:00:00 2001 From: stivn Date: Thu, 7 Apr 2022 16:14:56 +0800 Subject: [PATCH 11/11] Modified the BUILD.gn Signed-off-by: stivn --- .../calculator/test/fuzztest/common/parse_fuzzer/BUILD.gn | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/calculator/test/fuzztest/common/parse_fuzzer/BUILD.gn b/examples/calculator/test/fuzztest/common/parse_fuzzer/BUILD.gn index bfdc220..0aad50f 100644 --- a/examples/calculator/test/fuzztest/common/parse_fuzzer/BUILD.gn +++ b/examples/calculator/test/fuzztest/common/parse_fuzzer/BUILD.gn @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Huawei Device Co., Ltd. +# Copyright (c) 2021-2022 Huawei Device Co., Ltd. # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at @@ -19,7 +19,7 @@ module_output_path = "developertest/calculator" ##############################fuzztest########################################## ohos_fuzztest("CalculatorFuzzTest") { module_out_path = module_output_path - + fuzz_config_file = "//test/developertest/examples/calculator/test/fuzztest/common/parse_fuzzer" include_dirs = [] cflags = [ "-g", -- Gitee