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