blob: 1acf31266802317efc6f674071639e5dd680fc23 [file] [log] [blame]
Simon Glass3814e892022-10-29 19:47:11 -06001.. SPDX-License-Identifier: GPL-2.0+:
2
Heinrich Schuchardt1b0c3162024-01-14 14:53:13 +01003.. index::
4 single: ut (command)
5
Simon Glass3814e892022-10-29 19:47:11 -06006ut command
7==========
8
Heinrich Schuchardt44b09b32024-03-16 11:09:36 +01009Synopsis
10--------
Simon Glass3814e892022-10-29 19:47:11 -060011
12::
13
Simon Glassc2402642025-02-07 11:31:00 -070014 ut [-r<runs>] [-f] [-I<n>:<one_test>] [-r<n>] [<suite> | 'all' [<test>]]
15 ut [-s] info
Simon Glass3814e892022-10-29 19:47:11 -060016
17Description
18-----------
19
20The ut command runs unit tests written in C.
21
Simon Glassc2402642025-02-07 11:31:00 -070022suite
23 Specifies the suite to run, This can be a single suite, or a comma-separated
24 list
25
26test
27 Speciifes a particular test to run, within a suite, or all suites
28
29-f
30 Forces running of a manual test.
31
32-r <n>
33 Specifies the number of types to run each test
34
35-I <n>:<one_test>
36 Test to run after <n> other tests have run. This is used to find which test
37 causes another test to fail. If the one test fails, testing stops
38 immediately.
39
Simon Glass3814e892022-10-29 19:47:11 -060040Typically the command is run on :ref:`arch/sandbox/sandbox:sandbox` since it
41includes a near-complete set of emulators, no code-size limits, many CONFIG
42options enabled and runs easily in CI without needing QEMU. It is also possible
43to run some tests on real boards.
44
Simon Glass1a92f832024-08-22 07:57:48 -060045Each test is normally run once, although those marked with `UTF_DM` are
Simon Glass3814e892022-10-29 19:47:11 -060046run with livetree and flattree where possible. To run a test more than once,
47use the `-r` flag.
48
49Manual tests are normally skipped by this command. Use `-f` to run them. See
Simon Glassc2402642025-02-07 11:31:00 -070050:ref:`develop/tests_writing:mixing python and c` for more information on manual
51tests.
Simon Glass3814e892022-10-29 19:47:11 -060052
Simon Glass85ba7c32022-10-29 19:47:13 -060053When running unit tests, some may have side effects which cause a subsequent
54test to break. This can sometimes be seen when using 'ut dm' or similar. To
55fix this, select the 'one' test which breaks. Then tell the 'ut' command to
56run this one test after a certain number of other tests have run. Using a
57binary search method with `-I` you can quickly figure one which test is causing
58the problem.
59
Simon Glass3814e892022-10-29 19:47:11 -060060Generally all tests in the suite are run. To run just a single test from the
61suite, provide the <test> argument.
62
Simon Glassc2402642025-02-07 11:31:00 -070063To specify a list of suites to run, <suites> can also be a comma-separated list.
64
Simon Glass3814e892022-10-29 19:47:11 -060065See :ref:`develop/tests_writing:writing c tests` for more information on how to
66write unit tests.
67
Simon Glassc2402642025-02-07 11:31:00 -070068ut all
69~~~~~~
70
71Instead of a suite name 'all' may be used to run all tests.
72
73ut info
74~~~~~~~
75
76This provides information about the total number of suites and tests. Use the
77`-s` flag to show a detailed list of suites.
78
Simon Glass3814e892022-10-29 19:47:11 -060079Example
80-------
81
Simon Glasse4117462025-01-20 14:26:06 -070082Show information about tests::
83
84 => ut info
85 Test suites: 23
86 Total tests: 833
87
Simon Glass3814e892022-10-29 19:47:11 -060088List available unit-test suites::
89
Simon Glasse4117462025-01-20 14:26:06 -070090 => ut info -s
91 Test suites: 23
92 Total tests: 833
Simon Glass3814e892022-10-29 19:47:11 -060093
Simon Glasse4117462025-01-20 14:26:06 -070094 Tests Suite Purpose
95 ----- ------------ -------------------------
96 1 addrmap very basic test of addrmap command
97 4 bdinfo bdinfo (board info) command
98 14 bloblist bloblist implementation
99 7 bootm bootm command
100 66 bootstd standard boot implementation
101 2 cmd various commands
102 14 common tests for common/ directory
103 502 dm driver model
104 6 env environment
105 1 exit shell exit and variables
106 19 fdt fdt command
107 10 fdt_overlay device tree overlays
108 1 font font command
109 20 hush hush behaviour
110 115 lib library functions
111 2 loadm loadm command parameters and loading memory blob
112 18 log logging functions
113 1 mbr mbr command
114 1 measurement TPM-based measured boot
115 13 mem memory-related commands
116 1 pci_mps PCI Express Maximum Payload Size
117 11 setexpr setexpr command
118 4 upl Universal payload support
Simon Glass3814e892022-10-29 19:47:11 -0600119
Simon Glass3814e892022-10-29 19:47:11 -0600120
121Run one of the suites::
122
Simon Glassc2402642025-02-07 11:31:00 -0700123 => ut common
124 Running 14 common tests
125 Test: cli_ch_test: cread.c
126 Test: cread_test: cread.c
127 Test: dm_test_cyclic_running: cyclic.c
128 Test: print_display_buffer: print.c
129 Test: print_do_hex_dump: print.c
130 Test: print_efi_ut: print.c
131 Test: print_guid: print.c
132 Test: print_hexdump_line: print.c
133 Test: print_printf: print.c
134 Test: snprint: print.c
135 Test: test_autoboot: test_autoboot.c
136 Enter password "a" in 1 seconds to stop autoboot
137 Enter password "a" in 1 seconds to stop autoboot
138 Enter password "a" in 1 seconds to stop autoboot
139 Enter password "a" in 1 seconds to stop autoboot
140 Enter password "a" in 1 seconds to stop autoboot
141 Enter password "a" in 1 seconds to stop autoboot
142 Autoboot password unlock not successful
143 Test: test_event_base: event.c
144 Test: test_event_probe: event.c
145 Test: test_event_probe: event.c (flat tree)
146 Test: test_event_simple: event.c
147 Tests run: 14, 2611 ms, average 186 ms, skipped: 2, failures: 0
Simon Glass3814e892022-10-29 19:47:11 -0600148
149Run just a single test in a suite::
150
Simon Glassc2402642025-02-07 11:31:00 -0700151 => ut fdt_overlay change_int_property
152 Test: fdt_overlay_init: cmd_ut_fdt_overlay.c
153 Test: change_int_property: cmd_ut_fdt_overlay.c
154 Tests run: 2, 0 ms, average 0 ms, failures: 0
155
156Run a selection of three suites::
157
158 => ut bloblist,mem,fdt_overlay
159 Running 14 bloblist tests
160 Test: align: bloblist.c
161 Test: bad_blob: bloblist.c
162 Test: blob: bloblist.c
163 Test: blob_ensure: bloblist.c
164 Test: blob_maxsize: bloblist.c
165 Test: checksum: bloblist.c
166 Test: cmd_info: bloblist.c
167 Test: cmd_list: bloblist.c
168 Test: grow: bloblist.c
169 Test: init: bloblist.c
170 Test: reloc: bloblist.c
171 Test: resize_fail: bloblist.c
172 Test: resize_last: bloblist.c
173 Test: shrink: bloblist.c
174 Tests run: 14, 1 ms, average: 0 ms, failures: 0
175 Running 13 mem tests
176 Test: cp_b: mem_copy.c
177 Test: cp_l: mem_copy.c
178 Test: cp_q: mem_copy.c
179 Test: cp_w: mem_copy.c
180 Test: ms_b: mem_search.c
181 Test: ms_cont: mem_search.c
182 Test: ms_cont_end: mem_search.c
183 Test: ms_l: mem_search.c
184 Test: ms_limit: mem_search.c
185 Test: ms_mult: mem_search.c
186 Test: ms_quiet: mem_search.c
187 Test: ms_s: mem_search.c
188 Test: ms_w: mem_search.c
189 Tests run: 13, 13 ms, average: 1 ms, failures: 0
190 Running 10 fdt_overlay tests
191 Test: fdt_overlay_init: cmd_ut_fdt_overlay.c
192 Test: add_node_by_path: cmd_ut_fdt_overlay.c
193 Test: add_node_by_phandle: cmd_ut_fdt_overlay.c
194 Test: add_str_property: cmd_ut_fdt_overlay.c
195 Test: add_subnode_property: cmd_ut_fdt_overlay.c
196 Test: change_int_property: cmd_ut_fdt_overlay.c
197 Test: change_str_property: cmd_ut_fdt_overlay.c
198 Test: local_phandle: cmd_ut_fdt_overlay.c
199 Test: local_phandles: cmd_ut_fdt_overlay.c
200 Test: stacked: cmd_ut_fdt_overlay.c
201 Tests run: 10, 12 ms, average: 1 ms, failures: 0
202 Suites run: 3, total tests run: 37, 26 ms, average: 0 ms, failures: 0
203 Average test time: 0 ms, worst case 'mem' took 1 ms