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