From 3d02b79bbda24552ca7dc7925a9062fc5f0e14db Mon Sep 17 00:00:00 2001 From: hwb0703 Date: Tue, 18 May 2021 09:36:12 +0800 Subject: [PATCH] modify readme and code style --- BUILD.gn | 1 + README.md | 47 +++++++++++-- README_zh.md | 41 ++++++++++- aw/cxx/distributed/BUILD.gn | 6 +- aw/cxx/hwext/perf.cpp | 11 ++- .../junit/distribute/ISocketObserver.java | 2 +- aw/python/distributed/__init__.py | 4 ++ config/build_config.xml | 18 ++--- config/filter_config.xml | 58 ++++++++-------- examples/sleep/include/sleep_ex.h | 1 - .../sleep/test/xDevice_test_report_demo.xml | 69 +++---------------- .../src/com/ohos/utils/StringUtils.java | 5 +- .../sleep/spent_time_test/baseline.xml | 25 ++----- .../java/src/ohos/unittest/CaseLevel.java | 2 +- .../java/src/ohos/unittest/CaseType.java | 2 +- .../common/java/src/ohos/unittest/Level.java | 2 +- .../java/src/ohos/unittest/TestTarget.java | 2 +- .../common/java/src/ohos/unittest/Type.java | 2 +- .../java/src/ohos/unittest/perf/BaseLine.java | 2 +- .../ohos/unittest/perf/BaseLineParser.java | 2 +- .../src/ohos/unittest/perf/PerfVerify.java | 2 +- .../ohos/unittest/perf/VerifySingleton.java | 2 +- 22 files changed, 159 insertions(+), 147 deletions(-) diff --git a/BUILD.gn b/BUILD.gn index 93dfa9c..599b35d 100755 --- a/BUILD.gn +++ b/BUILD.gn @@ -11,6 +11,7 @@ # See the License for the specific language governing permissions and # limitations under the License. + group("make_temp_test") { testonly = true deps = [] diff --git a/README.md b/README.md index 557792a..20a010a 100755 --- a/README.md +++ b/README.md @@ -158,13 +158,31 @@ The Python environment is required. ``` -- Configure the developers test module +- Configure the developers test module. - in the configuration file **developertest/config/user\_config.xml**. + Configuration file: **developertest/config/user\_config.xml** - 1. For devices that support the Harmony device connector \(hdc\), modify the configuration file as follows: + 1. Modify basic configuration parameters. - Between the **** tags with the **"usb-hdc"** attribute, configure the test device IP address and the matched hdc port. For example + \[build\] \# Set build parameters of the test case. + + ``` + + false + false + true + ... ... + + ``` + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >**example**: whether to build the test case example. The default value is **false**. + >**version**: whether to build the test version. The default value is **false**. + >**testcase**: whether to build the test case. The default value is **true**. + + 2. For devices that support the Harmony device connector \(hdc\), modify the configuration file as follows: + + \[device\] \# Configure the device information with the **"usb-hdc"** attribute, including the test device IP address and the matched hdc port. ``` @@ -174,9 +192,26 @@ The Python environment is required. ``` - 2. For devices that only support the serial port connection, modify the configuration file as follows: + 3. For devices that support serial port connection only, modify the configuration file as follows: + + \[board\_info\] \# Configure development board information. + + ``` + + hispark + taurus + ipcamera + hb build + + ``` + + >![](public_sys-resources/icon-note.gif) **NOTE:** + >**board\_series**: development board series. The default value is **hispark**. + >**board\_type**: development board type. The default value is **taurus**. + >**board\_product**: target product. The default value is **ipcamera**. + >**build\_command**: command used for building the test version and test case. The default value is **hb build**. - Between the **** tags with the **"ipcamera"** attribute, configure the serial port information, including the COM port and baud rate. For example: + \[device\] \# Configure the serial port information with the **"ipcamera"** attribute, including the COM port and baud rate. For example: ``` diff --git a/README_zh.md b/README_zh.md index ee4f588..1187e67 100755 --- a/README_zh.md +++ b/README_zh.md @@ -166,7 +166,26 @@ developertest/ 文件:developertest/config/user\_config.xml - 1. 支持hdc连接的被测设备。 + 1. 测试框架通用配置。 + + \[build\] \# 配置测试用例的编译参数,例如: + + ``` + + false + false + true + ... ... + + ``` + + >![](public_sys-resources/icon-note.gif) **说明:** + >测试用例的编译参数说明如下: + >example:是否编译测试用例示例,默认false。 + >version:是否编译测试版本,默认false。 + >testcase:是否编译测试用例,默认true。 + + 2. 支持hdc连接的被测设备。 \[device\] \# 配置标签为usb-hdc的环境信息,测试设备的IP地址和hdc映射的端口号,例如: @@ -178,7 +197,25 @@ developertest/ ``` - 2. 仅支持串口的被测设备。 + 3. 仅支持串口的被测设备。 + + \[board\_info\] \# 开发板配置信息,例如: + + ``` + + hispark + taurus + ipcamera + hb build + + ``` + + >![](public_sys-resources/icon-note.gif) **说明:** + >开发板配置信息如下: + >board\_series:开发板系列,默认hispark。 + >board\_type:开发板类型,默认taurus。 + >board\_product:目标产品,默认ipcamera。 + >build\_command:测试版本和用例的编译命令,默认hb build。 \[device\] \# 配置标签为ipcamera的串口信息,COM口和波特率,例如: diff --git a/aw/cxx/distributed/BUILD.gn b/aw/cxx/distributed/BUILD.gn index 250c023..68888e0 100755 --- a/aw/cxx/distributed/BUILD.gn +++ b/aw/cxx/distributed/BUILD.gn @@ -32,6 +32,10 @@ ohos_static_library("distributedtest_lib") { "//third_party/googletest:gtest", "//utils/native/base:utils", ] - external_deps = [ "hilog:libhilog" ] + if (is_standard_system) { + external_deps = [ "hiviewdfx_hilog_native:libhilog" ] + } else { + external_deps = [ "hilog:libhilog" ] + } public_configs = [ ":distributedtest_config" ] } diff --git a/aw/cxx/hwext/perf.cpp b/aw/cxx/hwext/perf.cpp index 63e0c98..e1414a5 100755 --- a/aw/cxx/hwext/perf.cpp +++ b/aw/cxx/hwext/perf.cpp @@ -28,11 +28,8 @@ namespace TestAW { #define ERR_MSG(...) fprintf(stderr, __VA_ARGS__) #define INF_MSG(...) fprintf(stdout, __VA_ARGS__) -#if 0 -#define DBG_MSG(...) fprintf(stdout,__VA_ARGS__) -#else -#define DBG_MSG(...) -#endif +#define DBG_MSG(...) fprintf(stdout, __VA_ARGS__) + #define ID_LARGER_IS_BETTER true #define ID_SMALLER_IS_BETTER false #define _max(a,b) (((a)>=(b)) ? (a) : (b) ) @@ -152,7 +149,7 @@ double BaseLineManager::StrToDouble(const string& str) bool BaseLineManager::GetExtraValueDouble(const string testcaseName, const string extra, double &value) { if (testcaseName == "" || extra == "") { - DBG_MSG("[ ERROR ] invalid arguments: testcaseName=%s, extra=%s\n", testcaseName.c_str(), extra); + DBG_MSG("[ ERROR ] invalid arguments: testcaseName=%s, extra=%s\n", testcaseName.c_str(), extra.c_str()); return false; } @@ -238,7 +235,7 @@ bool GtestPerfTestCase::Initialize() m_bHasFloatRange = m_pManager->GetExtraValueDouble(m_strCaseName, "floatrange", m_dbFloatRange); // check values is valid, and update them. if (m_bHasFloatRange && (m_dbFloatRange < 0 || m_dbFloatRange >= 1)) { - DBG_MSG("[ ERROR ] %s has invalid float range: %f.\n", m_strCaseName, m_dbFloatRange); + DBG_MSG("[ ERROR ] %s has invalid float range: %f.\n", m_strCaseName.c_str(), m_dbFloatRange); m_bHasFloatRange = false; } diff --git a/aw/java/distributed/src/ohos/junit/distribute/ISocketObserver.java b/aw/java/distributed/src/ohos/junit/distribute/ISocketObserver.java index b62ca0f..c30e52d 100755 --- a/aw/java/distributed/src/ohos/junit/distribute/ISocketObserver.java +++ b/aw/java/distributed/src/ohos/junit/distribute/ISocketObserver.java @@ -16,7 +16,7 @@ package ohos.junit.distribute; /** - * Client for distribute socket + * Client for distributed socket */ public interface ISocketObserver { /** diff --git a/aw/python/distributed/__init__.py b/aw/python/distributed/__init__.py index 58269f6..9f9f21b 100755 --- a/aw/python/distributed/__init__.py +++ b/aw/python/distributed/__init__.py @@ -16,8 +16,12 @@ # limitations under the License. # +import os +import sys + from distributed.common.common import get_resource_dir from distributed.common.common import get_result_dir from distributed.common.common import create_empty_result_file +from distributed.distribute.distribute import Distribute from distributed.common.manager import DeviceManager diff --git a/config/build_config.xml b/config/build_config.xml index 2c32493..a6d3680 100755 --- a/config/build_config.xml +++ b/config/build_config.xml @@ -1,4 +1,4 @@ - + - - + + diff --git a/config/filter_config.xml b/config/filter_config.xml index dbceb46..4c640fe 100755 --- a/config/filter_config.xml +++ b/config/filter_config.xml @@ -1,4 +1,4 @@ - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/examples/sleep/include/sleep_ex.h b/examples/sleep/include/sleep_ex.h index 80d980a..d6ca5b3 100755 --- a/examples/sleep/include/sleep_ex.h +++ b/examples/sleep/include/sleep_ex.h @@ -14,7 +14,6 @@ */ #include -#include #include #include diff --git a/examples/sleep/test/xDevice_test_report_demo.xml b/examples/sleep/test/xDevice_test_report_demo.xml index 0216e36..09c8ed0 100755 --- a/examples/sleep/test/xDevice_test_report_demo.xml +++ b/examples/sleep/test/xDevice_test_report_demo.xml @@ -1,4 +1,4 @@ - + - - - - - - - - - + + + + + + + + + diff --git a/examples/string_utils/src/com/ohos/utils/StringUtils.java b/examples/string_utils/src/com/ohos/utils/StringUtils.java index 17ee9cd..13df18c 100755 --- a/examples/string_utils/src/com/ohos/utils/StringUtils.java +++ b/examples/string_utils/src/com/ohos/utils/StringUtils.java @@ -12,11 +12,11 @@ * See the License for the specific language governing permissions and * limitations under the License. */ + package com.ohos.utils; import java.util.Locale; - /** * handle string method */ @@ -33,7 +33,6 @@ public class StringUtils { if (str == null) { return EMPTY_STRING; } - return str.toLowerCase(Locale.getDefault()); } @@ -47,7 +46,6 @@ public class StringUtils { if (str == null) { return EMPTY_STRING; } - return str.toUpperCase(Locale.getDefault()); } @@ -61,7 +59,6 @@ public class StringUtils { if (str == null) { return EMPTY_STRING; } - return new StringBuffer(str).reverse().toString(); } } diff --git a/examples/test/resource/sleep/spent_time_test/baseline.xml b/examples/test/resource/sleep/spent_time_test/baseline.xml index 2c1628b..579d5fe 100755 --- a/examples/test/resource/sleep/spent_time_test/baseline.xml +++ b/examples/test/resource/sleep/spent_time_test/baseline.xml @@ -1,4 +1,4 @@ - + - - - - - + + + + + diff --git a/libs/jtr/common/java/src/ohos/unittest/CaseLevel.java b/libs/jtr/common/java/src/ohos/unittest/CaseLevel.java index 0361342..26f6581 100755 --- a/libs/jtr/common/java/src/ohos/unittest/CaseLevel.java +++ b/libs/jtr/common/java/src/ohos/unittest/CaseLevel.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/CaseType.java b/libs/jtr/common/java/src/ohos/unittest/CaseType.java index 918db59..717847d 100755 --- a/libs/jtr/common/java/src/ohos/unittest/CaseType.java +++ b/libs/jtr/common/java/src/ohos/unittest/CaseType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/Level.java b/libs/jtr/common/java/src/ohos/unittest/Level.java index 95560e1..df5a081 100755 --- a/libs/jtr/common/java/src/ohos/unittest/Level.java +++ b/libs/jtr/common/java/src/ohos/unittest/Level.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/TestTarget.java b/libs/jtr/common/java/src/ohos/unittest/TestTarget.java index 1918f9f..1a95bbe 100755 --- a/libs/jtr/common/java/src/ohos/unittest/TestTarget.java +++ b/libs/jtr/common/java/src/ohos/unittest/TestTarget.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/Type.java b/libs/jtr/common/java/src/ohos/unittest/Type.java index 7f929ea..0d4a842 100755 --- a/libs/jtr/common/java/src/ohos/unittest/Type.java +++ b/libs/jtr/common/java/src/ohos/unittest/Type.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/perf/BaseLine.java b/libs/jtr/common/java/src/ohos/unittest/perf/BaseLine.java index 6f88c67..5d66ded 100755 --- a/libs/jtr/common/java/src/ohos/unittest/perf/BaseLine.java +++ b/libs/jtr/common/java/src/ohos/unittest/perf/BaseLine.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/perf/BaseLineParser.java b/libs/jtr/common/java/src/ohos/unittest/perf/BaseLineParser.java index c0f8f89..1504953 100755 --- a/libs/jtr/common/java/src/ohos/unittest/perf/BaseLineParser.java +++ b/libs/jtr/common/java/src/ohos/unittest/perf/BaseLineParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/perf/PerfVerify.java b/libs/jtr/common/java/src/ohos/unittest/perf/PerfVerify.java index 5c061c2..3d0222f 100755 --- a/libs/jtr/common/java/src/ohos/unittest/perf/PerfVerify.java +++ b/libs/jtr/common/java/src/ohos/unittest/perf/PerfVerify.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 diff --git a/libs/jtr/common/java/src/ohos/unittest/perf/VerifySingleton.java b/libs/jtr/common/java/src/ohos/unittest/perf/VerifySingleton.java index 3138c08..adb3851 100755 --- a/libs/jtr/common/java/src/ohos/unittest/perf/VerifySingleton.java +++ b/libs/jtr/common/java/src/ohos/unittest/perf/VerifySingleton.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020 Huawei Device Co., Ltd. + * 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 -- Gitee