# Testing - [Overview](#section12403172115920) - [Basic Concepts](#section53632272090) - [Working Principles](#section2394431106) - [Limitations and Constraints](#section2029921310472) - [Setting Up a Test Environment](#section175012297491) - [Environment Requirements](#section935055691014) - [Installing the Environment](#section6511193210111) - [Verifying the Test Environment](#section1899144517117) - [Development Guidelines](#section16741101301210) - [When to Use](#section93782214124) - [Available APIs](#section54131732101218) - [How to Develop](#section53541946111218) - [Development Example](#section7477121918136) - [How to Use the Test Platform](#section76401945124810) - [Directory Structure](#section1875515364133) ## Overview ### Basic Concepts The testing subsystem provides a one-click Python-based self-test platform for developers. It supports cross-platform tests and extension to third-party testing frameworks. The subsystem consists of modules for compiling, managing, scheduling and distributing, and executing test cases, collecting test results, generating test reports, creating test case templates, managing test environments, and many others. Before development using the testing subsystem, you need to understand the following concepts: - Test case compilation This operation compiles the source code of test cases into binary files that can be executed on the tested device. - Test case scheduling & distributing This operation distributes test cases to different tested devices through the network port or serial port, and allocates a specific executor for each test case. - Test case executor A test case executor defines the execution logic of each test case, such as its pre-processing, execution, and result recording. - Test case template A test case template defines respective unified formats for test cases and for GN files. - Test platform kits The test platform provides common methods to be used during the running of the test tool, for example, providing the test case directory to mount the file system to a tested device, distributing test cases to the tested device, or obtaining test results from the tested device. - Test report generation This operation defines a template for generating self-test reports and web test reports. - Test environment management The tested devices can be managed through the USB port or serial port, including discovering a device and querying the device status. ### Working Principles - The following figure shows the architecture of the test platform. **Figure 1** Platform architecture ![](figure/platform-architecture.png "platform-architecture") - The following figure shows the running sequence diagram of the test platform. **Figure 2** Running sequence of the test platform ![](figure/running-sequence-of-the-test-platform.png "running-sequence-of-the-test-platform") - Working principle of the test platform The test platform is started using a shell script. It executes a series of testing commands entered on the command line interface \(CLI\) and prints the command output. ## Limitations and Constraints - The self-test platform supports only code-level test case development and verification, such as unit testing and module testing. - Currently, the testing framework supports only white-box testing. - Only one test platform can be started on a testing device. ## Setting Up a Test Environment ### Environment Requirements **Table 1** Environment requirements