Go to file
zhouke 2e4b7532a7 子系统名称调整为testfwk.Signed-off-by: <zhouke35@huawei.com>.
Signed-off-by: zhouke <zhouke35@huawei.com>
2023-04-27 17:41:49 +08:00
aw Signed-off-by: yuyan0428 <yuyan12@huawei.com> 2023-01-17 08:43:49 +00:00
config Signed-off-by:caojiale1<caojiale1@huawei.com> 2023-02-27 16:39:45 +08:00
examples Signed-off-by caojiale1 caojiale1@huawei.com 2023-04-20 18:10:47 +08:00
libs modify code path 2022-09-13 21:49:11 +08:00
localCoverage Signed-off-by caojiale1 caojiale1@huawei.com 2023-04-27 12:15:36 +08:00
public_sys-resources update OpenHarmony 2.0 Canary 2021-06-02 04:17:50 +08:00
signature add js test framework 2021-09-06 20:12:37 +08:00
src Signed-off-by caojiale1 caojiale1@huawei.com 2023-04-25 15:53:03 +08:00
third_party/lib/cpp switch path deps on utils to commonlibrary 2022-07-30 16:46:43 +08:00
.gitattributes update OpenHarmony 2.0 Canary 2021-06-02 04:17:50 +08:00
BUILD.gn switch path deps on utils to commonlibrary 2022-07-30 16:46:43 +08:00
bundle.json 子系统名称调整为testfwk.Signed-off-by: <zhouke35@huawei.com>. 2023-04-27 17:41:49 +08:00
install.sh 修改copyright时间为2022 2022-09-13 17:59:51 +08:00
LICENSE add OpenHarmony 1.0 baseline 2020-09-08 10:21:39 +08:00
OAT.xml update OAT.xml for OAT warning 2021-09-27 06:29:57 +00:00
ohtest 修改copyright时间为2022 2022-09-13 17:59:51 +08:00
README_zh.md Signed-off-by caojiale1 caojiale1@huawei.com 2023-04-20 18:10:47 +08:00
README.md readme中testing subsystem链接更改 2023-04-20 09:41:08 +00:00
start.bat update openharmony 1.0.1 2021-03-11 18:42:47 +08:00
start.sh update openharmony 1.0.1 2021-03-11 18:42:47 +08:00

Developers Test

Overview

This module allows you to develop new test cases for new features, or modify existing test cases for modified features. The developers test framework helps you develop high-quality code.

Directory Structure

developertest/
├── aw                            # Static libraries of the test framework
│   ├── cxx                      # C++ libraries
│   └── python                   # Python libraries
├── config                        # Test framework configuration
│   ├── build_config.xml         # Test case build configuration
│   ├── filter_config.xml        # Test case filter configuration
│   ├── framework_config.xml     # Test type configuration
│   └── user_config.xml          # User configuration
├── examples                      # Test case examples
│   ├── calculator               # Calculator
│   └── test                     # Test resources
├── src                           # Source code of the test framework
│   ├── main                     # Entry function
│   └── core                     # Core code of the test framework
├── third_party                   # Adaptation code for third-party components on which the test framework relies
│   └── lib                      # Compilation configuration of the static library
├── BUILD.gn                      # Compilation entry of the test framework
├── start.bat                     # Developers test entry for Windows
└── start.sh                      # Developers test entry for Linux

Constraints

The test tool environment must meet the following requirements:

  1. Python version: 3.7.5 or later
  2. Paramiko version: 2.7.1 or later
  3. Setuptools version: 40.8.0 or later
  4. RSA version: 4.0 or later
  5. NFS version: V4 or later required when device supports connection using the serial port but not the hdc
  6. pySerial version: 3.3 or later required when the device supports connection using the serial port but not the hdc
  7. OS version: Windows 10 or later; Ubuntu 18.04

Installation

