提交 063ce27b 编写于 作者: S stivn

Modified

Signed-off-by: Nstivn <sunteng10@huawei.com>
上级 70562192
/*
* 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<unsigned long>(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;
......
......@@ -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<struct sockaddr *>(&addr), sizeof(addr)) == 0) {
if (!connect(clientSockFd, reinterpret<struct sockaddr *>(&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;
......
......@@ -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 << " <testcase name=\""<< vecLines_.at(i)
<<"\" status=\"run\" time=\"\" classname=\"" << fileName_ << "\" level=\"3\">" << std::endl;
xmlOut << " <failure message=\"NULL\"></failure>"<< std::endl;
......
......@@ -103,7 +103,7 @@ bool BaseLineManager::ReadXmlFile(string baselinePath)
xmlNodePtr ptrRootNode = xmlDocGetRootElement(ptrXmlDoc);
if (ptrRootNode == nullptr || ptrRootNode->name == nullptr ||
xmlStrcmp(ptrRootNode->name, reinterpret_cast<const xmlChar*>(XML_TAG_ROOT)) != 0) {
xmlStrcmp(ptrRootNode->name, reinterpret_cast<const xmlChar*>(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<string, string> 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;
}
......
......@@ -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;
}
......
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
......@@ -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));
}
......@@ -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");
......
/*
* 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<AppKvStore> 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) {
......
/*
* 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
......
# 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
......
......@@ -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
......
<!--
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.
-->
<!DOCTYPE html>
<html lang="en">
<head>
......
<!--
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.
-->
<!DOCTYPE html>
<html lang="en">
<head>
......
......@@ -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") {
......
......@@ -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)
......
#!/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
......@@ -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
......
......@@ -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):
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册