提交 c2c469f6 编写于 作者: M mamingshuai

update openharmony 1.0.1

上级 9d2c8093
### 该问题是怎么引起的?
### 重现步骤
### 报错信息
### 相关的Issue
### 原因(目的、解决的问题等)
### 描述(做了什么,变更了什么)
### 测试用例(新增、改动、可能影响的功能)
*.pyc
/extension/
\ No newline at end of file
# Copyright (c) 2020 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.
import("//test/xts/tools/build/suite_lite.gni")
deploy_suite("xdevice"){
suite_name = "acts"
}
# Copyright (c) 2020 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.
import("//test/xts/tools/lite/build/suite_lite.gni")
deploy_suite("xdevice") {
suite_name = "acts,hits,ssts"
}
文件模式从 100755 更改为 100644
# XDevice<a name="EN-US_TOPIC_0000001083129731"></a>
- [Introduction](#section15701932113019)
- [Directory Structure](#section1791423143211)
- [Constraints](#section118067583303)
- [Usage](#section2036431583)
- [Repositories Involved](#section260848241)
## Introduction<a name="section15701932113019"></a>
XDevice, a core module of the OpenHarmony test framework, provides services on which test case execution depends.
XDevice consists of the following sub-modules:
- **command**: enables command-based interactions between users and the test platform. It parses and processes user commands.
- **config**: sets test framework configurations and provides different configuration options for the serial port connection and USB connection modes.
- **driver**: functions as a test case executor, which defines main test steps, such as test case distribution, execution, and result collection.
- **report**: parses test results and generates test reports.
- **scheduler**: schedules various test case executors in the test framework.
- **environment**: configures the test framework environment, enabling device discovery and device management.
- **testkit**: provides test tools to implement JSON parsing, network file mounting, etc.
- **resource**: provides the device connection configuration file and report template definitions.
- **adapter**: adapts the test framework to open-source software.
## Directory Structure<a name="section1791423143211"></a>
```
xdevice
├── config # XDevice configuration
│ ├── user_config.xml # XDevice environment configuration
├── resource # XDevice resources
│ ├── tools # Burning tools
├── src # Source code
│ ├── xdevice
├── extension # XDevice extension
│ ├── src # Source code of the extension
│ └── setup.py # Installation script of the extension
```
## Constraints<a name="section118067583303"></a>
The environment requirements for using this module are as follows:
- Python version: 3.7.5 or later
- pySerial version: 3.3 or later
- Paramiko version: 2.7.1 or later
- RSA version: 4.0 or later
## Usage<a name="section2036431583"></a>
- **Installing XDevice**
1. Go to the installation directory of XDevice.
2. Open the console window and run the following command:
```
python setup.py install
```
- **Installing the extension**
1. Go to the installation directory of the XDevice extension.
2. Open the console and run the following command:
```
python setup.py install
```
- **Modifying the user\_config.xml file**
Configure information about your environment in the **user\_config.xml** file.
**1. Configure the environment.**
- For devices that support hdc connection, refer to the following note to configure the environment.
>![](figures/icon-note.gif) **NOTE:**
>**ip/port**: IP address and port of a remote device. By default, the parameter is left blank, indicating that the local device \(IP address: 127.0.0.1; port: the one used for hdc startup\) is used as the test device.
>**sn**: SN of the test devices specified for command execution. If this parameter is set to **SN1**, only device SN1 can execute the subsequent **run** commands. In this case, other devices are set as **Ignored** and not involved in the command execution. You can run the **list devices** command and check the value of **Allocation** to view the **sn** values. You can set multiple SNs and separate each two of them with a semicolon \(;\).
- For devices that support serial port connection, refer to the following note to configure the environment.
>![](figures/icon-note.gif) **NOTE:**
>**type**: device connection mode. The **com** mode indicates that the device is connected through the serial port.
>**label**: device type, for example, **wifiiot**
>**serial**: serial port
>- **serial/com**: serial port for local connection, for example, **COM20**
>- **serial/type**: serial port type. The value can be **cmd** \(serial port for test case execution\) or **deploy** \(serial port for system upgrade\).
> For the open-source project, the **cmd** and **deploy** serial ports are the same, and their **com** values are the same too.
>**serial/baud\_rate, data\_bits, stop\_bits** and **timeout**: serial port parameters. You can use the default values.
**2. Set the test case directory.**
**dir**: test case directory
**3. Mount the NFS.**
>![](figures/icon-note.gif) **NOTE:**
>**server**: NFS mounting configuration. Set the value to **NfsServer**.
>**server/ip**: IP address of the mounting environment
>**server/port**: port number of the mounting environment
>**server/username**: user name for logging in to the server
>**server/password**: password for logging in to the server
>**server/dir**: external mount path
>**server/remote**: whether the NFS server and the XDevice executor are deployed on different devices. If yes, set this parameter to **true**. Otherwise, set it to **false**.
- **Specify the task type.**
- **Start the test framework.**
- **Execute test commands.**
Test framework commands can be classified into three groups: **help**, **list**, and **run**. Among them, **run** commands are most commonly used in the instruction sequence.
**help**
Queries help information about test framework commands.
```
help:
Use help to get information.
usage:
run: Display a list of supported run commands.
list: Display a list of supported devices and task records.
Examples:
help run
help list
```
>![](figures/icon-note.gif) **NOTE:**
>**help run**: displays the description of **run** commands.
>**help list**: displays the description of **list** commands.
**list**
Displays device information and related task information.
```
list:
Display device list and task records.
usage:
list
list history
list <id>
Introduction:
list: Display the device list.
list history: Display historical records of a series of tasks.
list <id>: Display historical records of tasks with the specified IDs.
Examples:
list
list history
list 6e****90
```
>![](figures/icon-note.gif) **NOTE:**
>**list**: displays device information.
>**list history**: displays historical task information.
>**list <id\>**: displays historical information about tasks with specified IDs.
**run**
Executes test tasks.
```
run:
Execute the selected test cases.
The command execution process includes use case compilation, execution, and result collection.
usage: run [-l TESTLIST [TESTLIST ...] | -tf TESTFILE
[TESTFILE ...]] [-tc TESTCASE] [-c CONFIG] [-sn DEVICE_SN]
[-rp REPORT_PATH [REPORT_PATH ...]]
[-respath RESOURCE_PATH [RESOURCE_PATH ...]]
[-tcpath TESTCASES_PATH [TESTCASES_PATH ...]]
[-ta TESTARGS [TESTARGS ...]] [-pt]
[-env TEST_ENVIRONMENT [TEST_ENVIRONMENT ...]]
[-e EXECTYPE] [-t [TESTTYPE [TESTTYPE ...]]]
[-td TESTDRIVER] [-tl TESTLEVEL] [-bv BUILD_VARIANT]
[-cov COVERAGE] [--retry RETRY] [--session SESSION]
[--dryrun] [--reboot-per-module] [--check-device]
[--repeat REPEAT]
action task
Specify tests to run.
positional arguments:
action Specify the action to do.
task Specify the task name, such as ssts, acts, and hits.
```
>![](figures/icon-note.gif) **NOTE:**
>The structure of a basic **run** command is as follows:
>```
>run [task name] -l module1;moudle2
>```
>**task name**: task type. This parameter is optional. Generally, the value is **ssts**, **acts**, or **hits**.
>**-l**: test cases to execute. Use semicolons \(;\) to separate each two test cases.
>**module**: module to test. Generally, there is a **.json** file of the module in the **testcases** directory.
>In addition, other parameters can be attached to this command as constraints. Common parameters are as follows:
>**-sn**: specifies the devices for test case execution. If this parameter is set to **SN1**, only device SN1 executes the test cases.
>**-c**: specifies a new **user\_config.xml** file.
>**-rp**: indicates the path where the report is generated. The default directory is **xxx/xdevice/reports**. Priority of a specified directory is higher than that of the default one.
>**-tcpath**: indicates the environment directory, which is **xxx/xdevice/testcases** by default. Priority of a specified directory is higher than that of the default one.
>**-respath**: indicates the test suite directory, which is **xxx/xdevice/resource** by default. Priority of a specified directory is higher than that of the default one.
>**--reboot-per-module**: restarts the device before test case execution.
- **View the execution result.**
After executing the **run** commands, the test framework displays the corresponding logs on the console, and generates the execution report in the directory specified by the **-rp** parameter. If the parameter is not set, the report will be generated in the default directory.
```
Structure of the report directory (the default or the specified one)
├── result # Test case execution results of the module
│ ├── module name.xml
│ ├── ...
├── log # Running logs of devices and tasks
│ ├── device 1.log
│ ├── ...
│ ├── task.log
├── summary_report.html # Visual report
├── summary_report.html # Statistical report
└── ...
```
## Repositories Involved<a name="section260848241"></a>
test\_xdevice
test\_xdevice\_extension
# xdevice组件<a name="ZH-CN_TOPIC_0000001083129731"></a>
- [简介](#section15701932113019)
- [目录](#section1791423143211)
- [约束](#section118067583303)
- [使用](#section2036431583)
- [相关仓](#section260848241)
## 简介<a name="section15701932113019"></a>
xdevice是OpenHarmony中为测试框架的核心组件,提供用例执行所依赖的相关服务。
xdevice主要包括以下几个主要模块:
- command,用户与测试平台命令行交互模块,提供用户输入命令解析,命令处理。
- config,测试框架配置模块,提供测试平台串口连接方式和USB连接方式的不同配置选项。
- driver,测试用例执行器,提供测试用例分发,执行,结果收集等主要测试步骤定义。
- report,测试报告模块,提供测试结果解析和测试报告生成。
- scheduler,测试框架调度模块,提供不同类型的测试执行器调度的调度功能。
- environment,测试框架的环境配置模块,提供设备发现,设备管理的功能。
- testkit,测试框架工具模块,提供json解析,网络文件挂载等操作。
- resource,测试框架资源模块,提供设备连接配置文件和报告模板定义。
- adapter,测试框架适配开源软件的模块。
## 目录<a name="section1791423143211"></a>
```
xdevice
├── config # xdevice组件配置
│ ├── user_config.xml # xdevice环境配置
├── resource # xdevice组件资源
│ ├── tools # 版本烧录工具
├── src # 组件源码目录
│ ├── xdevice
├── extension # xdevice扩展模块
│ ├── src # 扩展模块源码
│ └── setup.py # xdevice扩展模块安装脚本
```
## 约束<a name="section118067583303"></a>
运行环境要求:
- python版本\>=3.7.5
- pyserial\>=3.3
- paramiko\>=2.7.1
- rsa\>=4.0
## 使用<a name="section2036431583"></a>
- **安装xdevice**
1. 打开xdevice安装目录。
2. 打开控制台,执行如下命令:
```
python setup.py install
```
- **安装extension**
1. 打开extension安装目录。
2. 打开控制台,执行如下命令:
```
python setup.py install
```
- **修改user\_config.xml**
user\_config.xml是框架提供的用户配置文件,用户可以根据自身环境信息配置相关内容,具体介绍如下:
**1、environment环境相关配置:**
- 设备类型一
>![](figures/icon-note.gif) **说明:**
>ip/port: 表示远程设备地址,默认情况为空,表示使用本地设备,ip地址为127.0.0.1,port为本机hdc启动端口号;
>​sn: 过滤执行测试设备,若设置为SN1,则表示只有设备SN1能够支持后续run命令执行,其他设备分配状态设置为Ignored,不参与命令执行,可通过list devices命令中Allocation字段来查看sn设置,可配置多个sn,中间以;隔开;
- 设备类型二
>![](figures/icon-note.gif) **说明:**
>type: 设备连接方式,com表示连接方式是串口
>label: 表示设备种类,如wifiiot
>serial: 表示一个串口定义
>serial/com 表示本地连接的串口,如COM20 serial/type 表示串口类型,cmd是命令串口,deploy是刷机串口,社区版本cmd和deploy使用同一个串口,com值相同
>serial/baud\_rate、data\_bits、stop\_bits、timeout: 为串口波特率等串口参数 ,一般采用默认值即可。
**2、测试用例目录设置**
dir: 指定测试用例目录。
**3、nfs挂载**
>![](figures/icon-note.gif) **说明:**
>server: nfs挂载配置,label取值为NfsServer。
>server/ip: 挂载环境IP地址。
>server/port: 挂载环境端口。
>server/username: 登录用户名。
>server/password: 登录用户密码。
>server/dir: 对应挂载的外部路径。
>server/remote: nfs服务器与xDevice执行机不在同一台机器时,remote配置为true,否则为false。
- **选定任务类型**
- **启动框架**
- **执行指令**
框架指令可以分为三组:help、list、run。在指令序列中,以run为最常用的执行指令。
**1、help**
输入help指令可以查询框架指令帮助信息。
```
help:
use help to get information.
usage:
run: Display a list of supported run command.
list: Display a list of supported device and task record.
Examples:
help run
help list
```
>![](figures/icon-note.gif) **说明:**
>help run:展示run指令相关说明
>help list:展示 list指令相关说明
**2、list**
list指令用来展示设备和相关的任务信息
```
list:
This command is used to display device list and task record.
usage:
list
list history
list <id>
Introduction:
list: display device list
list history: display history record of a serial of tasks
list <id>: display history record about task what contains specific id
Examples:
list
list history
list 6e****90
```
>![](figures/icon-note.gif) **说明:**
>list: 展示设备信息
>list history: 展示任务历史信息
>list <id\>: 展示特定id的任务其历史信息
**3、run**
run指令主要用于执行测试任务
```
run:
This command is used to execute the selected testcases.
It includes a series of processes such as use case compilation, execution, and result collection.
usage: run [-l TESTLIST [TESTLIST ...] | -tf TESTFILE
[TESTFILE ...]] [-tc TESTCASE] [-c CONFIG] [-sn DEVICE_SN]
[-rp REPORT_PATH [REPORT_PATH ...]]
[-respath RESOURCE_PATH [RESOURCE_PATH ...]]
[-tcpath TESTCASES_PATH [TESTCASES_PATH ...]]
[-ta TESTARGS [TESTARGS ...]] [-pt]
[-env TEST_ENVIRONMENT [TEST_ENVIRONMENT ...]]
[-e EXECTYPE] [-t [TESTTYPE [TESTTYPE ...]]]
[-td TESTDRIVER] [-tl TESTLEVEL] [-bv BUILD_VARIANT]
[-cov COVERAGE] [--retry RETRY] [--session SESSION]
[--dryrun] [--reboot-per-module] [--check-device]
[--repeat REPEAT]
action task
Specify tests to run.
positional arguments:
action Specify action
task Specify task name,such as "ssts", "acts", "hits"
```
>![](figures/icon-note.gif) **说明:**
>一个基本的run指令结构如下:
>```
>run [task name] -l module1;moudle2
>```
>task name:任务类型。一般为ssts、acts、hits。非必选项
>-l :指定执行测试用例,多个测试用例,中间用;隔开
>module:被测试的模块。一般在testcases目录下存在对应的\\.json文件
>此外,其他参数可以作为约束条件,附加到这个基本指令之上使用。常用的如:
>-sn: 过滤执行测试设备,若设置为SN1,则表示只有设备SN1执行用例
>-c: 重新指定user\_config.xml。
>-rp: 报告生成路径。默认为xxx/xdevice/reports目录。指定目录后,优先级:指定目录\>xxx/xdevice/reports目录。
>-tcpath:环境目录,默认为xxx/xdevice/testcases目录。指定目录后,优先级:指定目录\>xxx/xdevice/testcases目录
>-respath:测试套目录,默认为xxx/xdevice/resource目录。指定目录后,优先级:指定目录\>xxx/xdevice/resource目录
>--reboot-per-module: 执行前先重启设备
- **查看执行结果**
框架执行run指令,控制台会输出对应的log打印,还会生成对应的执行结果报告。如果使用了-rp参数指定报告路径,那么报告就会生成在指定的路径下。否则报告会存放在默认目录。
```
当前报告目录(默认目录/指定目录)
├── result(模块执行结果存放目录)
│ ├── <模块名>.xml
│ ├── ... ...
├── log (设备和任务运行log存放目录)
│ ├── <设备1>.log
│ ├── ... ...
│ ├── <任务>.log
├── summary_report.html(测试任务可视化报告)
├── summary_report.html(测试任务数据化报告)
└── ... ...
```
## 相关仓<a name="section260848241"></a>
test\_xdevice
test\_xdevice\_extension
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.
***************************************************************
Copyright (C) 2011 The Android Open Source Project
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
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
#!/usr/bin/env python3
# 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.
#
#!/usr/bin/env python3
# coding=utf-8
#
# Copyright (c) 2021 Huawei Device Co., Ltd.
# Copyright (c) 2013 The Android Open Source Project
# 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.
#
from dataclasses import dataclass
__all__ = ["UsbConst", "AppConst"]
@dataclass
class UsbConst:
connector = "adb"
connector_type = "usb-adb"
push = "adb push"
pull = "adb pull"
shell = "adb shell"
server_port = "ANDROID_ADB_SERVER_PORT"
kill_server = "adb kill-server"
start_server = "adb start-server"
reboot = "adb reboot"
@dataclass
class AppConst:
entry_app = "Entry.apk"
app_ext = ".apk"
app_name = "APK"
wifi_app = "xDeviceService-wifi.apk"
{
"description": "Config for acts test suites",
"kits": [
{
"type": "QueryKit",
"server": "NfsServer",
"mount": [
{
"source": "resource/tools/query.bin",
"target": "/test_root/tools"
}
],
"query" : "/test_root/tools/query.bin"
}
]
}
{
"description": "Config for acts test suites",
"kits": [
{
"type": "QueryKit",
"server": "NfsServer",
"mount": [
{
"source": "resource/tools/query.bin",
"target": "/test_root/tools"
}
],
"query" : "/test_root/tools/query.bin"
},