• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# wukong User Guide
2
3## Introduction
4
5wukong is a built-in command line tool that implements application stability test capabilities such as random event injection, component injection, exception capture, report generation, and data traversal of abilities. This tool allows you to conduct stability tests on the system or applications by simulating user behavior. wukong provides three types of testing: random testing, special testing, and focus testing.
6
7In random testing, test inputs are generated randomly. Available features include shell startup, whole application startup, multiple injection modes, random seeds setting, run log printing, and report generation.
8
9In special testing, specific application components are tested. Available features include shell startup, sequential traversal and screenshot, sleep and wakeup test, recording and playback, run log printing, and report generation.
10
11In focus testing, specific components are injected. Available features include shell startup, device application startup, multiple injection modes, random seed setting, focus component type setting, component injection times setting, run log printing, and report generation.
12
13## Principles
14
15The following figure shows the wukong component architecture and the responsibilities of sub-modules.
16![Alternate text](figures/wukongRandomTestFlow.png)
17
18- Command line parsing: Obtain and parse parameters using commands.
19- Operating environment management: Initialize the overall operating environment of wukong using commands.
20- System API management: Check and obtain the specified mgr, and register the callback function of the Faultlogger for the controller and DFX.
21- Random event generation: Use the **random** function to generate a sequence of random numbers with the specified seed value to generate an event.
22- Event injection: Inject events of supported types to the system. This feature depends on the window, multi-mode, and security subsystems.
23- Exception capture and processing and report generation: Obtain exception information with the DFX subsystem during application running, record log, and generate reports.
24
25## Constraints
26
271. The wukong tool is built in the system since API version 9.
28
292. In API versions earlier than 9, you need to build the tool and push it to the target device. The procedure is as follows:
30
31   ```bash
32   // Build code.
33   ./build.sh --product-name rk3568 --build-target wukong
34
35   // Push code.
36   hdc shell mount -o rw,remount /
37   hdc file send wukong /
38   hdc shell chmod a+x /wukong
39   hdc shell mv /wukong /bin/
40   ```
41
423. When the PC is connected to one or more target devices, you can run test commands.
43
444. Enter the shell mode before running any command.
45
46## Functions and Commands
47
48| Command          | Description                                          |
49| -------------- | ---------------------------------------------- |
50| version | Obtains version information.                            |
51| help    | Obtains help information.                            |
52| appinfo | Queries the bundle name and the name of the corresponding mainAbility of the app that can be started.|
53| special | Runs special testing.                                  |
54| exec    | Runs random testing.                                  |
55| focus   | Runs focus testing.                                  |
56
57### Running Commands
58
59- Open the shell.
60
61  ```bash
62  #If you are testing one device, run **hdc shell**.
63  C:\Users>hdc shell
64  #
65
66  #If you are testing multiple devices, run **hdc list targets** to obtain the SNs, and then run **hdc -t** open the shell.
67  C:\Users>hdc list targets
68  15xxx424axxxx345209d94xxxx8fxx900
69  C:\Users>hdc -t 15xxx424axxxx345209d94xxxx8fxx900 shell
70  #
71  ```
72
73- Obtain the bundle name and ability name of the application.
74
75  ```bash
76  # wukong appinfo
77  BundleName:  com.ohos.adminprovisioning
78  AbilityName:  com.ohos.adminprovisioning.MainAbility
79  BundleName:  com.ohos.callui
80  AbilityName:  com.ohos.callui.MainAbility
81  ```
82- View the help information.
83
84  ```bash
85  C:\Users>hdc shell
86  # wukong --help        // wukong help menu.
87  wukong: '--help' is not a valid wukong command. See 'wukong help'.
88  usage: wukong <command> [<arguments>]
89  These are common wukong command list:
90    help                       wukong help information
91    -v/--version               wukong version
92    exec                       run random test
93    special                    run special test
94    focus                      run focus test
95    appinfo                    show all app information
96  # wukong exec -help   // Help menu for wukong random testing.
97  usage: wukong exec [<arguments>]
98  These are wukong exec arguments list:
99    -h, --help                 random test help
100    -a, --appswitch            appswitch event percent
101    -b, --bundle               the bundle name of allowlist
102    -p, --prohibit             the bundle name of blocklist
103    -d, --page                 block page list
104    -t, --touch                touch event percent
105    -c, --count                test count
106    -i, --interval             interval
107    -s, --seed                 random seed
108    -m, --mouse                mouse event percent
109    -k, --keyboard             keyboard event percent
110    -H, --hardkey              hardkey event percent
111    -S, --swap                 swap event percent
112    -T, --time                 test time
113    -C, --component            component event percent
114    -r, --rotate               rotate event percent
115    -e, --allow ability        the ability name of allowlist
116    -E, --block ability        the ability name of blocklist
117    -Y, --blockCompId          the id list of block component
118    -y, --blockCompType        the type list of block component
119    -I, --screenshot           get screenshot(only in random input)
120    -B, --checkBWScreen        black and white screen detection
121    -U, --Uri                  set Uri pages
122    -x, --Uri-type             set Uri-type
123  # wukong special -help    // Help menu for wukong special testing.
124  usage: wukong special [<arguments>]
125  These are wukong special arguments list:
126    -h, --help                 special test help
127    -t, --touch[x,y]           touch event
128    -c, --count                total count of test
129    -i, --interval             interval
130    -S, --swap[option]         swap event
131                                option is -s| -e| -b
132                                -s, --start: the start point of swap
133                                -e, --end: the end point of swap
134                                -b, --bilateral: swap go and back
135    -k, --spec_insomnia        power on/off event
136    -T, --time                 total time of test
137    -C, --component            component event
138    -p, --screenshot           get screenshot(only in componment input)
139    -r, --record               record user operation
140    -R, --replay               replay user operation
141    -u, --uitest               uitest dumpLayout
142  ```
143
144## Random Testing
145
146### Commands
147
148| Command           | Description                                | Mandatory| Description                                    |
149| --------------- | ------------------------------------ | ---- | ---------------------------------------- |
150| -h,--help       | Obtains the help information about the test.              | No  |  -                        |
151| -c,--count      | Sets the number of execution times. This command conflicts with the **-T** command. Set either of them.  | No  | The default value is 10, in times.                      |
152| -i,--interval   | Sets the test interval.                        | No  | The default value is 1500, in millisecond.                      |
153| -s,--seed       | Sets the random seed.                        | No  | If the same random seed is set, the same random event sequence is generated.|
154| -b,--bundle[bundlename, ......, bundlename]    | Sets allowed bundles for the test. This command conflicts with the **-p** command.| No  | By default, all bundles on the device are allowed. Use commas (,) to separate bundle names.                |
155| -p,--prohibit[bundlename, ......, bundlename]  | Sets blocked bundles for the test. This command conflicts with the **-b** command.| No  | By default, no bundle is blocked. Use commas (,) to separate bundle names.                      |
156| -d,--page[page, ......, page]                  | Sets blocked pages for the test.| No | By default, the **pages/system** pages are blocked. Use commas (,) to separate page names.|
157| -a,--appswitch  | Sets the proportion of the random application startup event test.            | No  | The default value is 10%.                                 |
158| -t,--touch      | Sets the proportion of the random touch event test.           | No  | The default value is 10%.                                 |
159| -S,--swap       | Sets the proportion of the random swipe event test.            | No  | The default value is 3%.                                  |
160| -m,--mouse      | Sets the proportion of the random mouse event test.           | No  | The default value is 1%.                                  |
161| -k,--keyboard   | Sets the proportion of the random keyboard event test.        | No  | The default value is 2%.                                  |
162| -H,--hardkey    | Sets the proportion of the random hardkey test.             | No  | The default value is 2%.                                  |
163| -r,--rotate     | Sets the proportion of the random rotate event test.              | No  | The default value is 2%.                                  |
164| -C, --component | Sets the proportion of random component test.                | No  | The default value is 70%.                                 |
165| -I, --screenshot | Takes a screenshot for the component test.                | No  | - |
166| -T,--time       | Sets the total test time. This command conflicts with the **-c** command. Set either of them.| No  | The default value is 10, in minute.        |
167| -e, --allow ability   |  Sets the ability that allows testing.| No| - |
168| -E, --block ability   |  Sets the ability that blocks testing.| No| - |
169| -Y, --blockCompId     |  Sets the blocked **CompId**.| No| - |
170| -y, --blockCompType   |  Sets the blocked **CompType**.| No| - |
171| -B, --checkBWScreen   |  Enables black and white screen check.| No| - |
172| -U, -uri              |  Sets the URI of the application startup page.| No| - |
173| -x, -uriType          |  Sets the URI type of the application startup page.| No| - |
174
175### Samples
176
177- Set 100 event injections.
178
179  ```bash
180  # wukong exec -s 10 -i 1000 -a 0.28 -t 0.72 -c 100
181  ```
182
183  The parameters in the command are described as follows.
184  | Command          | Value     |Description       |
185  | -------------- | -------------- | -------------- |
186  | wukong exec | -           | Works as the main command.               |
187  | -s     | 10           | Sets the random seed. The seed value is **10**. |
188  | -i  | 1000           | Sets the application startup interval to **1000** ms.|
189  | -a  | 0.28          | Sets the proportion of the random application startup test to **28%**.   |
190  | -t  | 0.72           | Sets the proportion of the random touch test to **72%**.   |
191  | -c  | 100           | Sets the number of execution times to **100**.        |
192
193- Specify a page to perform a pressure test.
194
195  ```bash
196  > Explicit start
197  > hdc_std shell
198  # wukong exec -b bundlename -a abilityname -U uri
199
200  > Implicit start
201  > hdc_std shell
202  # wukong exec -b bundlename -U uri -x uriType
203  ```
204
205- Set the ability that allows and blocks testing.
206  ```bash
207  # wukong exec -b com.ohos.settings -e com.ohos.settings.MainAbility -E com.ohos.settings.AppInfoAbility
208  ```
209  >  **NOTE**
210  >
211  > If **-e** and **-E** are set, you must set **-b** to specify an application.
212
213## Special Testing
214
215### Commands
216
217| Command               | Description                  | Mandatory| Description               |
218| :------------------ | ---------------------- | ---- | :------------------ |
219| -h, --help          | Obtains the help information about the special testing.| No  |  -    |
220| -k, --spec_insomnia | Powers on/off the special testing.      | No  | -                   |
221| -c, --count         | Sets the number of test times.          | No  | The default value is 10, in times.         |
222| -i, --interval      | Sets the test interval.          | No  | The default value is 1500, in millisecond. |
223| -S, --swap          | Sets a swipe event for the test.              | No  | -                   |
224| -s, --start[x,y]    | Sets the coordinates of the start point of the swipe event.  | No  | The values of coordinates are positive.          |
225| -e, --end[x,y]      | Sets the coordinates of the end point of the swipe event.  | No  | The values of coordinates are positive.         |
226| -b, --bilateral     | Sets a back and forth swipe event.          | No  | By default, the back and forth swipe event is disabled.     |
227| -t, --touch[x,y]    | Sets a touch event for the test.              | No  | -                   |
228| -T, --time          | Sets the total test time.        | No  | The default value is 10, in minute.|
229| -C, --component     | Sets the sequential traversal test for components.      | No  | You need to set the name of the test application.|
230| -r, --record     | Records user operation.      | No  | You need to specify the recording file.|
231| -R, --replay    |  Replays user operation.     | No  | You need to specify the playback file.|
232| -p, --screenshot    |  Takes a screenshot for the component test.     | No  | - |
233
234### Samples
235
236```bash
237# wukong special -C [bundlename] -p
238```
239
240## Focus Testing
241
242### Commands
243
244| Command           | Description                                | Mandatory| Description                                    |
245| --------------- | ------------------------------------ | ---- | ---------------------------------------- |
246| -n,--numberfocus       | Sets the number of injections for each component.              | No  | Unit: times                |
247| -f, --focustypes       | Sets the types of component for the focus testing.              | No  | Use commas (,) to separate the types.                        |
248| -h,--help       | Obtains the help information about the test.              | No  |                          |
249| -c,--count      | Sets the number of test times. This command conflicts with the **-T** command. Set either of them.  | No  | The default value is 10, in times.                      |
250| -i,--interval   | Sets the test interval.                        | No  | The default value is 1500, in millisecond.                      |
251| -s,--seed       | Sets the random seed.                        | No  | If the same random seed is set, the same random event sequence is generated.|
252| -b,--bundle[bundlename, ......, bundlename]    | Sets allowed bundles for the test. This command conflicts with the **-p** command.| No  | By default, all bundles on the device are allowed. Use commas (,) to separate bundle names.                |
253| -p,--prohibit[bundlename, ......, bundlename]  | Sets blocked bundles for the test. This command conflicts with the **-b** command.| No  | By default, no bundle is blocked. Use commas (,) to separate bundle names.                      |
254| -d,--page[page, ......, page]                  | Sets blocked pages for the test.| No | By default, the **pages/system** pages are blocked. Use commas (,) to separate page names.|
255| -a,--appswitch  | Sets the proportion of the random application startup event test.            | No  | The default value is 10%.                                 |
256| -t,--touch      | Sets the proportion of the random touch event test.           | No  | The default value is 10%.                                 |
257| -S,--swap       | Sets the proportion of the random swipe event test.            | No  | The default value is 3%.                                  |
258| -m,--mouse      | Sets the proportion of the random mouse event test.           | No  | The default value is 1%.                                  |
259| -k,--keyboard   | Sets the proportion of the random keyboard event test.        | No  | The default value is 2%.                                  |
260| -H,--hardkey    | Sets the proportion of the random hardkey test.             | No  | The default value is 2%.                                  |
261| -r,--rotate     | Sets the proportion of the random rotate event test.              | No  | The default value is 2%.                                  |
262| -C, --component | Sets the proportion of random component test.                | No  | The default value is 70%.                                 |
263| -I, --screenshot | Takes a screenshot for the component test.                | No  | - |
264| -T,--time       | Sets the total test time. This command conflicts with the **-c** command. Set either of them.| No  | The default value is 10, in minute.        |
265| -e, --allow ability   |  Sets the ability that allows testing.| No| - |
266| -E, --block ability   |  Sets the ability that blocks testing.| No| - |
267| -Y, --blockCompId     |  Sets the blocked **CompId**.| No| - |
268| -y, --blockCompType   |  Sets the blocked **CompType**.| No| - |
269| -B, --checkBWScreen   |  Enables black and white screen check.| No| - |
270
271### Samples
272
273```bash
274# wukong focus -s 10 -i 1000 -a 0.28 -t 0.72 -c 100
275```
276
277The parameters in the command are described as follows.
278| Command          | Value     |Description       |
279| -------------- | -------------- | -------------- |
280| wukong focus | -           | Works as the main command.               |
281| -s     | 10           | Sets the random seed. The seed value is **10**. |
282| -i  | 1000           | Sets the application startup interval to **1000** ms.|
283| -a  | 0.28          | Sets the proportion of the random application startup test to **28%**.   |
284| -t  | 0.72           | Sets the proportion of the random touch test to **72%**.   |
285| -c  | 100           | Sets the number of execution times to **100**.        |
286
287
288## Viewing the Test Result
289
290### Test Result Output Path
291
292After the test commands are executed, the test result is automatically generated. You can obtain the test result in the following directory:
293
294- For DevEco Studio versions earlier than September 22, 2022: /data/local/wukong/report/xxxxxxxx_xxxxxx/
295- For DevEco Studio versions later than September 22, 2022: /data/local/tmp/wukong/report/xxxxxxxx_xxxxxx/
296
297### Test Report Directories
298
299| Type                                | Description              |
300| ------------------------------------ | ------------------ |
301| exception/                           | Stores exception files generated during the test.|
302| screenshot/                          | Stores the screenshots of the test traversal. |
303| wukong_report.csv                    | Stores the test report summary.      |
304| wukong.log                | Indicates the test operation history.      |
305
306### View operation logs
307
308You can run the hdc command to obtain logs to the local host and view the operation history.
309
310```bash
311// The path of the wukong.log file is as follows:
312/data/local/tmp/wukong/report/xxxxxxxx_xxxxxx/wukong.log
313
314// To view the directory of the wukong test report, run the following command:
315# cd /data/local/tmp/wukong/report/20170805_170053
316# ls
317data.js  exception  wukong.log  wukong_report.csv
318
319// Open the shell and run hdc file recv to obtain wukong logs.
320C:\Users\xxx>hdc file recv /data/local/tmp/wukong/report/20170805_170053/wukong.log C:\Users\xxx\Desktop\log
321[I][2024-01-03 20:08:02] HdcFile::TransferSummary success
322FileTransfer finish, Size:76492, File count = 1, time:16ms rate:4780.75kB/s
323```
324
325## FAQs
326### failed to connect to AAMS
327 **Symptom**
328
329failed to connect to AAMS.
330
331 **Possible Cause**
332
333AAMS is occupied by Hypium or the UIViewer of DevEco Testing. AAMS can be connected to only one program at a time.
334
335 **Solution**
336
337Stop the process that occupies AAMS or restart the device.
338### Errorcode:(4005)
339 **Symptom**
340
341Errorcode:(4005).
342
343 **Possible Cause**
344
345The size of the screen display area changes. As a result, the page information fails to be obtained.
346
347 **Solution**
348
349This error does not affect the test process and does not need to be handled.
350### Errorcode:(4007)
351 **Symptom**
352
353Errorcode:(4007).
354
355 **Possible Cause**
356
357The size of the screen display area changes. As a result, the page information fails to be obtained.
358
359 **Solution**
360
361This error does not affect the test process and does not need to be handled.
362