• Home
Name Date Size #Lines LOC

..--

config/12-May-2024-10691

extension/12-May-2024-6,6275,384

figures/12-May-2024-

lite/12-May-2024-1816

src/xdevice/12-May-2024-14,21311,474

.gitattributesD12-May-2024631 1615

.gitignoreD12-May-20246 21

BUILD.gnD12-May-2024720 1816

LICENSED12-May-20249.9 KiB178150

OAT.xmlD12-May-20243.8 KiB6310

README.mdD12-May-202410.4 KiB228176

README_zh.mdD12-May-20248.8 KiB226174

bundle.jsonD12-May-20241.3 KiB5959

run.batD12-May-20241.5 KiB5750

run.shD12-May-20241.5 KiB5935

setup.pyD12-May-20241.9 KiB6036

README.md

1# XDevice<a name="EN-US_TOPIC_0000001083129731"></a>
2
3-   [Introduction](#section15701932113019)
4-   [Directory Structure](#section1791423143211)
5-   [Constraints](#section118067583303)
6-   [Usage](#section2036431583)
7-   [Repositories Involved](#section260848241)
8
9## Introduction<a name="section15701932113019"></a>
10
11XDevice, a core module of the OpenHarmony test framework, provides services on which test case execution depends.
12
13XDevice consists of the following sub-modules:
14
15-   **command**: enables command-based interactions between users and the test platform. It parses and processes user commands.
16-   **config**: sets test framework configurations and provides different configuration options for the serial port connection and USB connection modes.
17-   **driver**: functions as a test case executor, which defines main test steps, such as test case distribution, execution, and result collection.
18-   **report**: parses test results and generates test reports.
19-   **scheduler**: schedules various test case executors in the test framework.
20-   **environment**: configures the test framework environment, enabling device discovery and device management.
21-   **testkit**: provides test tools to implement JSON parsing, network file mounting, etc.
22-   **resource**: provides the device connection configuration file and report template definitions.
23
24## Directory Structure<a name="section1791423143211"></a>
25
26```
27xdevice
28├── config                    # XDevice configuration
29│     ├── user_config.xml    # XDevice environment configuration
30├── resource                  # XDevice resources
31│     ├── tools              # Burning tools
32├── src                       # Source code
33│     ├── xdevice
34├── extension                 # XDevice extension
35│     ├── src                # Source code of the extension
36│     └── setup.py           # Installation script of the extension
37```
38
39## Constraints<a name="section118067583303"></a>
40
41The environment requirements for using this module are as follows:
42
43-   Python version: 3.7.5 or later
44-   pySerial version: 3.3 or later
45-   Paramiko version: 2.7.1 or later
46-   RSA version: 4.0 or later
47
48## Usage<a name="section2036431583"></a>
49
50-   **Installing XDevice**
51    1.  Go to the installation directory of XDevice.
52    2.  Open the console window and run the following command:
53
54        ```
55        python setup.py install
56        ```
57
58
59-   **Installing the extension**
60    1.  Go to the installation directory of the XDevice extension.
61    2.  Open the console and run the following command:
62
63        ```
64        python setup.py install
65        ```
66
67
68-   **Modifying the user\_config.xml file**
69
70    Configure information about your environment in the  **user\_config.xml**  file.
71
72    **1. Configure the environment.**
73
74    -   For devices that support hdc connection, refer to the following note to configure the environment.
75
76        >![](figures/icon-note.gif) **NOTE:**
77        >**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.
78        >**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 \(;\).
79
80    -   For devices that support serial port connection, refer to the following note to configure the environment.
81
82        >![](figures/icon-note.gif) **NOTE:**
83        >**type**: device connection mode. The  **com**  mode indicates that the device is connected through the serial port.
84        >**label**: device type, for example,  **wifiiot**
85        >**serial**: serial port
86        >-   **serial/com**: serial port for local connection, for example,  **COM20**
87        >-   **serial/type**: serial port type. The value can be  **cmd**  \(serial port for test case execution\) or  **deploy**  \(serial port for system upgrade\).
88        >    For the open-source project, the  **cmd**  and  **deploy**  serial ports are the same, and their  **com**  values are the same too.
89        >**serial/baud\_rate, data\_bits, stop\_bits**  and  **timeout**: serial port parameters. You can use the default values.
90
91
92    **2. Set the test case directory.**
93
94    **dir**: test case directory
95
96    **3. Mount the NFS.**
97
98    >![](figures/icon-note.gif) **NOTE:**
99    >**server**: NFS mounting configuration. Set the value to  **NfsServer**.
100    >**server/ip**: IP address of the mounting environment
101    >**server/port**: port number of the mounting environment
102    >**server/username**: user name for logging in to the server
103    >**server/password**: password for logging in to the server
104    >**server/dir**: external mount path
105    >**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**.
106
107-   **Specify the task type.**
108-   **Start the test framework.**
109-   **Execute test commands.**
110
111    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.
112
113    **help**
114
115    Queries help information about test framework commands.
116
117    ```
118    help:
119         use help to get information.
120    usage:
121         run:  Display a list of supported run command.
122         list: Display a list of supported device and task record.
123    Examples:
124         help run
125         help list
126    ```
127
128    >![](figures/icon-note.gif) **NOTE:**
129    >**help run**: displays the description of  **run**  commands.
130    >**help list**: displays the description of  **list**  commands.
131
132    **list**
133
134    Displays device information and related task information.
135
136    ```
137    list:
138         This command is used to display device list and task record.
139    usage:
140          list
141          list history
142          list <id>
143    Introduction:
144         list:         display device list
145         list history: display history record of a serial of tasks
146         list <id>:    display history record about task what contains specific id
147    Examples:
148         list
149         list history
150         list 6e****90
151    ```
152
153    >![](figures/icon-note.gif) **NOTE:**
154    >**list**: displays device information.
155    >**list history**: displays historical task information.
156    >**list <id\>**: displays historical information about tasks with specified IDs.
157
158    **run**
159
160    Executes test tasks.
161
162    ```
163    run:
164         This command is used to execute the selected testcases.
165         It includes a series of processes such as use case compilation, execution, and result collection.
166    usage: run [-l TESTLIST [TESTLIST ...] | -tf TESTFILE
167                [TESTFILE ...]] [-tc TESTCASE] [-c CONFIG] [-sn DEVICE_SN]
168                [-rp REPORT_PATH [REPORT_PATH ...]]
169                [-respath RESOURCE_PATH [RESOURCE_PATH ...]]
170                [-tcpath TESTCASES_PATH [TESTCASES_PATH ...]]
171                [-ta TESTARGS [TESTARGS ...]] [-pt]
172                [-env TEST_ENVIRONMENT [TEST_ENVIRONMENT ...]]
173                [-e EXECTYPE] [-t [TESTTYPE [TESTTYPE ...]]]
174                [-td TESTDRIVER] [-tl TESTLEVEL] [-bv BUILD_VARIANT]
175                [-cov COVERAGE] [--retry RETRY] [--session SESSION]
176                [--dryrun] [--reboot-per-module] [--check-device]
177                [--repeat REPEAT]
178                action task
179    Specify tests to run.
180      positional arguments:
181       action                Specify action
182       task                  Specify task name,such as "ssts", "acts", "hits"
183    ```
184
185    >![](figures/icon-note.gif) **NOTE:**
186    >The structure of a basic  **run**  command is as follows:
187    >```
188    >run [task name] -l module1;moudle2
189    >```
190    >**task name**: task type. This parameter is optional. Generally, the value is  **ssts**,  **acts**, or  **hits**.
191    >**-l**: test cases to execute. Use semicolons \(;\) to separate each two test cases.
192    >**module**: module to test. Generally, there is a  **.json**  file of the module in the  **testcases**  directory.
193    >In addition, other parameters can be attached to this command as constraints. Common parameters are as follows:
194    >**-sn**: specifies the devices for test case execution. If this parameter is set to  **SN1**, only device SN1 executes the test cases.
195    >**-c**: specifies a new  **user\_config.xml**  file.
196    >**-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.
197    >**-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.
198    >**-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.
199    >**--reboot-per-module**: restarts the device before test case execution.
200
201-   **View the execution result.**
202
203    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.
204
205    ```
206    Structure of the report directory (the default or the specified one)
207         ├── result # Test case execution results of the module
208         │     ├── module name.xml
209         │     ├──  ... ...
210211         ├── log # Running logs of devices and tasks
212         │     ├── device 1.log
213         │     ├── ... ...
214         │     ├── task.log
215         ├── summary_report.html # Visual report
216         ├── summary_report.html # Statistical report
217         └── ... ...
218    ```
219
220
221## Repositories Involved<a name="section260848241"></a>
222
223[testing subsystem](https://gitee.com/openharmony/docs/blob/master/en/readme/testing-subsystem.md)
224
225**test\_xdevice**
226
227[test\_developertest](https://gitee.com/openharmony/test_developertest/blob/master/README.md)
228

README_zh.md

1# xdevice组件<a name="ZH-CN_TOPIC_0000001083129731"></a>
2
3-   [简介](#section15701932113019)
4-   [目录](#section1791423143211)
5-   [约束](#section118067583303)
6-   [使用](#section2036431583)
7-   [相关仓](#section260848241)
8
9## 简介<a name="section15701932113019"></a>
10
11xdevice是OpenHarmony中为测试框架的核心组件,提供用例执行所依赖的相关服务。
12
13xdevice主要包括以下几个主要模块:
14
15-   command,用户与测试平台命令行交互模块,提供用户输入命令解析,命令处理。
16-   config,测试框架配置模块,提供测试平台串口连接方式和USB连接方式的不同配置选项。
17-   driver,测试用例执行器,提供测试用例分发,执行,结果收集等主要测试步骤定义。
18-   report,测试报告模块,提供测试结果解析和测试报告生成。
19-   scheduler,测试框架调度模块,提供不同类型的测试执行器调度的调度功能。
20-   environment,测试框架的环境配置模块,提供设备发现,设备管理的功能。
21-   testkit,测试框架工具模块,提供json解析,网络文件挂载等操作。
22-   resource,测试框架资源模块,提供设备连接配置文件和报告模板定义。
23
24## 目录<a name="section1791423143211"></a>
25
26```
27xdevice
28├── config                    # xdevice组件配置
29│     ├── user_config.xml    # xdevice环境配置
30├── resource                  # xdevice组件资源
31│     ├── tools              # 版本烧录工具
32├── src                       # 组件源码目录
33│     ├── xdevice
34├── extension                 # xdevice扩展模块
35│     ├── src                # 扩展模块源码
36│     └── setup.py           # xdevice扩展模块安装脚本
37```
38
39## 约束<a name="section118067583303"></a>
40
41运行环境要求:
42
43-   python版本\>=3.7.5
44-   pyserial\>=3.3
45-   paramiko\>=2.7.1
46-   rsa\>=4.0
47
48## 使用<a name="section2036431583"></a>
49
50-   **安装xdevice**
51    1.  打开xdevice安装目录。
52    2.  打开控制台,执行如下命令:
53
54        ```
55        python setup.py install
56        ```
57
58
59-   **安装extension**
60    1.  打开extension安装目录。
61    2.  打开控制台,执行如下命令:
62
63        ```
64        python setup.py install
65        ```
66
67
68-   **修改user\_config.xml**
69
70    user\_config.xml是框架提供的用户配置文件,用户可以根据自身环境信息配置相关内容,具体介绍如下:
71
72    **1、environment环境相关配置:**
73
74    -   设备类型一
75
76        >![](figures/icon-note.gif) **说明:**
77        >ip/port: 表示远程设备地址,默认情况为空,表示使用本地设备,ip地址为127.0.0.1,port为本机hdc启动端口号;
78        >​sn: 过滤执行测试设备,若设置为SN1,则表示只有设备SN1能够支持后续run命令执行,其他设备分配状态设置为Ignored,不参与命令执行,可通过list devices命令中Allocation字段来查看sn设置,可配置多个sn,中间以;隔开;
79
80    -   设备类型二
81
82        >![](figures/icon-note.gif) **说明:**
83        >type: 设备连接方式,com表示连接方式是串口
84        >label: 表示设备种类,如wifiiot
85        >serial: 表示一个串口定义
86        >serial/com 表示本地连接的串口,如COM20 serial/type 表示串口类型,cmd是命令串口,deploy是刷机串口,社区版本cmd和deploy使用同一个串口,com值相同
87        >serial/baud\_rate、data\_bits、stop\_bits、timeout: 为串口波特率等串口参数 ,一般采用默认值即可。
88
89
90    **2、测试用例目录设置**
91
92    dir: 指定测试用例目录。
93
94    **3、nfs挂载**
95
96    >![](figures/icon-note.gif) **说明:**
97    >server: nfs挂载配置,label取值为NfsServer。
98    >server/ip: 挂载环境IP地址。
99    >server/port: 挂载环境端口。
100    >server/username: 登录用户名。
101    >server/password: 登录用户密码。
102    >server/dir: 对应挂载的外部路径。
103    >server/remote: nfs服务器与xDevice执行机不在同一台机器时,remote配置为true,否则为false。
104
105-   **选定任务类型**
106-   **启动框架**
107-   **执行指令**
108
109    框架指令可以分为三组:help、list、run。在指令序列中,以run为最常用的执行指令。
110
111    **1、help**
112
113    输入help指令可以查询框架指令帮助信息。
114
115    ```
116    help:
117         use help to get information.
118    usage:
119         run:  Display a list of supported run command.
120         list: Display a list of supported device and task record.
121    Examples:
122         help run
123         help list
124    ```
125
126    >![](figures/icon-note.gif) **说明:**
127    >help run:展示run指令相关说明
128    >help list:展示 list指令相关说明
129
130    **2、list**
131
132    list指令用来展示设备和相关的任务信息
133
134    ```
135    list:
136         This command is used to display device list and task record.
137    usage:
138          list
139          list history
140          list <id>
141    Introduction:
142         list:         display device list
143         list history: display history record of a serial of tasks
144         list <id>:    display history record about task what contains specific id
145    Examples:
146         list
147         list history
148         list 6e****90
149    ```
150
151    >![](figures/icon-note.gif) **说明:**
152    >list: 展示设备信息
153    >list history: 展示任务历史信息
154    >list <id\>: 展示特定id的任务其历史信息
155
156    **3、run**
157
158    run指令主要用于执行测试任务
159
160    ```
161    run:
162         This command is used to execute the selected testcases.
163         It includes a series of processes such as use case compilation, execution, and result collection.
164    usage: run [-l TESTLIST [TESTLIST ...] | -tf TESTFILE
165                [TESTFILE ...]] [-tc TESTCASE] [-c CONFIG] [-sn DEVICE_SN]
166                [-rp REPORT_PATH [REPORT_PATH ...]]
167                [-respath RESOURCE_PATH [RESOURCE_PATH ...]]
168                [-tcpath TESTCASES_PATH [TESTCASES_PATH ...]]
169                [-ta TESTARGS [TESTARGS ...]] [-pt]
170                [-env TEST_ENVIRONMENT [TEST_ENVIRONMENT ...]]
171                [-e EXECTYPE] [-t [TESTTYPE [TESTTYPE ...]]]
172                [-td TESTDRIVER] [-tl TESTLEVEL] [-bv BUILD_VARIANT]
173                [-cov COVERAGE] [--retry RETRY] [--session SESSION]
174                [--dryrun] [--reboot-per-module] [--check-device]
175                [--repeat REPEAT]
176                action task
177    Specify tests to run.
178      positional arguments:
179       action                Specify action
180       task                  Specify task name,such as "ssts", "acts", "hits"
181    ```
182
183    >![](figures/icon-note.gif) **说明:**
184    >一个基本的run指令结构如下:
185    >```
186    >run [task name] -l module1;moudle2
187    >```
188    >task name:任务类型。一般为ssts、acts、hits。非必选项
189    >-l :指定执行测试用例,多个测试用例,中间用;隔开
190    >module:被测试的模块。一般在testcases目录下存在对应的\\.json文件
191    >此外,其他参数可以作为约束条件,附加到这个基本指令之上使用。常用的如:
192    >-sn: 过滤执行测试设备,若设置为SN1,则表示只有设备SN1执行用例
193    >-c: 重新指定user\_config.xml194    >-rp: 报告生成路径。默认为xxx/xdevice/reports目录。指定目录后,优先级:指定目录\>xxx/xdevice/reports目录。
195    >-tcpath:环境目录,默认为xxx/xdevice/testcases目录。指定目录后,优先级:指定目录\>xxx/xdevice/testcases目录
196    >-respath:测试套目录,默认为xxx/xdevice/resource目录。指定目录后,优先级:指定目录\>xxx/xdevice/resource目录
197    >--reboot-per-module: 执行前先重启设备
198
199-   **查看执行结果**
200
201    框架执行run指令,控制台会输出对应的log打印,还会生成对应的执行结果报告。如果使用了-rp参数指定报告路径,那么报告就会生成在指定的路径下。否则报告会存放在默认目录。
202
203    ```
204    当前报告目录(默认目录/指定目录)
205         ├── result(模块执行结果存放目录)
206         │     ├── <模块名>.xml
207         │     ├──  ... ...
208209         ├── log (设备和任务运行log存放目录)
210         │     ├── <设备1>.log
211         │     ├── ... ...
212         │     ├── <任务>.log
213         ├── summary_report.html(测试任务可视化报告)
214         ├── summary_report.html(测试任务数据化报告)
215         └── ... ...
216    ```
217
218
219## 相关仓<a name="section260848241"></a>
220
221[测试子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/%E6%B5%8B%E8%AF%95%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
222
223**test\_xdevice**
224
225[test\_developertest](https://gitee.com/openharmony/test_developertest/blob/master/README_zh.md)
226