0 Star 0 Fork 247

MrBarryLiang / test_developertest

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
Apache-2.0

开发者测试组件

简介

开发者基于系统新增特性可以通过开发者自己开发用例保证,对于系统已有特性的修改,也可通过修改项目中原有的测试用例保证,开发者测试旨在帮助开发者在开发阶段就能开发出高质量代码

目录

developertest/
├── aw                            # 测试框架的静态库
│   ├── cxx                      # 支持C++
│   └── python                   # 支持Python
├── config                        # 测试框架配置
│   ├── build_config.xml         # 用例编译配置
│   ├── filter_config.xml        # 用例筛选配置
│   ├── framework_config.xml     # 测试类型配置
│   └── user_config.xml          # 用户使用配置
├── examples                      # 测试用例示例
│   ├── calculator               # 计算器示例
│   └── test                     # 测试资源示例
├── src                           # 测试框架源码
│   ├── main                     # 入口函数
│   └── core                     # 测试框架核心代码
├── third_party                   # 测试框架依赖第三方组件适配
│   └── lib                      # 静态库编译配置
├── BUILD.gn                      # 测试框架编译入口
├── start.bat                     # 开发者测试入口(Windows)
└── start.sh                      # 开发者测试入口(Linux)

约束

测试工具环境依赖

  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.

使用测试框架

  • 可选,安装xdevice组件。

    1. 打开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] # 配置测试用例的编译参数,例如:

      <build>
          <example>false</example>
          <version>false</version>
          <testcase>true</testcase>
          ... ...
      </build>

      说明: 测试用例的编译参数说明如下: example:是否编译测试用例示例,默认false。 version:是否编译测试版本,默认false。 testcase:是否编译测试用例,默认true。

    2. 支持hdc连接的被测设备。

      [device] # 配置标签为usb-hdc的环境信息,测试设备的IP地址和hdc映射的端口号,例如:

      <device type="usb-hdc">
          <ip>192.168.1.1</ip>
          <port>9111</port>
          <sn></sn>
      </device>
    3. 仅支持串口的被测设备。

      [board_info] # 开发板配置信息,例如:

      <board_info>
          <board_series>hispark</board_series>
          <board_type>taurus</board_type>
          <board_product>ipcamera</board_product>
          <build_command>hb build</build_command>
      </board_info>

      说明: 开发板配置信息如下: board_series:开发板系列,默认hispark。 board_type:开发板类型,默认taurus。 board_product:目标产品,默认ipcamera。 build_command:测试版本和用例的编译命令,默认hb build。

      [device] # 配置标签为ipcamera的串口信息,COM口和波特率,例如:

      <device type="com" label="ipcamera">
          <serial>
              <com>COM1</com>
              <type>cmd</type>
              <baud_rate>115200</baud_rate>
              <data_bits>8</data_bits>
              <stop_bits>1</stop_bits>
              <timeout>1</timeout>
          </serial>
      </device>
  • 修改developertest组件配置。可选,如果测试用例已完成编译,可以直接指定测试用例的编译输出路径,测试平台执行测试用例时即不会重新编译测试用例。

    文件:config/user_config.xml。

    1. [test_cases] # 指定测试用例的输出路径,编译输出目录,例如:

      <test_cases>
          <dir>/home/opencode/out/release/tests</dir>
      </test_cases>
    2. [NFS] # 被测设备仅支持串口时配置,指定NFS的映射路径,host_dir为PC侧的NFS目录,board_dir为板侧创建的目录,例如:

      <NFS>
          <host_dir>D:\nfs</host_dir>
          <board_dir>user</board_dir>
      </NFS>
  • 测试环境准备(当被测设备仅支持串口时,需要检查)。

    • 系统镜像与文件系统已烧录进开发板,开发板上系统正常运行,在系统模式下,如shell登录时设备提示符OHOS#。
    • 开发主机和开发板串口连接正常,网口连接正常。
    • 开发主机IP与开发板IP处在同一小网网段,相互可以ping通。
    • 开发主机侧创建空目录用于开发板通过NFS挂载测试用例,并且NFS服务启动正常。
  • 运行测试套。

    • 启动测试框架,打开test/developertest目录。

      1. Windows环境启动测试框架。

        start.bat
      2. Linux环境启动测试框架。

        ./strat.sh
    • 设备形态选择。

      根据实际的开发板选择,设备形态配置:developertest/config/framework_config.xml。

    • 执行测试指令。

      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
      2. 执行测试指令示例,其中-t为必选,-ss和-tm为可选字段

        run -t ut -ss test -tm example
      3. 参数说明:指定参数可以执行特定特性、模块对应的测试套

        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
  • 测试框架帮助。

    • 帮助指令,用于查询测试平台支持哪些测试指令。

      help
  • 退出自测试平台。

    • 退出自测试平台,使用如下命令退出测试平台。

      quit

