blob: e794922c80658ff90cbed643c630e0ba66ac2719 [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 Glasse4117462025-01-20 14:26:06 -070014 ut [-r<runs>] [-fs] [-I<n>:<one_test>] [<suite> [<test>]]
Simon Glass3814e892022-10-29 19:47:11 -060015
16 <runs> Number of times to run each test
17 -f Force 'manual' tests to run as well
Simon Glass85ba7c32022-10-29 19:47:13 -060018 <n> Run <one test> after <n> other tests have run
19 <one_test> Name of the 'one' test to run
Simon Glass3814e892022-10-29 19:47:11 -060020 <suite> Test suite to run, or `all`
21 <test> Name of single test to run
22
23Description
24-----------
25
26The ut command runs unit tests written in C.
27
28Typically the command is run on :ref:`arch/sandbox/sandbox:sandbox` since it
29includes a near-complete set of emulators, no code-size limits, many CONFIG
30options enabled and runs easily in CI without needing QEMU. It is also possible
31to run some tests on real boards.
32
Simon Glasse4117462025-01-20 14:26:06 -070033For a list of available test suites, type `ut info -s`.
Simon Glass3814e892022-10-29 19:47:11 -060034
Simon Glass1a92f832024-08-22 07:57:48 -060035Each test is normally run once, although those marked with `UTF_DM` are
Simon Glass3814e892022-10-29 19:47:11 -060036run with livetree and flattree where possible. To run a test more than once,
37use the `-r` flag.
38
39Manual tests are normally skipped by this command. Use `-f` to run them. See
40See :ref:`develop/tests_writing:mixing python and c` for more information on
41manual test.
42
Simon Glass85ba7c32022-10-29 19:47:13 -060043When running unit tests, some may have side effects which cause a subsequent
44test to break. This can sometimes be seen when using 'ut dm' or similar. To
45fix this, select the 'one' test which breaks. Then tell the 'ut' command to
46run this one test after a certain number of other tests have run. Using a
47binary search method with `-I` you can quickly figure one which test is causing
48the problem.
49
Simon Glass3814e892022-10-29 19:47:11 -060050Generally all tests in the suite are run. To run just a single test from the
51suite, provide the <test> argument.
52
53See :ref:`develop/tests_writing:writing c tests` for more information on how to
54write unit tests.
55
56Example
57-------
58
Simon Glasse4117462025-01-20 14:26:06 -070059Show information about tests::
60
61 => ut info
62 Test suites: 23
63 Total tests: 833
64
Simon Glass3814e892022-10-29 19:47:11 -060065List available unit-test suites::
66
Simon Glasse4117462025-01-20 14:26:06 -070067 => ut info -s
68 Test suites: 23
69 Total tests: 833
Simon Glass3814e892022-10-29 19:47:11 -060070
Simon Glasse4117462025-01-20 14:26:06 -070071 Tests Suite Purpose
72 ----- ------------ -------------------------
73 1 addrmap very basic test of addrmap command
74 4 bdinfo bdinfo (board info) command
75 14 bloblist bloblist implementation
76 7 bootm bootm command
77 66 bootstd standard boot implementation
78 2 cmd various commands
79 14 common tests for common/ directory
80 502 dm driver model
81 6 env environment
82 1 exit shell exit and variables
83 19 fdt fdt command
84 10 fdt_overlay device tree overlays
85 1 font font command
86 20 hush hush behaviour
87 115 lib library functions
88 2 loadm loadm command parameters and loading memory blob
89 18 log logging functions
90 1 mbr mbr command
91 1 measurement TPM-based measured boot
92 13 mem memory-related commands
93 1 pci_mps PCI Express Maximum Payload Size
94 11 setexpr setexpr command
95 4 upl Universal payload support
Simon Glass3814e892022-10-29 19:47:11 -060096
Simon Glass3814e892022-10-29 19:47:11 -060097
98Run one of the suites::
99
100 => ut bloblist
101 Running 14 bloblist tests
102 Test: bloblist_test_align: bloblist.c
103 Test: bloblist_test_bad_blob: bloblist.c
104 Test: bloblist_test_blob: bloblist.c
105 Test: bloblist_test_blob_ensure: bloblist.c
106 Test: bloblist_test_blob_maxsize: bloblist.c
107 Test: bloblist_test_checksum: bloblist.c
108 Test: bloblist_test_cmd_info: bloblist.c
109 Test: bloblist_test_cmd_list: bloblist.c
110 Test: bloblist_test_grow: bloblist.c
111 Test: bloblist_test_init: bloblist.c
112 Test: bloblist_test_reloc: bloblist.c
113 Test: bloblist_test_resize_fail: bloblist.c
114 Test: bloblist_test_resize_last: bloblist.c
115 Test: bloblist_test_shrink: bloblist.c
116 Failures: 0
117
118Run just a single test in a suite::
119
120 => ut bloblist bloblist_test_grow
121 Test: bloblist_test_grow: bloblist.c
122 Failures: 0