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

!94 Modified the codes

Merge pull request !94 from stivn/master
......@@ -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 <iostream>
#include "securec.h"
......@@ -50,4 +50,4 @@ using DistDeviceInfo = DistDevInfo;
} // namespace DistributeSystemTest
} // namespace OHOS
#endif // _DISTRIBUTED_H_
#endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_H_
......@@ -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,8 @@ int DistributedAgent::DoCmdServer(int serverSockFd)
auto pclinereturn = reinterpret_cast<DistributedMsg *>(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",
......@@ -413,4 +418,4 @@ int DistributedAgent::Stop()
return 0;
}
} // namespace DistributeSystemTest
} // namespace OHOS
\ No newline at end of file
} // namespace OHOS
......@@ -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 <map>
#include <vector>
......@@ -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_
......@@ -160,4 +160,4 @@ std::unique_ptr<DistributedCfg>& DistributedCfg::GetInstance()
std::unique_ptr<DistributedCfg> DistributedCfg::getCfg_ = nullptr;
} // namespace DistributeSystemTest
} // namespace OHOS
\ No newline at end of file
} // namespace OHOS
......@@ -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 <map>
#include <iostream>
......@@ -52,4 +52,5 @@ private:
};
} // namespace DistributeSystemTest
} // namespace OHOS
#endif
\ No newline at end of file
#endif // AW_CXX_DISTRIBUTED_DISTRIBUTED_CFG_H_
......@@ -504,4 +504,4 @@ bool DistributeTest::Notify(AGENT_NO devNo, const std::string &notifyType, const
return false;
}
} // namespace DistributeSystemTest
} // namespace OHOS
\ No newline at end of file
} // namespace OHOS
......@@ -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 <vector>
#include <map>
......@@ -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<std::string> 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_
......@@ -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 <iostream>
#include <vector>
#include <string>
......@@ -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_
......@@ -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
......@@ -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 <string>
#include <list>
......@@ -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_
......@@ -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)
......
......@@ -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));
}
......@@ -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
}
......@@ -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_
......@@ -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<int*> (pMsec);
for (int index = 0; index < msec; index++) {
Msleep(1);
}
......
......@@ -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" ]
}
```
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册