The Python environment is required.

  1. Run the following command to install the Linux extension component 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. Run the following command to install the plug-in Setuptools:

    pip3 install setuptools
    

    If the installation is successful, the following prompts are displayed:

    Requirement already satisfied: setuptools in d:\programs\python37\lib\site-packages (41.2.0)
    
  3. Run the following command to install the plug-in Paramiko:

    pip3 install paramiko
    

    If the installation is successful, the following prompts are displayed:

    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. Run the following command to install the Python plug-in RSA:

    pip3 install rsa
    

    If the installation is successful, the following prompts are displayed:

    Installing collected packages: pyasn1, rsa
    Successfully installed pyasn1-0.4.8 rsa-4.7
    
  5. Run the following command to install the serial port plug-in pySerial for Python on the local PC:

    pip3 install pyserial
    

    If the installation is successful, the following prompts are displayed:

    Requirement already satisfied: pyserial in d:\programs\python37\lib\site-packages\pyserial-3.4-py3.7.egg (3.4)
    
  6. If the device supports test result output only using the serial port, install the NFS server.

    For example, to install haneWIN NFS Server 1.2.50 for Windows, download the installation package from https://www.hanewin.net/nfs-e.htm.

    For Linux, run the following command:

    sudo apt install nfs-kernel-server
    

    If the installation is successful, the following prompts are displayed:

    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.
    

Using Test Framework

  • Optional Install the XDevice module.

    1. Go to the XDevice installation directory test/xdevice.

    2. Open the console and run the following command:

      python setup.py install
      

      If the installation is successful, the following prompts are displayed:

      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
      
  • Configure the developers test module in the configuration file developertest/config/user_config.xml.

    1. Modify basic configuration parameters of the test framework.

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

      NOTE: example: whether to build the test case example. The default value is false. version: whether to build the test version. The default value is false. testcase: whether to build the test case. The default value is true.

    2. For devices that support the Harmony device connector hdc, modify the configuration file as follows:

      device
      <device type="usb-hdc">
          <ip>192.168.1.1</ip>
          <port>9111</port>
          <sn></sn>
      </device>
      
    3. For devices that only support the serial port connection, modify the configuration file as follows:

      device
      <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>
      
  • Optional Modify the configuration file config/user_config.xml of the developertest module. If a test case has been compiled, specify the compilation output directory of the test case. In this case, the test platform will not recompile the test case.

    1. Specify the output directory of the test case, that is, the compilation output directory between the <test_cases> tags.

      <test_cases>
          <dir>/home/opencode/out/release/tests</dir>
      </test_cases>
      
    2. For devices that only support serial port connection, specify the NFS directory on the PC **host\_dir** and the corresponding directory on the board **board\_dir** between the <NFS> tags. For example:

      <NFS>
          <host_dir>D:\nfs</host_dir>
          <board_dir>user</board_dir>
      </NFS>
      
  • Prepare the test environment. Check that the test environment is ready if the tested device only supports serial port connection.

    • The system image and file system have been burnt into a development board and are running properly on the development board. For example, in system mode, device prompt OHOS# is displayed during shell login, indicating that the system is running properly.
    • The development host has been connected to the serial port of the development board and the network port.
    • The IP addresses of the development host and development board are in the same network segment and can ping each other.
    • An empty directory is created on the development host for mounting test cases through the NFS, and the NFS service is started properly.
  • Run test suites.

    • Start the test framework and go to the test/developertest directory.

      1. Run the following command to start the test framework in Windows.

        start.bat
        
      2. Run the following command to start the test framework in Linux.

        ./strat.sh
        
    • Select a device form.

      Configure device forms based on the actual development board, for example, developertest/config/framework_config.xml.

    • Run test commands.

      1. To query the subsystems, modules, product forms, and test types supported by test cases, run the show commands.

        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. Run the execution command, where -t is mandatory, and -ss and -tm are optional.

        run -t ut -ss test -tm example
        
      3. Specify the parameters that can be used to execute the test suite corresponding to a specific feature or module.

        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
        
  • See the test framework help if needed.

    • Run the following command to query commands supported by the test platform:

      help
      
  • Exit the self-test platform.

    • Run the following command to exit the test platform:

      quit
      

Test Result and Log

  • Test logs and test reports are generated after you execute the test commands.

  • Test result

    • Reports are displayed on the console. The root path of the test result is as follows:

      reports/xxxx-xx-xx-xx-xx-xx
      
    • Test case formatting result

      result/
      
    • Test case log

      log/plan_log_xxxx-xx-xx-xx-xx-xx.log
      
    • Report summary

      summary_report.html
      
    • Test report details

      details_report.html
      
  • Test framework log

    reports/platform_log_xxxx-xx-xx-xx-xx-xx.log
    
  • Latest test reports

    reports/latest
    

Repositories Involved

testing subsystem

test_developertest

test_xdevice