未验证 提交 d2f3bb01 编写于 作者: O openharmony_ci 提交者: Gitee

!90 Modified the File

Merge pull request !90 from stivn/master
......@@ -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.
......
......@@ -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<struct sockaddr *>(&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<struct sockaddr *>(&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<unsigned long>(cmdLen) < DST_COMMAND_HEAD_LEN) {
if (cmdLen == 0) {
int recvCmdLen = recv(clientSockFd_, buff, DST_COMMAND_HEAD_LEN, 0);
if (static_cast<unsigned long>(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;
......
......@@ -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<DistributedCfg>& GetInstance();
......
......@@ -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<struct sockaddr *>(&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<DistributedMsg *>(pstrMsg);
pCmdTest->no = globalCommandNo;
pCmdTest->cmdTestType = htons(cmdType);
pCmdTest->len = htons(len);
int rlen = send(clientList_[devNo].fd, pCmdTest, static_cast<size_t>(len + DST_COMMAND_HEAD_LEN), 0);
auto pCmdMsg = reinterpret_cast<DistributedMsg *>(pstrMsg);
pCmdMsg->no = globalCommandNo;
pCmdMsg->cmdTestType = htons(cmdType);
pCmdMsg->len = htons(len);
int rlen = send(clientList_[devNo].fd, pCmdMsg, static_cast<size_t>(len + DST_COMMAND_HEAD_LEN), 0);
if (rlen <= 0) {
HiLog::Error(LABEL, "agent socket is closed.");
return breturn;
......
......@@ -19,7 +19,7 @@
#include <string>
#include <list>
#include <map>
#include <time.h>
#include <ctime>
#include "securec.h"
#include <gtest/gtest.h>
......
{
"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"
]
}
}
}
......@@ -12,10 +12,12 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include <iostream>
#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
......@@ -13,7 +13,6 @@
* limitations under the License.
*/
#include <iostream>
int Add(int e1, int e2)
{
......
......@@ -13,10 +13,8 @@
* limitations under the License.
*/
#include "parse_fuzzer.h"
#include <stddef.h>
#include <stdint.h>
#include <cstddef>
#include <cstdint>
const int FUZZ_DATA_LEN = 3;
const int FUZZ_FST_DATA = 0;
......
......@@ -13,11 +13,9 @@
* limitations under the License.
*/
#include <cstdint>
#include <unistd.h>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <fcntl.h>
#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
......@@ -13,7 +13,11 @@
* limitations under the License.
*/
#ifndef _EXAMPLE_DETECTOR_H_
#define _EXAMPLE_DETECTOR_H_
#include <stdio.h>
bool IsPrime(int n);
bool FileExist(const char* fileName);
#endif // _EXAMPLE_DETECTOR_H_
\ No newline at end of file
......@@ -13,10 +13,11 @@
* limitations under the License.
*/
#include <sys/socket.h>
#include <string>
#include <unistd.h>
#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
......@@ -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<double>(x->tv_sec * SleepTest::ID_MS_TO_NS_LEVEL)
+ reinterpret_cast<double>(x->tv_usec);
double yUs = reinterpret_cast<double>(y->tv_sec * SleepTest::ID_MS_TO_NS_LEVEL)
+ reinterpret_cast<double>(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<int>(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;
......
{
"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"
]
}
}
}
......@@ -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:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册