diff --git a/aw/cxx/distributed/distributed.h b/aw/cxx/distributed/distributed.h index 9e4d3b068be53f5d8fa08f1d680565b5f0542aec..44c712f8ea2848ead9b1ee2b9221fcf4ae082745 100644 --- a/aw/cxx/distributed/distributed.h +++ b/aw/cxx/distributed/distributed.h @@ -13,20 +13,20 @@ * 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" 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. @@ -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 400847ee1ac8ecf426e200949fb36039708bff44..72a90a9a1bfcad6978248456977166fa684e4884 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,14 +78,18 @@ 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; } 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); @@ -94,7 +98,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); @@ -103,12 +107,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); }); @@ -132,7 +136,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 +157,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) { HiLog::Info(DistributedAgent::LABEL, "agent connect socket closed, IP:%s .\n", inet_ntoa(clientAddr.sin_addr)); mbStop_ = true; @@ -196,12 +200,15 @@ 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); pclinereturn->no = pcline->no; pclinereturn->cmdTestType = htons(DST_COMMAND_CALL); - sprintf_s(pclinereturn->alignmentCmd, (MAX_BUFF_LEN - DST_COMMAND_HEAD_LEN), "%d", nresult); + (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", @@ -411,4 +418,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 2a5aced4b5f6557238a372c1f848e387e34f1b19..cb5af1d383bd91a2c04c8cc7e73e39ed22feb4f6 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 ad64fc60cd9dff2a19c7acdcdb5e5188a8932c1d..3addc39245cd5b272c34e881d52a71e97c7c2ac3 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 1c6a6ab8011130be881a901d18358ad9495db308..e9766e4881468fad763ee911216245b3e07aed65 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 @@ -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(); @@ -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 1638b826dc54405cdc1e42f0bce9d6092b66319f..43c2f89a1dffe841939bedd4a4c1dc75a65949dc 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))) { 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; @@ -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; @@ -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 1acb3dd587e62cf7466b0d52f6ec2d1b4d24c432..cb913a61344f74ce4f3bd70aa9f35d0e4c6961cb 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 2802b020067b65cf7dc4dd68679e313d34d46dcb..abb59a25e98b95844602b545436be47b2c60bc7e 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(); @@ -67,7 +68,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 +79,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; @@ -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/BUILD.gn b/aw/cxx/hwext/BUILD.gn index 379f4ff0d18975c95b291f678fcdc511a3d734a1..c8b709bae4818e9d92162ef77898dabd1058078e 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" } diff --git a/aw/cxx/hwext/perf.cpp b/aw/cxx/hwext/perf.cpp index e1414a510c4761c0d3abe5c2efc07218011bcbc9..728e5224797ffa5abbb7faec4b8208f17c928599 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"; @@ -103,7 +101,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 +136,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 +155,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; } @@ -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 662dd9137a9a1812049877955ec4368b59ec0148..8dabe4f22a215d70c32c6a91ea4da4aa733c2a5f 100644 --- a/aw/cxx/hwext/perf.h +++ b/aw/cxx/hwext/perf.h @@ -13,13 +13,13 @@ * 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 #include -#include +#include #include "securec.h" #include @@ -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; @@ -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/bundle.json b/bundle.json new file mode 100644 index 0000000000000000000000000000000000000000..678ab5fea019762583a589535a167b4934d74d7a --- /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 9b8168f07ac63b98db3edabf363b32d98e099923..4f39f2f98c8c5e9cbce20000b501765412817039 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 e71a031359850268aa3fd3ce1dd775ec047a9471..dd942ace19e31e40b64e799df9662b8b3d2f2af2 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) { @@ -33,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) { @@ -44,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/BUILD.gn b/examples/calculator/test/fuzztest/common/parse_fuzzer/BUILD.gn index bfdc2202c82c162db4ca8fb5e4d1622cf19dbcb6..0aad50f62c7d550239e765209f4d1f2cca87fdd0 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", diff --git a/examples/calculator/test/fuzztest/common/parse_fuzzer/corpus/init b/examples/calculator/test/fuzztest/common/parse_fuzzer/corpus/init index 6b7212c8a6a9ee6e433ea43d0c2c2e96568ad4c4..4dc63c8f403b1fa695180b46d78e22021ec1cd04 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/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.cpp index 576457ac2b63bf9664c6513c4a4126aed79f71fc..beead983a4a1e81b5ad1837869849d7d71797503 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; @@ -27,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' && @@ -36,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/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.h b/examples/calculator/test/fuzztest/common/parse_fuzzer/parse_fuzzer.h index bf3acfc48cd91e9eeb848b9e7eca48c6e461d822..9089dfa2f553ae84b1edb15f262ef001320235da 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 26d0a1b975154b0d6b801976966749c1faea7192..a4c032736b710eccc7fd495a5ca11b35784b7f2d 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/detector/src/detector.cpp b/examples/detector/src/detector.cpp index 368603fdb99e7c40bcbd12fd75012312f273b03b..9f84764ba2144982c3e0dfb3ce0d197a6905ece8 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; } } @@ -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) == 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 c0f0e51c2ba6a3123913339ee9de1ecc8f886479..f485b7f58cfea055cf510285886d03f18d5406e6 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() {} }; /** @@ -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"); @@ -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/distributedb/test/distributedtest/common/distribute_demo_agent.cpp b/examples/distributedb/test/distributedtest/common/distribute_demo_agent.cpp index 478c6f82d15b43760523f4a9ff9c614a87a4a868..50886b9ed0dadecff347e1f7a6553568a4bfcef0 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 919b046524a5e5a7299850420c269b8f272d3181..1bbda7f0405842b810ed0066ffc9c3e31a487360 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 @@ -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/lite/c_demo/source/BUILD.gn b/examples/lite/c_demo/source/BUILD.gn index c32c1b2c586561b5a7aef09f9a32818d412c6804..1d3e8a815e0061e52df85903cf7916097df02857 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/examples/sleep/include/sleep_ex.h b/examples/sleep/include/sleep_ex.h index d6ca5b3a60cd76ffeae4afc2278442d4b8ea40ae..0b7939dbce01833a63184332f98511f6544a3409 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 5c213280eef6a78a0989510adb09ac07470312f6..46444f10b38a8d8a548b10a424fa75a4226a84da 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/examples/sleep/test/performance/common/spent_time_test.cpp b/examples/sleep/test/performance/common/spent_time_test.cpp index b96b9475aa6b368a1d2df6f5672b03641e24c95b..421ffded7912dd3a614aa45b4685361f12e591ee 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 0d859d6aabeb1f87dff17e9129709af069595e01..ad5cb624f2432898428456ec1bb21501aa8f1cb8 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 @@ -262,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", + ] +} ``` 详细内容如下: @@ -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 @@ -314,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" ] } ``` diff --git a/libs/benchmark/template/benchmark_detail.html b/libs/benchmark/template/benchmark_detail.html index 4599395f46d9998688a2c4d19f92eb5e3d1fc0d4..0a289a1e90e8acfdf8bace2f88b9e48298be54eb 100644 --- a/libs/benchmark/template/benchmark_detail.html +++ b/libs/benchmark/template/benchmark_detail.html @@ -1,3 +1,17 @@ + @@ -7,7 +21,7 @@ - + @@ -135,4 +149,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 13d829f6f007a0d92824c9e73fee545da02fe72d..7a40913e52b502795fbd48df4b582087f3eb5930 100644 --- a/libs/benchmark/template/benchmark_summary.html +++ b/libs/benchmark/template/benchmark_summary.html @@ -1,3 +1,17 @@ + @@ -115,7 +129,7 @@ - + diff --git a/libs/fuzzlib/README_zh.md b/libs/fuzzlib/README_zh.md index b4ca91190def65375448ae65365150375ef0b851..3d52e2ceb5dcaf7c7edda7f10507bbcecc748529 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 7bfb2f48ec7591ec25a833f8cd2381ddc825d9a9..b8c6217419047f2c6d31f1a22b6e03b4c5b3d2f9 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 e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..74e555a47a3152df7771378bb33a0b937433ce68 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/ohos.build b/ohos.build deleted file mode 100644 index e2efca2a7452596656071915a25254189c8c99e6..0000000000000000000000000000000000000000 --- 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/build/build_manager.py b/src/core/build/build_manager.py index f2d437f53910f7a129938e58bae0b92bf0d01667..0f95c6da19ba3ca517ba42a67f408f3b487c1caa 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 2189a1bf1444c0b2810ddba7697c09682563f749..3d07569932c1c85614805a3f9f8db3b951345960 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 756a02224da20c3bdaadd9c2280dcb27f9cfdbaf..912a6d942592669afeac12d70effceb40813f339 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 8b5cb5d311a9f09ae037d0ac65961acc8a663022..d89d6577e882c39367246e97ec0e78bd5f4ee0b4 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/config_manager.py b/src/core/config/config_manager.py index c8224e042d26a63b7753e93ee107bfe3545d743c..3b463f63ae52793e96ea81cfcf619f5715ca9f77 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: diff --git a/src/core/config/resource_manager.py b/src/core/config/resource_manager.py index e6780c2a4adf3b9ebaa6829e7b1661229b0c86f8..538b813dce5cf23e7c04717af23899d6f0d276ee 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 224fb818b9344b15f204b307ee19b4e69e4a26b8..ac93f2ba9963678ab1d965761c552c3283249246 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 @@ -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): diff --git a/src/core/utils.py b/src/core/utils.py index 379afb9f30d91d0a782d175c28fd251eb2e50d80..45d10b2ee3e7c809ddc73843525959631deb5ae0 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