diff --git a/aw/cxx/distributed/distributed_agent.h b/aw/cxx/distributed/distributed_agent.h index cb5af1d383bd91a2c04c8cc7e73e39ed22feb4f6..dd45cd1a58dc089afff8d33326f30d4d0a29fa13 100644 --- a/aw/cxx/distributed/distributed_agent.h +++ b/aw/cxx/distributed/distributed_agent.h @@ -42,7 +42,7 @@ public: static const int RECE_LEN = 10; static const int CMD_LENGTH = 50; static const int HALF_NUM = 2; - static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "DistributedAgent"}; + static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD001690, "DistributedAgent"}; protected: virtual bool SetUp(); diff --git a/aw/cxx/distributed/distributed_cfg.cpp b/aw/cxx/distributed/distributed_cfg.cpp index 3addc39245cd5b272c34e881d52a71e97c7c2ac3..1b0b718d92185625b40d8f98fb07fb9c13257fb0 100644 --- a/aw/cxx/distributed/distributed_cfg.cpp +++ b/aw/cxx/distributed/distributed_cfg.cpp @@ -18,12 +18,11 @@ #include #include -#include "hilog/log.h" - namespace OHOS { namespace DistributeSystemTest { using namespace std; -static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "DistributeTestEnvironment"}; +using namespace OHOS::HiviewDFX; + DistributedCfg::DistributedCfg() { @@ -100,53 +99,53 @@ std::string DistributedCfg::GetDeviceIp(std::string fileName, size_t devNo) { devNo--; if (!OpenCfg(fileName)) { - HiviewDFX::HiLog::Error(LABEL, - "OpenCfg() failed! make sure the filename:%s of major or agent", - fileName.c_str()); + HiLog::Error(DistributedCfg::LABEL, + "OpenCfg() failed! make sure the filename:%s of major or agent", + fileName.c_str()); return ""; } std::string valueOfIps; if (!GetCfgVal("agentlist", valueOfIps)) { - HiviewDFX::HiLog::Error(LABEL, - "GetCfgVal() failed! make sure the filename:%s of major or agent", - fileName.c_str()); + HiLog::Error(DistributedCfg::LABEL, + "GetCfgVal() failed! make sure the filename:%s of major or agent", + fileName.c_str()); return ""; } std::string ip = GetValueInString(valueOfIps, devNo); if (!ip.compare("")) { - HiviewDFX::HiLog::Error(LABEL, - "GetValueOfString() return ""! %zu maybe bigger than the sum of devices_online", - devNo + 1); + HiLog::Error(DistributedCfg::LABEL, + "GetValueOfString() return ""! %zu maybe bigger than the sum of devices_online", + devNo + 1); return ""; } - HiviewDFX::HiLog::Info(LABEL, "get %zu device's ip : %s", devNo + 1, ip.c_str()); + HiLog::Info(DistributedCfg::LABEL, "get %zu device's ip : %s", devNo + 1, ip.c_str()); return ip; } std::string DistributedCfg::GetDeviceUuid(std::string fileName, size_t devNo) { if (!OpenCfg(fileName)) { - HiviewDFX::HiLog::Error(LABEL, - "OpenCfg() failed! make sure the filename:%s of major or agent", - fileName.c_str()); + HiLog::Error(DistributedCfg::LABEL, + "OpenCfg() failed! make sure the filename:%s of major or agent", + fileName.c_str()); return ""; } std::string valueOfUuids; if (!GetCfgVal("devicesuuid", valueOfUuids)) { - HiviewDFX::HiLog::Error(LABEL, - "GetCfgVal() failed! make sure the filename:%s of major or agent", - fileName.c_str()); + HiLog::Error(DistributedCfg::LABEL, + "GetCfgVal() failed! make sure the filename:%s of major or agent", + fileName.c_str()); return ""; } std::string uuid = GetValueInString(valueOfUuids, devNo); if (!uuid.compare("")) { printf("device:%zu uuid is null \n", devNo); - HiviewDFX::HiLog::Error(LABEL, - "GetValueOfString() return ""! %zu maybe bigger than the sum of devices_online", - devNo); + HiLog::Error(DistributedCfg::LABEL, + "GetValueOfString() return ""! %zu maybe bigger than the sum of devices_online", + devNo); return ""; } - HiviewDFX::HiLog::Info(LABEL, "get %zu device's uuid : %s", devNo, uuid.c_str()); + HiLog::Info(DistributedCfg::LABEL, "get %zu device's uuid : %s", devNo, uuid.c_str()); return uuid; } diff --git a/aw/cxx/distributed/distributed_cfg.h b/aw/cxx/distributed/distributed_cfg.h index e9766e4881468fad763ee911216245b3e07aed65..a4763caaf88ade79aa1ba55900d3670619b6ef1b 100644 --- a/aw/cxx/distributed/distributed_cfg.h +++ b/aw/cxx/distributed/distributed_cfg.h @@ -19,6 +19,8 @@ #include #include +#include "hilog/log.h" + namespace OHOS { namespace DistributeSystemTest { using namespace std; @@ -47,6 +49,8 @@ public: static std::unique_ptr& GetInstance(); static std::unique_ptr getCfg_; + static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD001690, "DistributedCfg"}; + private: std::map cfgMap_; // from env.desc file }; diff --git a/aw/cxx/distributed/distributed_major.cpp b/aw/cxx/distributed/distributed_major.cpp index b086441b6c3765b579066a1192d15e706956f70e..afc79f4a5b0e8afaf0abb792678719a2db9d5682 100644 --- a/aw/cxx/distributed/distributed_major.cpp +++ b/aw/cxx/distributed/distributed_major.cpp @@ -28,7 +28,6 @@ #include #include #include "securec.h" -#include "hilog/log.h" namespace OHOS { namespace DistributeSystemTest { @@ -37,7 +36,6 @@ using namespace testing; using namespace OHOS::HiviewDFX; DistributeTestEnvironment *g_pDistributetestEnv = nullptr; namespace { - const constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0, "DistributeTestEnvironment"}; const int CONNECT_TIME = 3; const int SLEEP_TIME = 1000; const int HALF_BUF_LEN = 2; @@ -83,7 +81,7 @@ void DistributeTestEnvironment::Init(std::string fileName) if (sscanf_s(strPort.c_str(), "%d", &serverPort_) < 1) { serverPort_ = DEFAULT_AGENT_PORT; } - HiLog::Info(LABEL, "get device port : %d", serverPort_); + HiLog::Info(DistributeTestEnvironment::LABEL, "get device port : %d", serverPort_); } DistributeTestEnvironment::~DistributeTestEnvironment() @@ -136,12 +134,12 @@ int DistributeTestEnvironment::ConnectAgent(size_t devNo) std::this_thread::sleep_for(std::chrono::milliseconds(SLEEP_TIME)); // delay 10ms } if (connectCount >= CONNECT_TIME) { - HiLog::Error(LABEL, "connect to agent %s fail.", serverIp.c_str()); + HiLog::Error(DistributeTestEnvironment::LABEL, "connect to agent %s fail.", serverIp.c_str()); close(clientSockFd); clientSockFd = -1; return 0; } - HiLog::Info(LABEL, "connect to agent %s success.", serverIp.c_str()); + HiLog::Info(DistributeTestEnvironment::LABEL, "connect to agent %s success.", serverIp.c_str()); clientList_[devNo].fd = clientSockFd; return 1; } @@ -172,11 +170,11 @@ bool DistributeTestEnvironment::SendToAgent(size_t devNo, int cmdType, void *pst bool breturn = false; devNo = devNo - 1; if (devNo >= clientList_.size()) { - HiLog::Info(LABEL, "can not find no %zu device.", devNo); + HiLog::Info(DistributeTestEnvironment::LABEL, "can not find no %zu device.", devNo); return breturn; } if (clientList_[devNo].fd <= 0) { - HiLog::Info(LABEL, "connect is failure %zu device.", devNo); + HiLog::Info(DistributeTestEnvironment::LABEL, "connect is failure %zu device.", devNo); return breturn; } if (pstrMsg == nullptr) { @@ -190,7 +188,7 @@ bool DistributeTestEnvironment::SendToAgent(size_t devNo, int cmdType, void *pst 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."); + HiLog::Error(DistributeTestEnvironment::LABEL, "agent socket is closed."); return breturn; } // get ret value ; @@ -209,7 +207,7 @@ bool DistributeTestEnvironment::SendToAgent(size_t devNo, int cmdType, void *pst continue; } recv(clientList_[devNo].fd, pCmdTest->alignmentCmd, pCmdTest->len, 0); - HiLog::Info(LABEL, "recv agent data : No.%d command type :%d length :%d", + HiLog::Info(DistributeTestEnvironment::LABEL, "recv agent data : No.%d command type :%d length :%d", pCmdTest->no, pCmdTest->cmdTestType, pCmdTest->len); if ((globalCommandNo == pCmdTest->no) && (cmdType == pCmdTest->cmdTestType)) { // get ret value ; @@ -220,12 +218,13 @@ bool DistributeTestEnvironment::SendToAgent(size_t devNo, int cmdType, void *pst } break; } else { - HiLog::Error(LABEL, "get error message. type is :%d", pCmdTest->cmdTestType); + HiLog::Error(DistributeTestEnvironment::LABEL, "get error message. type is :%d", + pCmdTest->cmdTestType); } } else { if (!rlen) { // peer socket is closed. - HiLog::Error(LABEL, "device socket close."); + HiLog::Error(DistributeTestEnvironment::LABEL, "device socket close."); break; } } @@ -284,7 +283,7 @@ bool DistributeTestEnvironment::RunTestCmd(size_t devNo, const std::string &strC pCmdTest->len = lenptr; breturn = SendToAgent(devNo, DST_COMMAND_CALL, pCmdTest, pCmdTest->len, onProcessReturn); } else { - HiLog::Error(LABEL, "command data is too long \n"); + HiLog::Error(DistributeTestEnvironment::LABEL, "command data is too long \n"); } return breturn; }; @@ -304,7 +303,7 @@ bool DistributeTestEnvironment::SendMessage(size_t devNo, const std::string &str pCmdTest->len = msgLen; breturn = SendToAgent(devNo, DST_COMMAND_MSG, pCmdTest, msgLen, onProcessReturnMsg); } else { - HiLog::Info(LABEL, "message data is too long.\n"); + HiLog::Info(DistributeTestEnvironment::LABEL, "message data is too long.\n"); } return breturn; } @@ -329,7 +328,7 @@ bool DistributeTestEnvironment::Notify(size_t devNo, const std::string &strMsg, pCmdTest->len = msgLen; breturn = SendToAgent(devNo, DST_COMMAND_NOTIFY, pCmdTest, msgLen, nullptr); } else { - HiLog::Info(LABEL, "notify data is too long.\n"); + HiLog::Info(DistributeTestEnvironment::LABEL, "notify data is too long.\n"); } return breturn; } @@ -449,7 +448,7 @@ bool DistributeTest::SendMessage(AGENT_NO devNo, const std::string &msg, int len if (g_pDistributetestEnv != nullptr) { return g_pDistributetestEnv->SendMessage(devNo, msg, len, [&](const std::string &szreturnbuf, int rlen)->bool { - HiLog::Info(LABEL, "onprocessmsg len :%d.", rlen); + HiLog::Info(DistributeTestEnvironment::LABEL, "onprocessmsg len :%d.", rlen); return OnMsgProc(szreturnbuf, rlen); }); } diff --git a/aw/cxx/distributed/distributed_major.h b/aw/cxx/distributed/distributed_major.h index cb913a61344f74ce4f3bd70aa9f35d0e4c6961cb..aa68855ebf31217493303255c6f14d53e10cb064 100644 --- a/aw/cxx/distributed/distributed_major.h +++ b/aw/cxx/distributed/distributed_major.h @@ -29,6 +29,7 @@ #include "distributed_cfg.h" #include "gtest/gtest.h" +#include "hilog/log.h" namespace OHOS { namespace DistributeSystemTest { @@ -54,6 +55,8 @@ public: std::vector clientList_; + static constexpr HiviewDFX::HiLogLabel LABEL = {LOG_CORE, 0xD001690, "DistributeTestEnvironment"}; + private: DistributedCfg clientCfg_; int serverPort_; diff --git a/aw/python/distributed/distribute/distribute.py b/aw/python/distributed/distribute/distribute.py index 37f7f2a92399847b8402b6ca5f7f5cf13bab5647..a4083f022a0d424c79ceb905e1ee4a03d14d2691 100755 --- a/aw/python/distributed/distribute/distribute.py +++ b/aw/python/distributed/distribute/distribute.py @@ -235,7 +235,7 @@ class Distribute: return "" isemulator = re.findall('readonly', str(output)) - output = device.shell_with_output("ifconfig") + output = device.shell_with_output("ifconfig waln0") if output == "": return ""