测试结果与日志

  • 通过在测试框架中执行测试指令,即可以生成测试日志和测试报告。

  • 测试结果

    • 测试用例的结果会直接显示在控制台上,执行一次的测试结果根路径如下:

      reports/xxxx-xx-xx-xx-xx-xx
    • 测试用例格式化结果。

      result/
    • 测试用例日志。

      log/plan_log_xxxx-xx-xx-xx-xx-xx.log
    • 测试报告汇总。

      summary_report.html
    • 测试报告详情。

      details_report.html
  • 测试框架日志

    reports/platform_log_xxxx-xx-xx-xx-xx-xx.log
  • 最新测试报告

    reports/latest

涉及仓

测试子系统

test_developertest

test_xdevice

Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 1. Definitions. "License" shall mean the terms and conditions for use, reproduction, and distribution as defined by Sections 1 through 9 of this document. "Licensor" shall mean the copyright owner or entity authorized by the copyright owner that is granting the License. "Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity. "You" (or "Your") shall mean an individual or Legal Entity exercising permissions granted by this License. "Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files. "Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, generated documentation, and conversions to other media types. "Work" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work (an example is provided in the Appendix below). "Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof. "Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution." "Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work. 2. Grant of Copyright License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to reproduce, prepare Derivative Works of, publicly display, publicly perform, sublicense, and distribute the Work and such Derivative Works in Source or Object form. 3. Grant of Patent License. Subject to the terms and conditions of this License, each Contributor hereby grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable (except as stated in this section) patent license to make, have made, use, offer to sell, sell, import, and otherwise transfer the Work, where such license applies only to those patent claims licensable by such Contributor that are necessarily infringed by their Contribution(s) alone or by combination of their Contribution(s) with the Work to which such Contribution(s) was submitted. If You institute patent litigation against any entity (including a cross-claim or counterclaim in a lawsuit) alleging that the Work or a Contribution incorporated within the Work constitutes direct or contributory patent infringement, then any patent licenses granted to You under this License for that Work shall terminate as of the date such litigation is filed. 4. Redistribution. You may reproduce and distribute copies of the Work or Derivative Works thereof in any medium, with or without modifications, and in Source or Object form, provided that You meet the following conditions: (a) You must give any other recipients of the Work or Derivative Works a copy of this License; and (b) You must cause any modified files to carry prominent notices stating that You changed the files; and (c) You must retain, in the Source form of any Derivative Works that You distribute, all copyright, patent, trademark, and attribution notices from the Source form of the Work, excluding those notices that do not pertain to any part of the Derivative Works; and (d) If the Work includes a "NOTICE" text file as part of its distribution, then any Derivative Works that You distribute must include a readable copy of the attribution notices contained within such NOTICE file, excluding those notices that do not pertain to any part of the Derivative Works, in at least one of the following places: within a NOTICE text file distributed as part of the Derivative Works; within the Source form or documentation, if provided along with the Derivative Works; or, within a display generated by the Derivative Works, if and wherever such third-party notices normally appear. The contents of the NOTICE file are for informational purposes only and do not modify the License. You may add Your own attribution notices within Derivative Works that You distribute, alongside or as an addendum to the NOTICE text from the Work, provided that such additional attribution notices cannot be construed as modifying the License. You may add Your own copyright statement to Your modifications and may provide additional or different license terms and conditions for use, reproduction, or distribution of Your modifications, or for any such Derivative Works as a whole, provided Your use, reproduction, and distribution of the Work otherwise complies with the conditions stated in this License. 5. Submission of Contributions. Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions. 6. Trademarks. This License does not grant permission to use the trade names, trademarks, service marks, or product names of the Licensor, except as required for reasonable and customary use in describing the origin of the Work and reproducing the content of the NOTICE file. 7. Disclaimer of Warranty. Unless required by applicable law or agreed to in writing, Licensor provides the Work (and each Contributor provides its Contributions) on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied, including, without limitation, any warranties or conditions of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are solely responsible for determining the appropriateness of using or redistributing the Work and assume any risks associated with Your exercise of permissions under this License. 8. Limitation of Liability. In no event and under no legal theory, whether in tort (including negligence), contract, or otherwise, unless required by applicable law (such as deliberate and grossly negligent acts) or agreed to in writing, shall any Contributor be liable to You for damages, including any direct, indirect, special, incidental, or consequential damages of any character arising as a result of this License or out of the use or inability to use the Work (including but not limited to damages for loss of goodwill, work stoppage, computer failure or malfunction, or any and all other commercial damages or losses), even if such Contributor has been advised of the possibility of such damages. 9. Accepting Warranty or Additional Liability. While redistributing the Work or Derivative Works thereof, You may choose to offer, and charge a fee for, acceptance of support, warranty, indemnity, or other liability obligations and/or rights consistent with this License. However, in accepting such obligations, You may act only on Your own behalf and on Your sole responsibility, not on behalf of any other Contributor, and only if You agree to indemnify, defend, and hold each Contributor harmless for any liability incurred by, or claims asserted against, such Contributor by reason of your accepting any such warranty or additional liability. END OF TERMS AND CONDITIONS

简介

Development self-test framework | 开发者自测试框架 展开 收起
Apache-2.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
1
https://gitee.com/mrbarryliang/test_developertest.git
git@gitee.com:mrbarryliang/test_developertest.git
mrbarryliang
test_developertest
test_developertest
master

搜索帮助

14c37bed 8189591 565d56ea 8189591