1a69a01cdSopenharmony_ci# wukong
2a69a01cdSopenharmony_ci## Introduction
3a69a01cdSopenharmony_ci
4a69a01cdSopenharmony_ciOpenHarmony stability testing automation tool simulates disorderly user behavior to stress test the stability of OpenHarmony systems and applications.<br>
5a69a01cdSopenharmony_ci
6a69a01cdSopenharmony_ciwukong component architecture diagram<br>
7a69a01cdSopenharmony_ci![架构图](figures/wukongArchitectureDiagram.png)<br>
8a69a01cdSopenharmony_ci
9a69a01cdSopenharmony_ciSubmodule responsibilities within the component:<br>
10a69a01cdSopenharmony_ci1. Command line parsing: allows you to obtain and parse parameters on the command line.<br>
11a69a01cdSopenharmony_ci2. Running environment management: Initialize the overall wukong running environment according to the command line.<br>
12a69a01cdSopenharmony_ci3. System interface management: Check and get the specified mgr, register controller and dfx faultlog callback functions.<br>
13a69a01cdSopenharmony_ci4. Random event generation: Generate a random sequence with a specified number of seeds through the random function to generate events.<br>
14a69a01cdSopenharmony_ci5. Event injection: Inject events into the system based on supported event types, relying on subsystems such as Windows, multimode, and security.<br>
15a69a01cdSopenharmony_ci6. Exception capture and processing/report generation: The DFX subsystem obtains anomaly information in operation and records logs to generate reports.<br>
16a69a01cdSopenharmony_ci
17a69a01cdSopenharmony_ci## Directory
18a69a01cdSopenharmony_ci
19a69a01cdSopenharmony_ci```
20a69a01cdSopenharmony_ci├── wukong                              # wukong main code file
21a69a01cdSopenharmony_ci|   └── common                          # Provides application control capabilities, random event injection capabilities, multi-mode event injection capabilities
22a69a01cdSopenharmony_ci|   └── component_event                 # Define the ability, page, Component tree to provide the ability to add nodes, traverse the tree, find child nodes by NodeId, etc
23a69a01cdSopenharmony_ci|   └── input_factory                   # Realize the screen click, slide, drag, keyboard and other events injection ability    
24a69a01cdSopenharmony_ci|   └── report                          # Monitor abnormal information, collect, collect statistics, and display it
25a69a01cdSopenharmony_ci|   └── shell_command                   # Used to create a command line map, parse the command line parameters, and execute the command line              
26a69a01cdSopenharmony_ci|   └── test_flow                                  
27a69a01cdSopenharmony_ci│       └── include                     # Defining Header files
28a69a01cdSopenharmony_ci│       └── src                     
29a69a01cdSopenharmony_ci│           ├── random_test_flow.cpp    # Inherited from TestFlow, is the execution flow of random tests
30a69a01cdSopenharmony_ci│           ├── special_test_flow.cpp   # Inherited from TestFlow, is the execution flow of sequential specific tests
31a69a01cdSopenharmony_ci│           ├── focus_test_flow.cpp     # Inherited from TestFlow, is the execution flow of focus specific tests
32a69a01cdSopenharmony_ci│           ├── test_flow.cpp           # Check whether the command line parameters conform to specifications
33a69a01cdSopenharmony_ci│   ── BUILD.gn                         # Store the configuration of wukong construction, including construction object, method, dependency, hardware architecture, and file format
34a69a01cdSopenharmony_ci│   ── README_zh.md                     # The readme file
35a69a01cdSopenharmony_ci```
36a69a01cdSopenharmony_ci
37a69a01cdSopenharmony_ci## Constraints
38a69a01cdSopenharmony_ci
39a69a01cdSopenharmony_ci1. wukong began presetting after system version 3.2<br>
40a69a01cdSopenharmony_ci2. Versions of wukong prior to version 3.2 do not compile with the version. When using wukong, you need to compile and push it to the OpenHarmony device under test. The procedure is as follows:<br>
41a69a01cdSopenharmony_ci    2.1. Build a way
42a69a01cdSopenharmony_ci    ```
43a69a01cdSopenharmony_ci    ./build.sh --product-name rk3568 --build-target wukong
44a69a01cdSopenharmony_ci    ```
45a69a01cdSopenharmony_ci    2.2. push
46a69a01cdSopenharmony_ci    ```
47a69a01cdSopenharmony_ci    hdc_std shell mount -o rw,remount /
48a69a01cdSopenharmony_ci    hdc_std file send wukong /
49a69a01cdSopenharmony_ci    hdc_std shell chmod a+x /wukong
50a69a01cdSopenharmony_ci    hdc_std shell mv /wukong /bin/
51a69a01cdSopenharmony_ci    ```
52a69a01cdSopenharmony_ci
53a69a01cdSopenharmony_ci## Directions for use
54a69a01cdSopenharmony_ci
55a69a01cdSopenharmony_ci### Function Features and Command Description
56a69a01cdSopenharmony_ci
57a69a01cdSopenharmony_ci
58a69a01cdSopenharmony_ci| Command | Description | Note |
59a69a01cdSopenharmony_ci| -------------- | ---------------------------------------------- | ------------- |
60a69a01cdSopenharmony_ci| wukong version | Get wukong version information | -v, --version |
61a69a01cdSopenharmony_ci| wukong help    | Get wukong help information |               |
62a69a01cdSopenharmony_ci| wukong appinfo | Query support pulling up the application bundleName and the corresponding mainAbility name |               |
63a69a01cdSopenharmony_ci| wukong special | wukong special test |               |
64a69a01cdSopenharmony_ci| wukong exec    | wukong randomly tests |               |
65a69a01cdSopenharmony_ci| wukong focus   | wukong focus tests |               |
66a69a01cdSopenharmony_ci
67a69a01cdSopenharmony_ci
68a69a01cdSopenharmony_ci### wukong special description
69a69a01cdSopenharmony_ci
70a69a01cdSopenharmony_ci| Command | Features | Required | Note |
71a69a01cdSopenharmony_ci| :------------------ | ---------------------- | ---- | :------------------ |
72a69a01cdSopenharmony_ci| -h, --help          | Get help information for the current test. | No | Specialized test help information. |
73a69a01cdSopenharmony_ci| -k, --spec_insomnia | Sleep wake-up special test. | No | -                   |
74a69a01cdSopenharmony_ci| -c, --count         | Set the Number of executions. | No | The default is 10 times. |
75a69a01cdSopenharmony_ci| -i, --interval      | Set the execution interval. | No | Unit ms, default 1500ms. |
76a69a01cdSopenharmony_ci| -S, --swap          | Sliding test. | No | -                   |
77a69a01cdSopenharmony_ci| -s, --start[x,y]    | Set the slide test start coordinates. | No | -                   |
78a69a01cdSopenharmony_ci| -e, --end[x,y]      | Set the slide test end coordinates. | No | -                   |
79a69a01cdSopenharmony_ci| -b, --bilateral     | Set the round-trip swipe. | No | By default, there is no round-trip swipe. |
80a69a01cdSopenharmony_ci| -t, --touch[x,y]    | Click test. | No | -                   |
81a69a01cdSopenharmony_ci| -T, --time          | Set the total test time. | No | Unit minutes, the default is 10 minutes. |
82a69a01cdSopenharmony_ci| -p, --screenshot  | Screenshot of control testing. | No | -|
83a69a01cdSopenharmony_ci| -C, --component     | The control sequentially traverses the test. | No | You need to set the test app name. |
84a69a01cdSopenharmony_ci
85a69a01cdSopenharmony_ci#### Example of wukong Special test
86a69a01cdSopenharmony_ci```bash
87a69a01cdSopenharmony_ci> hdc_std shell
88a69a01cdSopenharmony_ci# wukong special -C [bundlename] -p
89a69a01cdSopenharmony_ci```
90a69a01cdSopenharmony_ciSpecific test example parsing:
91a69a01cdSopenharmony_ci| Command           | Parameter Value     | Description                                           |
92a69a01cdSopenharmony_ci| -------------- | -------------- | ---------------------------------------------- |
93a69a01cdSopenharmony_ci| wukong special |  | The main commands.                             |
94a69a01cdSopenharmony_ci| -C [bundlename] |[bundlename]| Control to sequentially traverse the test parameter Settings, bundlename is the name of the test application.    |
95a69a01cdSopenharmony_ci| -p | | Represents a screenshot.                             |
96a69a01cdSopenharmony_ci
97a69a01cdSopenharmony_ci### wukong random description
98a69a01cdSopenharmony_ci
99a69a01cdSopenharmony_ci| Command | Features | Required | Note |
100a69a01cdSopenharmony_ci| --------------- | ------------------------------------ | ---- | ---------------------------------------- |
101a69a01cdSopenharmony_ci| -h,--help       | Get help information for the current test. | No | Random test help information. |
102a69a01cdSopenharmony_ci| -c,--count      | Set the Number of executions, conflicts with -T. | No | The number of units, the default is 10 times. |
103a69a01cdSopenharmony_ci| -i,--interval   | Set the execution interval. | No | Unit ms, default 1500ms. |
104a69a01cdSopenharmony_ci| -s,--seed       | Set the Random Seed. | No | Configuring the same random seed results in the same random event sequence. |
105a69a01cdSopenharmony_ci| -b,--bundle[bundlename,......,bundlename]     | Set the list of allowed applications for this test, and the -p conflict. | No | By default, test all apps for the current device (app names separated by commas). |
106a69a01cdSopenharmony_ci| -p,--prohibit[bundlename,......,bundlename]   | Set the list of prohibited apps for this test, which conflicts with -b. | No | By default, no applications are prohibited (application names are separated by commas). |
107a69a01cdSopenharmony_ci| -d,--page[page,……,page]                   | Set the list of prohibited pages for this test | Np  | The system default prohibits pages/system pages (page names separated by commas). |
108a69a01cdSopenharmony_ci| -a,--appswitch  | Set the app random pull-up test scale. | No | The default 10%. |
109a69a01cdSopenharmony_ci| -t,--touch      | Set the screen random touch test ratio. | No | The default 10%. |
110a69a01cdSopenharmony_ci| -S,--swap       | Set the screen random swap test scale. | No | The default 3%. |
111a69a01cdSopenharmony_ci| -m,--mouse      | Set the screen randommou test ratio. | No | The default 1%. |
112a69a01cdSopenharmony_ci| -k,--keyboard   | Set the screen random keyboard test ratio. | No | The default 2%. |
113a69a01cdSopenharmony_ci| -H,--hardkey    | Set the random hardkey test scale. | No | The default 2%. |
114a69a01cdSopenharmony_ci| -r,--rotate     | Set the random rotate test scale.  | No | The default 2%. |
115a69a01cdSopenharmony_ci| -C, --component | Set the Random Control Test Scale. | No | The default 70%. |
116a69a01cdSopenharmony_ci| -I, --screenshot  | Screenshot of control testing. | No | -|
117a69a01cdSopenharmony_ci| -T,--time       | Set the total test time, conflicts with -c. | No | Unit minutes, the default is 10 minutes. |
118a69a01cdSopenharmony_ci
119a69a01cdSopenharmony_ci> Instructions: Configuring the same random seed results in the same sequence of random events
120a69a01cdSopenharmony_ci
121a69a01cdSopenharmony_ci#### Example of wukong exec random test
122a69a01cdSopenharmony_ci```bash
123a69a01cdSopenharmony_ci> hdc_std shell
124a69a01cdSopenharmony_ci# wukong exec -s 10 -i 1000 -a 0.28 -t 0.72 -c 100
125a69a01cdSopenharmony_ci```
126a69a01cdSopenharmony_ciRandom test example parsing:
127a69a01cdSopenharmony_ci| Command           | Parameter Value     | Description                                           |
128a69a01cdSopenharmony_ci| -------------- | --------------     | ---------------------------------------------- |
129a69a01cdSopenharmony_ci| wukong exec |       | The main command.                             |
130a69a01cdSopenharmony_ci| -s  | 10    | Parameter set random seed, 10 is the seed value.           |
131a69a01cdSopenharmony_ci| -i  | 1000   | Parameter Settings apply pull up interval, 1000 unit ms. |
132a69a01cdSopenharmony_ci| -a  | 0.28   | Parameter Settings Apply random pull up test ratio 28%.         |
133a69a01cdSopenharmony_ci| -t  | 0.72   | Parameter Settings Screen random touch test proportion is 72%.    |
134a69a01cdSopenharmony_ci| -c  | 100  | Parameter Setting The number of execution times is 100.                |
135a69a01cdSopenharmony_ci
136a69a01cdSopenharmony_ci### wukong random description
137a69a01cdSopenharmony_ci
138a69a01cdSopenharmony_ci| Command | Features | Required | Note |
139a69a01cdSopenharmony_ci| --------------- | ------------------------------------ | ---- | ---------------------------------------- |
140a69a01cdSopenharmony_ci| -n,--numberfocus| Set focus number for components.     | No   |                                          |
141a69a01cdSopenharmony_ci| -f, --focustypes| Set the component type to focus on.  | No   | "," to split if more than one.           |
142a69a01cdSopenharmony_ciOther params are same as exec.
143a69a01cdSopenharmony_ci
144a69a01cdSopenharmony_ci
145a69a01cdSopenharmony_ci## Release notes
146a69a01cdSopenharmony_ci
147a69a01cdSopenharmony_ci3.2.0.0 Release content: Preset wukong supports the following functions:<br>
148a69a01cdSopenharmony_ci1. Support the whole machine application pull up, set the random seed, set the application pull up interval, set the application pull up times, support the query application pull up bundle name and ability name.<br>
149a69a01cdSopenharmony_ci2. Support random injection of events, support random injection of controls, support sleep and wake up special tests, support control sequence traversal screenshots special tests.<br>
150a69a01cdSopenharmony_ci3. Supports wukong run log printing.<br>
151a69a01cdSopenharmony_ci4. White and blacklist applications are supported.