From 5f0d1b39b381690a47491edf51db2958dc7471ef Mon Sep 17 00:00:00 2001 From: stivn Date: Sat, 11 Sep 2021 17:41:01 +0800 Subject: [PATCH 1/8] modify DCO Signed-off-by: stivn --- DCO.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DCO.txt b/DCO.txt index b3e5605c27e..3f70bb332b9 100644 --- a/DCO.txt +++ b/DCO.txt @@ -1,4 +1,4 @@ -Developer Certificate of Origin +Developer Certificate of Origin 开发者原创声明 Version 1.1 第1.1版 -- Gitee From de98ebc42b7d2c812d9f27a70bc8b104d92de4dd Mon Sep 17 00:00:00 2001 From: stivn Date: Sat, 11 Sep 2021 18:02:50 +0800 Subject: [PATCH 2/8] Input Environment configuration of developertest Signed-off-by: stivn --- .../guide/environment configuration.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 zh-cn/device-dev/guide/environment configuration.md diff --git a/zh-cn/device-dev/guide/environment configuration.md b/zh-cn/device-dev/guide/environment configuration.md new file mode 100644 index 00000000000..0b476c718cf --- /dev/null +++ b/zh-cn/device-dev/guide/environment configuration.md @@ -0,0 +1,74 @@ +# 环境配置 +## 测试框架基础环境依赖 +|环境依赖|操作系统|Linux系统扩展组件|Python|Python插件|NFS Server| +|------------|------------|------------|------------|------------|------------| +|版本型号|Ubuntu18.04|libreadline-dev|3.7.5版本以上|pyserial 3.3以上、paramiko2.7.1以上、setuptools40.8.0以上、rsa4.0以上|haneWIN NFS Server 1.2.50及以上或者 NFSSv4及以上| +|详细说明|代码编译环境|命令行读取插件|测试框架语言 |pyserial:支持Python的串口通信;paramiko:支持Python使用SSH协议;setuptools:支持Python方便创建和分发Python包;rsa:支持Python rsa加密 |支持设备通过串口连接| +## 安装流程 +1. 安装Linux扩展组件readline,安装命令如下: +``` +sudo apt-get install libreadline-dev +``` +安装成功提示 +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +libreadline-dev is already the newest version (7.0-3). +0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. +``` +2. 安装setuptools插件,安装命令如下: +``` +pip3 install setuptools +``` +安装成功提示如下: +``` +Requirement already satisfied: setuptools in d:\programs\python37\lib\site-packages (41.2.0) +``` +3. 安装paramiko插件,安装命令如下: +``` +pip3 install paramiko +``` +安装成功提示如下: +``` +Installing collected packages: pycparser, cffi, pynacl, bcrypt, cryptography, paramiko +Successfully installed bcrypt-3.2.0 cffi-1.14.4 cryptography-3.3.1 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 +``` +4. 安装python的rsa插件,安装命令如下: +``` +pip3 install rsa +``` +安装成功截图如下: +``` +Installing collected packages: pyasn1, rsa +Successfully installed pyasn1-0.4.8 rsa-4.7 +``` +5. 需要本地的python安装串口插件pyserial,安装命令如下: +``` +pip3 install pyserial +``` +安装成功提示如下: +``` +Requirement already satisfied: pyserial in d:\programs\python37\lib\site-packages\pyserial-3.4-py3.7.egg (3.4) +``` +6. 如果设备仅支持串口输出测试结果,则需要安装NFS Server +- windows环境下安装,例如安装haneWIN NFS Server1.2.50。 +- Linux环境下安装,安装命令如下: +``` +sudo apt install nfs-kernel-server +``` +安装成功提示如下: +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +nfs-kernel-server is already the newest version (1:1.3.4-2.1ubuntu5.3). +0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. +``` +## 检验环境 + +| 检查项 |操作 |满足环境 | +| --- | --- | --- | +| 检查python安装与否 |命令行窗口执行命令:python --version |版本不小于3.7.5即可 | +| 检查python扩展插件安装与否 |打开test/xdevice目录,执行run.bat或run.sh| 可进入提示符“>>>”界面即可 | +|检查NFS Server启动状态(被测设备仅支持串口时检测) |通过串口登录开发板,执行mount命令挂载NFS |可正常挂载文件目录即可 | \ No newline at end of file -- Gitee From 21a6740df868bf4cef095f1e1a6dd57937ea989b Mon Sep 17 00:00:00 2001 From: stivn <9699603+stivn@user.noreply.gitee.com> Date: Sat, 11 Sep 2021 10:17:18 +0000 Subject: [PATCH 3/8] =?UTF-8?q?=E5=88=A0=E9=99=A4=E6=96=87=E4=BB=B6=20DCO.?= =?UTF-8?q?txt?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DCO.txt | 39 --------------------------------------- 1 file changed, 39 deletions(-) delete mode 100644 DCO.txt diff --git a/DCO.txt b/DCO.txt deleted file mode 100644 index 3f70bb332b9..00000000000 --- a/DCO.txt +++ /dev/null @@ -1,39 +0,0 @@ -Developer Certificate of Origin -开发者原创声明 -Version 1.1 -第1.1版 - -Copyright (C) 2004, 2006 The Linux Foundation and its contributors. -版权所有(C)2004,2006 Linux基金会及其贡献者。 -1 Letterman Drive -莱特曼大道1号 -Suite D4700 -D4700室 -San Francisco, CA, 94129 -加利福尼亚州旧金山市94129 - -Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. -任何人均可复制和分发本许可文件副本,但不得修改。 -*************************************************** - -Developer's Certificate of Origin 1.1 -开发者原创声明(第1.1版) - -By making a contribution to this project, I certify that: -在向本项目提交贡献之时,本人声明: - -(a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or -(a) 该贡献全部或部分由本人创作,且本人有权根据当前文件中所示的开源许可证提交;或 - -(b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or -(b) 尽本人所知,该贡献所基于的在先作品已经过适当的开源许可证授权,且根据该开源许可证,本人有权在相同开源许可证(如当前文件中所示)下提交该修改后的作品(除非本人被允许根据不同的许可证提交),不论其是否全部或部分由本人创作;或 - -(c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. -(c) 该贡献是由作出(a)、(b) 或(c) 声明的其他人直接提供给本人,且本人未对其进行修改。 - -(d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. -(d) 本人理解并同意,本项目及贡献是公开的,且贡献(包括本人随附提交的全部个人信息,含本人签字)将被无限期存档,并可以与本项目或所涉开源许可证保持一致的情形下再被分发。 - -*************************************************** -Above Chinese version of the Developer's Certificate of Origin is translated by the OpenAtom Foundation. -以上开发者原创声明中文版本由开放原子开源基金会翻译。 -- Gitee From 77aa0b086d5c925e2bdebb2233a5f71f8b76bfa7 Mon Sep 17 00:00:00 2001 From: stivn Date: Sat, 11 Sep 2021 18:02:50 +0800 Subject: [PATCH 4/8] Input Environment configuration of developertest Signed-off-by: stivn --- ...25\345\255\220\347\263\273\347\273\237.md" | 1218 ++++++++++------- 1 file changed, 761 insertions(+), 457 deletions(-) diff --git "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" index 65aaa9d5e90..192b2d34b35 100755 --- "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" @@ -1,527 +1,831 @@ -# 测试子系统 +# 测试子系统 +OpenHarmony为开发者提供了一套全面的自测试框架,开发者可根据自己测试需求开发相关测试用例,以在开发阶段提前发现缺陷,大幅度提高代码质量。 -- [简介](#section7375710115617) -- [目录](#section102031353175317) -- [约束](#section87444710110) -- [安装](#section1347156474) -- [编写测试用例](#section125411936102918) -- [使用测试框架](#section75882026185016) -- [测试结果与日志](#section414715805819) -- [涉及仓](#section6299103515474) - -## 简介 - -开发过程采用测试驱动开发模式,开发者基于系统新增特性可以通过开发者自己开发用例保证,对于系统已有特性的修改,也可通过修改项目中原有的测试用例保证,开发者测试旨在帮助开发者在开发阶段就能开发出高质量代码。 - -## 目录 +本文从基础环境构建,用例开发,编译以及执行等方面介绍Harmony测试框架如何运行和使用。 +## 1.基础环境构建 +测试框架依赖于Python运行环境,在使用测试框架之前可参阅以下方式进行配置。 + - [\[环境配置\]]() + - [\[源码获取\]](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/get-code/sourcecode-acquire.md) +## 2 测试框架目录简介 ``` -test/ -├── developertest # 开发者测试框架 -│ ├── aw # 测试框架的静态库 -│ ├── config # 测试框架配置 -│ ├── examples # 测试用例示例 -│ ├── src # 测试框架源码 -│ ├── third_party # 测试框架依赖第三方组件适配 -│ ├── start.bat # 开发者测试入口(Windows) -│ ├── start.sh # 开发者测试入口(Linux) -│ └── BUILD.gn # 测试框架编译入口 -├── xdevice # 测试框架基础组件 -│ ├── config # 框架配置文件 -│ ├── extension # 基础组件扩展仓 -│ ├── resource # 基础组件测试资源 -│ └── src # 基础组件源码 -└── xts # XTS认证套件 +test # 测试子系统 +├── developertest # 开发者测试组件 +│ ├── aw # 测试框架的静态库 +│ ├── config # 测试框架配置 +│ │ │ ... +│ │ └── user_config.xml # 用户使用配置 +│ ├── examples # 测试用例示例 +│ ├── src # 测试框架源码 +│ ├── third_party # 测试框架依赖第三方组件适配 +│ ├── reports # 测试结果报告 +│ ├── BUILD.gn # 测试框架编译入口 +│ ├── start.bat # 开发者测试入口(Windows) +│ └── start.sh # 开发者测试入口(Linux) +└── xdevice # 测试框架依赖组件 ``` +## 3 测试用例编写 +### 3.1 测试用例目录规划 +``` +subsystem # 子系统 +├── partA # 部件A +│ ├── moduleA # 模块A +│ │ ├── include +│ │ ├── src # 业务代码 +│ │ └── test # 测试目录 +│ │ ├── unittest # 单元测试 +│ │ │ ├── common # 公共用例 +│ │ │ │ ├── BUILD.gn # 测试用例编译配置 +│ │ │ │ ├── testA_test.cpp # 单元测试用例源码 +│ │ │ ├── phone # 手机形态用例 +│ │ │ ├── ivi # 车机形态 +│ │ │ └── liteos-a # ipcamera使用liteos内核时的用例 +│ │ └── resource # 依赖资源 +│ │ └── ohos_test.xml +│ ├── moduleB +│ ├── test +│ │ └── moduletest # 模块测试 +│ │ ├── common +│ │ ├── phone +│ │ ├── ivi +│ │ └── liteos-a +│ │ ... +│ └── ohos_build # 编译入口配置 +... +``` +> **注意:** 测试用例根据不同设备形态差异分为通用用例和非通用用例,建议将通用用例存放在common目录下,非通用用例存放在相应设备形态目录下。 -## 约束 - -测试工具环境依赖 - -1. python版本\>=3.7.5 -2. paramiko版本\>=2.7.1 -3. setuptools版本\>=40.8.0 -4. rsa版本\>=4.0 -5. NFS版本\>=V4,设备不支持hdc连接,支持串口时使用 -6. pyserial版本\>=3.3,设备不支持hdc连接,支持串口时使用 -7. 运行操作系统:Windows版本\>=Win10,Linux为Ubuntu18.04 - -## 安装 - -依赖python环境: - -1. 安装Linux扩展组件readline, - - 执行如下命令如下: - - ``` - sudo apt-get install libreadline-dev - ``` - - 安装成功提示 - - ``` - Reading package lists... Done - Building dependency tree - Reading state information... Done - libreadline-dev is already the newest version (7.0-3). - 0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. - ``` - -2. 安装setuptools插件,安装命令如下: - - ``` - pip3 install setuptools - ``` - - 安装成功提示如下: - - ``` - Requirement already satisfied: setuptools in d:\programs\python37\lib\site-packages (41.2.0) - ``` - -3. 安装paramiko插件,安装命令如下: - - ``` - pip3 install paramiko - ``` - - 安装成功提示如下: - - ``` - Installing collected packages: pycparser, cffi, pynacl, bcrypt, cryptography, paramiko - Successfully installed bcrypt-3.2.0 cffi-1.14.4 cryptography-3.3.1 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 - ``` - -4. 安装python的rsa插件,安装命令如下: - - ``` - pip3 install rsa - ``` - - 安装成功截图如下: - - ``` - Installing collected packages: pyasn1, rsa - Successfully installed pyasn1-0.4.8 rsa-4.7 - ``` - -5. 需要本地的python安装串口插件pyserial,安装命令如下: - - ``` - pip3 install pyserial - ``` - - 安装成功提示如下: - - ``` - Requirement already satisfied: pyserial in d:\programs\python37\lib\site-packages\pyserial-3.4-py3.7.egg (3.4) - ``` - -6. 如果设备仅支持串口输出测试结果,则需要安装NFS Server - - windows环境下安装,例如安装haneWIN NFS Server1.2.50,下载地址:https://www.hanewin.net/nfs-e.htm 。 - - Linux环境下安装,安装命令如下: - - ``` - sudo apt install nfs-kernel-server - ``` - - 安装成功提示如下: - - ``` - Reading package lists... Done - Building dependency tree - Reading state information... Done - nfs-kernel-server is already the newest version (1:1.3.4-2.1ubuntu5.3). - 0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. - ``` - - -## 编写测试用例 - -- 测试用例规范 - - 命名规范 - - 测试用例源文件名称和测试套内容保持一致,测试套与用例之间关系1:N,测试套与测试源文件之间关系1:1,每个源文件全局唯一,格式:\[特性\]\_\[功能\]\_\[子功能1\]\_\[子功能1.1\],子功能支持向下细分。 - - 文件命名采用全小写+下划线方式命名,以test结尾,如demo用例:developertest/examples/calculator。 - - - 测试用例编码规范 - - 开发者测试用例原则上与特性代码编码规范保持一致,另外需要添加必要的用例描述信息,详见[•自测试用例模板](#li2069415903917)。 - - - 测试用例编译配置规范 - - 测试用例采用GN方式编译,配置遵循本开源项目的编译指导[使用](编译构建子系统.md)。 - - -- 测试用例模板 - - 详见测试demo用例:developertest/examples/calculator/test/unittest/common/calculator\_add\_test.cpp。 - -- 测试用例目录规划 - - ``` - subsystem # 子系统,系统组件 - ├── parts # 部件 - │ └── test # 模块测试目录 - │ └── unittest # 单元测试 - │ ├── common # 公共用例 - │ ├── phone # 手机形态用例 - │ └── ivi # 车机形态 - │ └── liteos-a # ipcamera使用liteos内核时的用例 - │ └── moduletest # 模块测试 - │ ├── common - │ ├── phone - │ └── ivi - │ └── liteos-a - └── test # 子系统测试目录 - └── resource # 测试资源 - ├── module - ├── common - ├── phone - ├── ivi - ├── liteos-a - └── systemtest # 系统测试 - ├── common - ├── phone - ├── ivi - ├── liteos-a - ``` - - >![](public_sys-resources/icon-note.gif) **说明:** - >其中phone,ivi,liteos-a仅不同设备形态举例,如区分手机,车机,IPCamera等不同形态设备,对于同一特性在不同开发板上,如果用例没有差异,则用例放置common目录下,如果同一特性,用例区分不同设备形态,可能包含内核差异,芯片平台差异,则用例以目录区分。 - -- 编写测试用例步骤 - 1. 添加测试用例文件头注释信息。 - 2. 引用gtest头文件和ext命名空间。 - 3. 添加被测试类的头文件。 - 4. 定义测试套(测试类)。 - 5. 实现该测试套具体的测试用例,包括用例注释和用例逻辑实现。 - 6. 编写测试用例编译配置。 - - >![](public_sys-resources/icon-note.gif) **说明:** - >\*样例参考: - >仅支持串口设备形态编译示例:developertest/examples/lite/cxx\_demo/test/unittest/common/calc\_subtraction\_test.cpp。 - >支持hdc连接的设备形态编译示例:developertest/examples/calculator/test/unittest/common/calculator\_add\_test.cpp。 - >注意点如下: - >a、SetUp & TearDown是针对该测试套下每条用例执行前和执行后的处理逻辑 - >b、SetUpTestCase & TearDownTestCase是针对该测试套下所有用例执行前和执行后的处理逻辑 - >c、HWTEST的使用:特点:只适合做简单测试(执行不依赖Setup & Teardown)缺点:多个测试场景需要相同数据配置的情况不适用,测试用例之间可能相互影响,不具备独立性 - >d、使用printf函数打印日志 - - -- 编写测试用例编译文件 - - 定义测试用例编译构建目标。 - 1. 添加测试用例编译文件头注释信息。 - 2. 导入测试用例编译模板文件。 - 3. 指定测试用例文件的输出路径。 - 4. 配置测试用例编译依赖包含目录。 - 5. 指定测试用例编译目标输出的文件名称。 - 6. 编写具体的测试用例编译脚本(添加需要参与编译的源文件、配置和依赖 )。 - 7. 对目标测试用例文件进行条件分组(分组名称固定为:unittest/moduletest\)。 - - - 如果存在多个测试套,定义公共编译配置。 - - 将测试用例添加到构建系统中。 - - >![](public_sys-resources/icon-note.gif) **说明:** - >\*样例参考: - >1、仅支持串口设备形态编译示例: - >用例编译配置:developertest/examples/lite/cxx\_demo/test/unittest/common/BUILD.gn - >编译入口配置:developertest/examples/lite/BUILD.gn - >2、支持hdc连接的设备形态编译示例: - >用例编译配置:developertest/examples/calculator/test/unittest/common/BUILD.gn - >编译入口配置:developertest/examples/ohos.build - - -- 编写测试用例资源 - 1. 在部件或者模块的test目录下创建resource目录。 - 2. 在resource目录下创建形态目录,如phone。 - 3. 在设备形态目录下创建一个以模块名命名的文件夹,如testmodule。 - 4. 在模块目录下创建一个ohos\_test.xml文件,文件内容格式如下 - - ``` - - - - - - - - ``` - - 5. 在测试用例的编译配置文件中定义resource\_config\_file,用来指定对应的资源文件ohos\_test.xml。 - - >![](public_sys-resources/icon-note.gif) **说明:** - >如上资源文件功能:将resource目录下的test.txt文件通过hdc push命令推送到被测设备的/data/test/resource目录下。 - - 6. ohos\_test.xml文件标签说明如下: - - >![](public_sys-resources/icon-note.gif) **说明:** - >target\_name:测试单元的名字,通常定义在测试目录的BUILD.gn中。 - >preparer:表示该测试单元执行前执行的动作。 - >cleaner:表示测试单元执行结束后的动作。 - >特别的,src=”res” 表示测试资源位于子系统根目录的resource目录, src=“out“ 表示out/release/$\(子系统名\)目录。 - - -- 测试用例级别定义 - - 基本(Level1) - - 重要(Level2) - - 一般(Level3) - - 生僻(Level4) - - -## 使用测试框架 - -- 可选,安装xdevice组件。 - 1. 以Windows环境为例,打开xdevice安装目录:test/xdevice。 - 2. 打开控制台窗口,执行如下命令: - - ``` - python setup.py install - ``` - - 安装成功如下图: - - ``` - Installed d:\programs\python37\lib\site-packages\xdevice-0.0.0-py3.7.egg - Processing dependencies for xdevice==0.0.0 - Finished processing dependencies for xdevice==0.0.0 - ``` - - -- 必选,developertest组件配置。 - - 文件:developertest/config/user\_config.xml。 - - 1. 测试框架通用配置。 - - \[build\] \# 配置测试用例的编译参数,例如: - - ``` - - false - false - true - ... ... - - ``` +### 3.2 测试用例编写 +本测试框架支持多种语言进行用例编写,针对不同语言提供了不同的模板以供编写参考。 +#### 3.2.1 C++参考示例 +``` +/* + * 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 + * + * 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. + */ + +#include "calculator.h" +#include + +using namespace testing::ext; + +class CalculatorSubTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void CalculatorSubTest::SetUpTestCase(void) +{ + // input testsuit setup step,setup invoked before all testcases +} + +void CalculatorSubTest::TearDownTestCase(void) +{ + // input testsuit teardown step,teardown invoked after all testcases +} + +void CalculatorSubTest::SetUp(void) +{ + // input testcase setup step,setup invoked before each testcases +} + +void CalculatorSubTest::TearDown(void) +{ + // input testcase teardown step,teardown invoked after each testcases +} + +/** + * @tc.name: integer_sub_001 + * @tc.desc: Verify the sub function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(CalculatorSubTest, integer_sub_001, TestSize.Level1) +{ + //step 1:调用函数计算结果 + int actual = Sub(4,0); + //Step 2:使用断言比较预期与计算结果 + EXPECT_EQ(4, actual); +} +``` +详细内容介绍: +1.添加测试用例文件头注释信息 +``` +/* + * 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 + * + * 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. + */ +``` +2.引用测试框架头文件和命名空间 +``` +#include - >![](public_sys-resources/icon-note.gif) **说明:** - >测试用例的编译参数说明如下: - >example:是否编译测试用例示例,默认false。 - >version:是否编译测试版本,默认false。 - >testcase:是否编译测试用例,默认true。 +using namespace testing::ext; +``` +3.添加被测试类的头文件 +``` +#include "calculator.h" +``` +4.定义测试套(测试类) +``` +class CalculatorSubTest : public testing::Test { +public: + static void SetUpTestCase(void); + static void TearDownTestCase(void); + void SetUp(); + void TearDown(); +}; + +void CalculatorSubTest::SetUpTestCase(void) +{ + // input testsuit setup step,setup invoked before all testcases +} + +void CalculatorSubTest::TearDownTestCase(void) +{ + // input testsuit teardown step,teardown invoked after all testcases +} + +void CalculatorSubTest::SetUp(void) +{ + // input testcase setup step,setup invoked before each testcases +} + +void CalculatorSubTest::TearDown(void) +{ + // input testcase teardown step,teardown invoked after each testcases +} +``` +> **注意:** 在定义测试套时,测试套名称应与编译目标保持一致,采用大驼峰风格。 - 2. 支持hdc连接的被测设备。 +5.测试用例实现,包含用例注释和逻辑实现 +``` +/** + * @tc.name: integer_sub_001 + * @tc.desc: Verify the sub function. + * @tc.type: FUNC + * @tc.require: Issue Number + */ +HWTEST_F(CalculatorSubTest, integer_sub_001, TestSize.Level1) +{ + //step 1:调用函数计算结果 + int actual = Sub(4,0); + //Step 2:使用断言比较预期与计算结果 + EXPECT_EQ(4, actual); +} +``` +在编写用例时,我们提供了三种用例模板供您选择。 + +|类型|描述| +|------------|------------| +|HWTEST(A,B,C)|用例执行不依赖Setup()时,可选取| +|HWTEST(A,B,C)|用例执行依赖于Setup()时,可选取| +|HWTEST(A,B,C)|需要做参数化测试时,可选取| + +其中,参数A,B,C的含义如下: +- 参数A为测试套名。 +- 参数B为测试用例名,其命名必须遵循[功能点]_[编号]的格式,编号为3位数字,从001开始。 +- 参数C为测试用例等级,具体分为门禁level0 以及非门禁level1-level4共五个等级,其中非门禁level1-level4等级的具体选取规则为:测试用例功能越重要,level等级越低。 + +**注意:** +- 测试用例的预期结果必须有对应的断言。 +- 测试用例必须填写用例等级。 +- 测试体建议按照模板分步实现。 +- 用例描述信息按照标准格式@tc.xxx value书写,注释信息必须包含用例名称,用例类型,需求编号四项。其中用例测试类型@tc.type参数的选取,可参考下表。 + +|测试类型名称|功能测试|性能测试|可靠性测试|安全测试|模糊测试| +|------------|------------|------------|------------|------------|------------| +|类型编码|FUNC|PERF|RELI|SECU|FUZZ| + +6.用例源文件命名规范 +测试用例源文件名称和测试套内容保持一致,文件命名采用全小写+下划线方式命名,以test结尾,具体格式为:[功能]_[子功能]_test,子功能支持向下细分。 +示例: +``` +calculator_sub_test.cpp +``` +#### 3.2.2 JavaScript参考示例 +``` +/* + * 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 + * + * 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. + */ +import app from '@system.app' + +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' + +describe("AppInfoTest", function () { + beforeAll(function() { + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll caled') + }) + + afterAll(function() { + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll caled') + }) + + beforeEach(function() { + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach caled') + }) + + afterEach(function() { + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach caled') + }) + + /* + * @tc.name:appInfoTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("appInfoTest001", 0, function () { + var info = app.getInfo() + expect(info != null).assertEqual(true) + }) +}) +``` +详细内容介绍: +1.添加测试用例文件头注释信息 +``` +/* + * 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 + * + * 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. + */ +``` +2.导入被测api和jsunit测试库 +``` +import app from '@system.app' - \[device\] \# 配置标签为usb-hdc的环境信息,测试设备的IP地址和hdc映射的端口号,例如: +import {describe, beforeAll, beforeEach, afterEach, afterAll, it, expect} from 'deccjsunit/index' +``` +3.定义测试套 +``` +describe("AppInfoTest", function () { + beforeAll(function() { + // input testsuit setup step,setup invoked before all testcases + console.info('beforeAll caled') + }) + + afterAll(function() { + // input testsuit teardown step,teardown invoked after all testcases + console.info('afterAll caled') + }) + + beforeEach(function() { + // input testcase setup step,setup invoked before each testcases + console.info('beforeEach caled') + }) + + afterEach(function() { + // input testcase teardown step,teardown invoked after each testcases + console.info('afterEach caled') + }) +``` +4.测试用例实现 +``` + /* + * @tc.name:appInfoTest001 + * @tc.desc:verify app info is not null + * @tc.type: FUNC + * @tc.require: Issue Number + */ + it("appInfoTest001", 0, function () { + var info = app.getInfo() + expect(info != null).assertEqual(true) + }) +``` +5.用例源文件命名规范 +测试用例原文件名称采用大驼峰风格,以TEST结尾,具体格式为:[功能][子功能]TEST,子功能支持向下细分。 +示例: +``` +AppInfoTest.js +``` +### 3.3 测试用例编译文件编写 +根据测试用例目录规划,当执行某一用例时,测试框架会根据编译文件逐层查找,最终找到所需用例进行编译。下面通过不同示例来讲解gn文件如何编写。 - ``` - - 192.168.1.1 - 9111 - - - ``` +#### 3.3.1 测试用例编译配置文件 +针对不同语言,下面提供不同的编译模板以供参考。 - 3. 仅支持串口的被测设备。 +- **C++用例编译配置示例** - \[board\_info\] \# 开发板配置信息,例如: +``` +# Copyright (c) 2021 XXXX Device Co., Ltd. - ``` - - hispark - taurus - ipcamera - hb build - - ``` +import("//build/test.gni") - >![](public_sys-resources/icon-note.gif) **说明:** - >开发板配置信息如下: - >board\_series:开发板系列,默认hispark。 - >board\_type:开发板类型,默认taurus。 - >board\_product:目标产品,默认ipcamera。 - >build\_command:测试版本和用例的编译命令,默认hb build。 +module_output_path = "subsystem_examples/calculator" - \[device\] \# 配置标签为ipcamera的串口信息,COM口和波特率,例如: +config("module_private_config") { + visibility = [ ":*" ] - ``` - - - COM1 - cmd - 115200 - 8 - 1 - 1 - - - ``` + include_dirs = [ "../../../include" ] +} +ohos_unittest("CalculatorSubTest") { + module_out_path = module_output_path -- 修改developertest组件配置。可选,如果测试用例已完成编译,可以直接指定测试用例的编译输出路径,测试平台执行测试用例时即不会重新编译测试用例。 + sources = [ + "../../../include/calculator.h", + "../../../src/calculator.cpp", + ] - 文件:config/user\_config.xml。 + sources += [ "calculator_sub_test.cpp" ] - 1. \[test\_cases\] \# 指定测试用例的输出路径,编译输出目录,例如: + configs = [ ":module_private_config" ] - ``` - - /home/source_code/out/release/tests - - ``` + deps = [ "//third_party/googletest:gtest_main" ] +} - 2. \[NFS\] \# 被测设备仅支持串口时配置,指定NFS的映射路径,host\_dir为PC侧的NFS目录,board\_dir为板侧创建的目录,例如: +group("unittest") { + testonly = true + deps = [":CalculatorSubTest"] +} +``` - ``` - - D:\nfs - user - - ``` +详细内容如下: +1. 添加文件头注释信息 -- 测试环境准备(当被测设备仅支持串口时,需要检查)。 - - 系统镜像与文件系统已烧录进开发板,开发板上系统正常运行,在系统模式下,如shell登录时设备提示符OHOS\#。 - - 开发主机和开发板串口连接正常,网口连接正常。 - - 开发主机IP与开发板IP处在同一小网网段,相互可以ping通。 - - 开发主机侧创建空目录用于开发板通过NFS挂载测试用例,并且NFS服务启动正常。 + ``` + # Copyright (c) 2021 XXXX Device Co., Ltd. + ``` -- 运行测试套。 - - 启动测试框架,打开test/developertest目录。 - 1. Windows环境启动测试框架。 +2. 导入编译模板文件 - ``` - start.bat - ``` + ``` + import("//build/test.gni") + ``` - 2. Linux环境启动测试框架。 +3. 指定文件输出路径 - ``` - ./strat.sh - ``` + ``` + module_output_path = "subsystem_examples/calculator" + ``` + > **说明:** 此处输出路径为部件/模块名。 - - 设备形态选择。 +4. 配置依赖包含目录 - 根据实际的开发板选择,设备形态配置:developertest/config/framework\_config.xml。 + ``` + config("module_private_config") { + visibility = [ ":*" ] + + include_dirs = [ "../../../include" ] + } + ``` - - 执行测试指令。 - 1. 查询测试用例支持的子系统,模块,产品形态以及测试类型,使用show命令。 + > **说明:** 一般在此处对相关配置进行设置,在测试用例编译脚本中可直接引用。 - ``` - usage: - show productlist Querying Supported Product Forms - show typelist Querying the Supported Test Type - show subsystemlist Querying Supported Subsystems - show modulelist Querying Supported Modules - ``` +5. 指定测试用例编译目标输出的文件名称 - 2. 执行测试指令示例,其中-t为必选,-ss和-tm为可选字段。 + ``` + ohos_unittest("CalculatorSubTest") { + } + ``` - ``` - run -t ut -ss test -tm example - ``` +6. 编写具体的测试用例编译脚本(添加需要参与编译的源文件、配置和依赖) + ``` + ohos_unittest("CalculatorSubTest") { + module_out_path = module_output_path + sources = [ + "../../../include/calculator.h", + "../../../src/calculator.cpp", + "../../../test/calculator_sub_test.cpp" + ] + sources += [ "calculator_sub_test.cpp" ] + configs = [ ":module_private_config" ] + deps = [ "//third_party/googletest:gtest_main" ] + } + ``` - 3. 参数说明:指定参数可以执行特定特性、模块对应的测试套。 + > **说明:根据测试类型的不同,在具体编写过程中可选择不同的测试类型:** + > + > - ohos_unittest:单元测试 + > - ohos_moduletest:模块测试 + > - ohos_systemtest:系统测试 + > - ohos_performancetest:性能测试 + > - ohos_securitytest:安全测试 + > - ohos_reliabilitytest:可靠性测试 + > - ohos_distributedtest:分布式测试 - ``` - usage: run [-h] [-p PRODUCTFORM] [-t [TESTTYPE [TESTTYPE ...]]] - [-ss SUBSYSTEM] [-tm TESTMODULE] [-ts TESTSUIT] - [-tc TESTCASE] [-tl TESTLEVEL] - - optional arguments: - -h, --help show this help message and exit - -p PRODUCTFORM, --productform PRODUCTFORM Specified product form - -t [TESTTYPE [TESTTYPE ...]], --testtype [TESTTYPE [TESTTYPE ...]] - Specify test type(UT,MST,ST,PERF,ALL) - -ss SUBSYSTEM, --subsystem SUBSYSTEM Specify test subsystem - -tm TESTMODULE, --testmodule TESTMODULE Specified test module - -ts TESTSUIT, --testsuite TESTSUIT Specify test suite - -tc TESTCASE, --testcase TESTCASE Specify test case - -tl TESTLEVEL, --testlevel TESTLEVEL Specify test level - ``` +7. 对目标测试用例文件进行条件分组 + ``` + group("unittest") { + testonly = true + deps = [":CalculatorSubTest"] + } + ``` + > **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 -- 测试框架帮助。 +- **JavaScript用例编译配置示例** - 帮助指令,用于查询测试平台支持哪些测试指令。 +``` +# Copyright (C) 2021 XXXX Device Co., Ltd. - ``` - help - ``` +import("//build/test.gni") +module_output_path = "subsystem_examples/app_info" -- 退出自测试平台。 +ohos_js_unittest("GetAppInfoJsTest") { + module_out_path = module_output_path - 退出自测试平台,使用如下命令退出测试平台。 + hap_profile = "./config.json" + certificate_profile = "//test/developertest/signature/openharmony_sx.p7b" +} - ``` - quit - ``` +group("unittest") { + testonly = true + deps = [ ":GetAppInfoJsTest" ] +} +``` +详细内容如下: + +1. 添加文件头注释信息 + + ``` + # Copyright (C) 2021 XXXX Device Co., Ltd. + ``` + +2. 导入编译模板文件 + + ``` + import("//build/test.gni") + ``` + +3. 指定文件输出路径 + + ``` + module_output_path = "subsystem_examples/app_info" + ``` + + > **说明:** 此处输出路径为部件/模块名。 + +4. 指定测试用例编译目标输出的文件名称 + + ``` + ohos_js_unittest("GetAppInfoJsTest") { + } + ``` + + > **说明:** + >- 使用模板ohos_js_unittest定义js测试套,注意与C++用例区分。 + >- js测试套编译输出文件为hap类型,hap名为此处定义的测试套名,测试套名称必须以JsTest结尾。 + +5. 指定hap包配置文件config.json和签名文件,两个配置为必选项 + + ``` + ohos_js_unittest("GetAppInfoJsTest") { + module_out_path = module_output_path + + hap_profile = "./config.json" + certificate_profile = "//test/developertest/signature/openharmony_sx.p7b" + } + ``` + + config.json为hap编译所需配置文件,需要开发者根据被测sdk版本配置“target”项,其余项可默认,具体如下所示: + + ``` + { + "app": { + "bundleName": "com.example.myapplication", + "vendor": "example", + "version": { + "code": 1, + "name": "1.0" + }, + "apiVersion": { + "compatible": 4, + "target": 5 # 根据被测sdk版本进行修改,此例为sdk5 + } + }, + "deviceConfig": {}, + "module": { + "package": "com.example.myapplication", + "name": ".MyApplication", + "deviceType": [ + "phone" + ], + "distro": { + "deliveryWithInstall": true, + "moduleName": "entry", + "moduleType": "entry" + }, + "abilities": [ + { + "skills": [ + { + "entities": [ + "entity.system.home" + ], + "actions": [ + "action.system.home" + ] + } + ], + "name": "com.example.myapplication.MainAbility", + "icon": "$media:icon", + "description": "$string:mainability_description", + "label": "MyApplication", + "type": "page", + "launchType": "standard" + } + ], + "js": [ + { + "pages": [ + "pages/index/index" + ], + "name": "default", + "window": { + "designWidth": 720, + "autoDesignWidth": false + } + } + ] + } + } + ``` + +6. 对目标测试用例文件进行条件分组 + + ``` + group("unittest") { + testonly = true + deps = [ ":GetAppInfoJsTest" ] + } + ``` + + > **说明:** 进行条件分组的目的在于执行用例时可以选择性的执行某一种特定类型的用例。 + +#### 3.3.2 编译入口配置文件ohos.build + +当完成用例编译配置文件编写后,需要进一步编写部件编译配置文件,以关联到具体的测试用例。 +``` + "partA": { + "module_list": [ + + ], + "inner_list": [ + + ], + "system_kits": [ + + ], + "test_list": [ + "//system/subsystem/partA/calculator/test:unittest" //配置模块calculator下的test + ] + } +``` +> **说明:** test_list中配置的是对应模块的测试用例。 -## 测试结果与日志 +### 3.4 测试用例资源配置 +测试依赖资源主要包括测试用例在执行过程中需要的图片文件,视频文件、第三方库等对外的文件资源。 -- 通过在测试框架中执行测试指令,即可以生成测试日志和测试报告。 -- 测试结果 - - 测试用例的结果会直接显示在控制台上,执行一次的测试结果根路径如下: +依赖资源文件配置步骤如下: +1. 在部件或者模块的test目录下创建resource目录,存放需要的资源文件 - ``` - reports/xxxx-xx-xx-xx-xx-xx - ``` +2. 在resource目录下创建一个ohos_test.xml文件,文件内容格式如下 +``` + + + + + + + +``` +3. 在测试用例的编译配置文件中定义resource_config_file进行指引,用来指定对应的资源文件ohos_test.xml +``` +ohos_unittest("CalculatorSubTest") { + resource_config_file = "//system/subsystem/partA/calculator/test/resource/ohos_test.xml" +} +``` +>**说明:** +>- target_name: 测试套的名称,定义在测试目录的BUILD.gn中。preparer: 表示该测试套执行前执行的动作。 +>- src="res": 表示测试资源位于test目录下的resource目录下,src="out" 表示位于out/release/$(部件)目录下。 - - 测试用例格式化结果 +## 4 测试用例执行 +在执行测试用例之前,针对用例使用设备的不同,需要对相应配置进行修改,修改完成即可执行测试用例。 - ``` - result/ - ``` +### 4.1 user_config.xml配置 +``` + + + + false + + false + + true + + + + + + + + + + + + + cmd + 115200 + 8 + 1 + 1 + + + + + + + + + + + + + + + + + + +``` +>**说明:** 在执行测试用例之前,若使用HDC连接设备,用例仅需配置设备IP和端口号即可,其余信息均默认不修改。 - - 测试用例日志 +### 4.2 Windows环境执行 +#### 4.2.1 测试用例编译 - ``` - log/plan_log_xxxx-xx-xx-xx-xx-xx.log - ``` +由于Windows环境下无法实现用例编译,因此执行用例前需要在Linux环境下进行用例编译,用例编译命令: +``` +./build.sh --product-name Hi3516DV300 --build-target make_test +``` +编译完成后,测试用例将自动保存在out/ohos-arm-release/packages/phone/images/tests目录下。 - - 测试报告汇总 +**说明: Hi3516DV300为当前版本所支持的平台,make_test表示全部用例。根据不同需求,编译选项可进行不同选择:** +- --product-name # 编译产品名称(必选) +- --build-target # 指定编译目标(可选) - ``` - summary_report.html - ``` +#### 4.2.2 搭建执行环境 +1. 在Windows环境创建测试框架目录Test,并在此目录下创建testcase目录 - - 测试报告详情 +2. 从Linux环境拷贝测试框架developertest和xdevice到创建的Test目录下,拷贝编译好的测试用例到testcase目录下 +>**说明:** 将测试框架及测试用例从Linux环境移植到Windows环境,以便后续执行。 - ``` - details_report.html - ``` +3. 修改user_config.xml +``` + + + false + + + + D:\Test\testcase\tests + +``` +>**说明:** ``标签表示是否需要编译用例;``标签表示测试用例查找路径。 +#### 4.2.3 执行用例 +##### 4.2.3.1 启动测试框架 +启动测试框架: +``` +start.bat +``` +##### 4.2.3.2 选择产品形态 +进入测试框架,系统会自动提示您选择产品形态,请根据实际的开发板进行选择。例如:Hi3516DV300。 -- 测试框架日志 +##### 4.2.3.3 执行测试用例 +当选择完产品形态,可参考如下指令执行测试用例。 +``` +run -t UT -ts CalculatorSubTest -tc interger_sub_00l +``` +执行命令参数说明: +``` +-t [TESTTYPE]: 指定测试用例类型,有UT,MST,ST,PERF等。(必选参数) +-tp [TESTTYPE]: 指定部件,可独立使用。 +-tm [TESTTYPE]: 指定模块,不可独立使用,需结合-tp指定上级部件使用。 +-ts [TESTTYPE]: 指定测试套,可独立使用。 +-tc [TESTTYPE]: 指定测试用例,不可独立使用,需结合-ts指定上级测试套使用。 +-h : 帮助命令。 +``` - ``` - reports/platform_log_xxxx-xx-xx-xx-xx-xx.log - ``` +### 4.3 Linux环境执行 +#### 4.3.1 远程端口映射 +为了在Linux远程服务器以及Linux虚拟机两种环境下执行测试用例,需要对端口进行远程映射,以实现与设备的数据通路连接。具体操作如下: +HDC Server指令: +``` +hdc_std kill +hdc_std -m -s 0.0.0.0:8710 +``` +>**说明:** IP和端口号为默认值。 -- 最新测试报告 +HDC Client指令: +``` +hdc_std -s xx.xx.xx.xx:8710 list targets +``` +>**说明:** 此处IP填写设备侧IP地址。 - ``` - reports/latest - ``` +#### 4.3.2 执行用例 +##### 4.3.2.1 启动测试框架 +启动测试框架: +``` +./start.sh +``` +##### 4.3.2.2 选择产品形态 +进入测试框架,系统会自动提示您选择产品形态,请根据实际的开发板进行选择。例如:Hi3516DV300。 -## 涉及仓 +##### 4.3.2.3 执行测试用例 +测试框架在执行用例时会根据指令找到所需用例,自动实现用例编译,执行过程,完成自动化测试。 +``` +run -t UT -ts CalculatorSubTest -tc interger_sub_00l +``` +执行命令参数说明: +``` +-t [TESTTYPE]: 指定测试用例类型,有UT,MST,ST,PERF等。(必选参数) +-tp [TESTTYPE]: 指定部件,可独立使用。 +-tm [TESTTYPE]: 指定模块,不可独立使用,需结合-tp指定上级部件使用。 +-ts [TESTTYPE]: 指定测试套,可独立使用。 +-tc [TESTTYPE]: 指定测试用例,不可独立使用,需结合-ts指定上级测试套使用。 +-h : 帮助命令。 +``` -**测试子系统** +## 5 测试报告日志 +当执行完测试指令,控制台会自动生成测试结果,若需要详细测试报告您可在相应的数据文档中进行查找。 -test\_developertest +### 5.1 测试结果 +测试结果输出根路径如下: +``` +test/developertest/reports/xxxx_xx_xx_xx_xx_xx +``` +>**说明:** 测试报告文件目录将自动生成。 -test\_xdevice +该目录中包含以下几类结果: +| 类型 | 描述| +| ------------ | ------------ | +| result/ |测试用例格式化结果| +| log/plan_log_xxxx_xx_xx_xx_xx_xx.log | 测试用例日志 | +| summary_report.html | 测试报告汇总 | +| details_report.html | 测试报告详情 | -test\_xdevice\_extension +### 5.2 测试框架日志 +``` +reports/platform_log_xxxx_xx_xx_xx_xx_xx.log +``` +### 5.3 最新测试报告 +``` +reports/latest +``` \ No newline at end of file -- Gitee From 0d7628fe24966f0bb936724e922694dc86854a8a Mon Sep 17 00:00:00 2001 From: stivn Date: Sat, 11 Sep 2021 18:29:51 +0800 Subject: [PATCH 5/8] Update test subsystem documentation Signed-off-by: stivn --- .../guide/environment configuration.md | 74 +++++++++++++++++++ 1 file changed, 74 insertions(+) create mode 100644 zh-cn/device-dev/guide/environment configuration.md diff --git a/zh-cn/device-dev/guide/environment configuration.md b/zh-cn/device-dev/guide/environment configuration.md new file mode 100644 index 00000000000..0b476c718cf --- /dev/null +++ b/zh-cn/device-dev/guide/environment configuration.md @@ -0,0 +1,74 @@ +# 环境配置 +## 测试框架基础环境依赖 +|环境依赖|操作系统|Linux系统扩展组件|Python|Python插件|NFS Server| +|------------|------------|------------|------------|------------|------------| +|版本型号|Ubuntu18.04|libreadline-dev|3.7.5版本以上|pyserial 3.3以上、paramiko2.7.1以上、setuptools40.8.0以上、rsa4.0以上|haneWIN NFS Server 1.2.50及以上或者 NFSSv4及以上| +|详细说明|代码编译环境|命令行读取插件|测试框架语言 |pyserial:支持Python的串口通信;paramiko:支持Python使用SSH协议;setuptools:支持Python方便创建和分发Python包;rsa:支持Python rsa加密 |支持设备通过串口连接| +## 安装流程 +1. 安装Linux扩展组件readline,安装命令如下: +``` +sudo apt-get install libreadline-dev +``` +安装成功提示 +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +libreadline-dev is already the newest version (7.0-3). +0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. +``` +2. 安装setuptools插件,安装命令如下: +``` +pip3 install setuptools +``` +安装成功提示如下: +``` +Requirement already satisfied: setuptools in d:\programs\python37\lib\site-packages (41.2.0) +``` +3. 安装paramiko插件,安装命令如下: +``` +pip3 install paramiko +``` +安装成功提示如下: +``` +Installing collected packages: pycparser, cffi, pynacl, bcrypt, cryptography, paramiko +Successfully installed bcrypt-3.2.0 cffi-1.14.4 cryptography-3.3.1 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 +``` +4. 安装python的rsa插件,安装命令如下: +``` +pip3 install rsa +``` +安装成功截图如下: +``` +Installing collected packages: pyasn1, rsa +Successfully installed pyasn1-0.4.8 rsa-4.7 +``` +5. 需要本地的python安装串口插件pyserial,安装命令如下: +``` +pip3 install pyserial +``` +安装成功提示如下: +``` +Requirement already satisfied: pyserial in d:\programs\python37\lib\site-packages\pyserial-3.4-py3.7.egg (3.4) +``` +6. 如果设备仅支持串口输出测试结果,则需要安装NFS Server +- windows环境下安装,例如安装haneWIN NFS Server1.2.50。 +- Linux环境下安装,安装命令如下: +``` +sudo apt install nfs-kernel-server +``` +安装成功提示如下: +``` +Reading package lists... Done +Building dependency tree +Reading state information... Done +nfs-kernel-server is already the newest version (1:1.3.4-2.1ubuntu5.3). +0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. +``` +## 检验环境 + +| 检查项 |操作 |满足环境 | +| --- | --- | --- | +| 检查python安装与否 |命令行窗口执行命令:python --version |版本不小于3.7.5即可 | +| 检查python扩展插件安装与否 |打开test/xdevice目录,执行run.bat或run.sh| 可进入提示符“>>>”界面即可 | +|检查NFS Server启动状态(被测设备仅支持串口时检测) |通过串口登录开发板,执行mount命令挂载NFS |可正常挂载文件目录即可 | \ No newline at end of file -- Gitee From 3eebac3c60dd1db534b06ab206e94bdff424f6e2 Mon Sep 17 00:00:00 2001 From: stivn Date: Sat, 11 Sep 2021 18:30:55 +0800 Subject: [PATCH 6/8] Update test subsystem documentation Signed-off-by: stivn --- ...\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" index 192b2d34b35..a323cd2559c 100755 --- "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" @@ -823,7 +823,7 @@ test/developertest/reports/xxxx_xx_xx_xx_xx_xx ### 5.2 测试框架日志 ``` reports/platform_log_xxxx_xx_xx_xx_xx_xx.log -``` +``` ### 5.3 最新测试报告 ``` -- Gitee From 0f72affe9e6bf82d94a65f862a163642fb035ae7 Mon Sep 17 00:00:00 2001 From: stivn Date: Sat, 11 Sep 2021 18:33:00 +0800 Subject: [PATCH 7/8] Update test subsystem documentation --- ...\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" index a323cd2559c..2b9477ad94a 100755 --- "a/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" +++ "b/zh-cn/readme/\346\265\213\350\257\225\345\255\220\347\263\273\347\273\237.md" @@ -827,5 +827,5 @@ reports/platform_log_xxxx_xx_xx_xx_xx_xx.log ### 5.3 最新测试报告 ``` -reports/latest +reports/latest ``` \ No newline at end of file -- Gitee From 3def156be8679a69e171f0c54b026a30a79b11c2 Mon Sep 17 00:00:00 2001 From: stivn Date: Mon, 13 Sep 2021 09:32:03 +0800 Subject: [PATCH 8/8] Input environment configuration Signed-off-by: stivn --- .../guide/environment configuration.md | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 zh-cn/device-dev/guide/environment configuration.md diff --git a/zh-cn/device-dev/guide/environment configuration.md b/zh-cn/device-dev/guide/environment configuration.md deleted file mode 100644 index 0b476c718cf..00000000000 --- a/zh-cn/device-dev/guide/environment configuration.md +++ /dev/null @@ -1,74 +0,0 @@ -# 环境配置 -## 测试框架基础环境依赖 -|环境依赖|操作系统|Linux系统扩展组件|Python|Python插件|NFS Server| -|------------|------------|------------|------------|------------|------------| -|版本型号|Ubuntu18.04|libreadline-dev|3.7.5版本以上|pyserial 3.3以上、paramiko2.7.1以上、setuptools40.8.0以上、rsa4.0以上|haneWIN NFS Server 1.2.50及以上或者 NFSSv4及以上| -|详细说明|代码编译环境|命令行读取插件|测试框架语言 |pyserial:支持Python的串口通信;paramiko:支持Python使用SSH协议;setuptools:支持Python方便创建和分发Python包;rsa:支持Python rsa加密 |支持设备通过串口连接| -## 安装流程 -1. 安装Linux扩展组件readline,安装命令如下: -``` -sudo apt-get install libreadline-dev -``` -安装成功提示 -``` -Reading package lists... Done -Building dependency tree -Reading state information... Done -libreadline-dev is already the newest version (7.0-3). -0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. -``` -2. 安装setuptools插件,安装命令如下: -``` -pip3 install setuptools -``` -安装成功提示如下: -``` -Requirement already satisfied: setuptools in d:\programs\python37\lib\site-packages (41.2.0) -``` -3. 安装paramiko插件,安装命令如下: -``` -pip3 install paramiko -``` -安装成功提示如下: -``` -Installing collected packages: pycparser, cffi, pynacl, bcrypt, cryptography, paramiko -Successfully installed bcrypt-3.2.0 cffi-1.14.4 cryptography-3.3.1 paramiko-2.7.2 pycparser-2.20 pynacl-1.4.0 -``` -4. 安装python的rsa插件,安装命令如下: -``` -pip3 install rsa -``` -安装成功截图如下: -``` -Installing collected packages: pyasn1, rsa -Successfully installed pyasn1-0.4.8 rsa-4.7 -``` -5. 需要本地的python安装串口插件pyserial,安装命令如下: -``` -pip3 install pyserial -``` -安装成功提示如下: -``` -Requirement already satisfied: pyserial in d:\programs\python37\lib\site-packages\pyserial-3.4-py3.7.egg (3.4) -``` -6. 如果设备仅支持串口输出测试结果,则需要安装NFS Server -- windows环境下安装,例如安装haneWIN NFS Server1.2.50。 -- Linux环境下安装,安装命令如下: -``` -sudo apt install nfs-kernel-server -``` -安装成功提示如下: -``` -Reading package lists... Done -Building dependency tree -Reading state information... Done -nfs-kernel-server is already the newest version (1:1.3.4-2.1ubuntu5.3). -0 upgraded, 0 newly installed, 0 to remove and 11 not upgraded. -``` -## 检验环境 - -| 检查项 |操作 |满足环境 | -| --- | --- | --- | -| 检查python安装与否 |命令行窗口执行命令:python --version |版本不小于3.7.5即可 | -| 检查python扩展插件安装与否 |打开test/xdevice目录,执行run.bat或run.sh| 可进入提示符“>>>”界面即可 | -|检查NFS Server启动状态(被测设备仅支持串口时检测) |通过串口登录开发板,执行mount命令挂载NFS |可正常挂载文件目录即可 | \ No newline at end of file -- Gitee