blob: a3039634f2e150c5113b544bae3a4f29a86e16b4 [file] [log] [blame]
Simon Glass3814e892022-10-29 19:47:11 -06001.. SPDX-License-Identifier: GPL-2.0+:
2
3ut command
4==========
5
6Synopis
7-------
8
9::
10
Simon Glass85ba7c32022-10-29 19:47:13 -060011 ut [-r<runs>] [-f] [-I<n>:<one_test>] [<suite> [<test>]]
Simon Glass3814e892022-10-29 19:47:11 -060012
13 <runs> Number of times to run each test
14 -f Force 'manual' tests to run as well
Simon Glass85ba7c32022-10-29 19:47:13 -060015 <n> Run <one test> after <n> other tests have run
16 <one_test> Name of the 'one' test to run
Simon Glass3814e892022-10-29 19:47:11 -060017 <suite> Test suite to run, or `all`
18 <test> Name of single test to run
19
20Description
21-----------
22
23The ut command runs unit tests written in C.
24
25Typically the command is run on :ref:`arch/sandbox/sandbox:sandbox` since it
26includes a near-complete set of emulators, no code-size limits, many CONFIG
27options enabled and runs easily in CI without needing QEMU. It is also possible
28to run some tests on real boards.
29
30For a list of available test suites, type `ut` by itself.
31
32Each test is normally run once, although those marked with `UT_TESTF_DM` are
33run with livetree and flattree where possible. To run a test more than once,
34use the `-r` flag.
35
36Manual tests are normally skipped by this command. Use `-f` to run them. See
37See :ref:`develop/tests_writing:mixing python and c` for more information on
38manual test.
39
Simon Glass85ba7c32022-10-29 19:47:13 -060040When running unit tests, some may have side effects which cause a subsequent
41test to break. This can sometimes be seen when using 'ut dm' or similar. To
42fix this, select the 'one' test which breaks. Then tell the 'ut' command to
43run this one test after a certain number of other tests have run. Using a
44binary search method with `-I` you can quickly figure one which test is causing
45the problem.
46
Simon Glass3814e892022-10-29 19:47:11 -060047Generally all tests in the suite are run. To run just a single test from the
48suite, provide the <test> argument.
49
50See :ref:`develop/tests_writing:writing c tests` for more information on how to
51write unit tests.
52
53Example
54-------
55
56List available unit-test suites::
57
58 => ut
59 ut - unit tests
60
61 Usage:
62 ut [-r] [-f] [<suite>] - run unit tests
63 -r<runs> Number of times to run each test
64 -f Force 'manual' tests to run as well
65 <suite> Test suite to run, or all
66
67 Suites:
68 all - execute all enabled tests
69 addrmap - very basic test of addrmap command
70 bloblist - bloblist implementation
71 bootstd - standard boot implementation
72 compression - compressors and bootm decompression
73 dm - driver model
74 env - environment
75 fdt - fdt command
76 loadm - loadm command parameters and loading memory blob
77 lib - library functions
78 log - logging functions
79 mem - memory-related commands
80 overlay - device tree overlays
81 print - printing things to the console
82 setexpr - setexpr command
83 str - basic test of string functions
84 time - very basic test of time functions
85 unicode - Unicode functions
86
87Run one of the suites::
88
89 => ut bloblist
90 Running 14 bloblist tests
91 Test: bloblist_test_align: bloblist.c
92 Test: bloblist_test_bad_blob: bloblist.c
93 Test: bloblist_test_blob: bloblist.c
94 Test: bloblist_test_blob_ensure: bloblist.c
95 Test: bloblist_test_blob_maxsize: bloblist.c
96 Test: bloblist_test_checksum: bloblist.c
97 Test: bloblist_test_cmd_info: bloblist.c
98 Test: bloblist_test_cmd_list: bloblist.c
99 Test: bloblist_test_grow: bloblist.c
100 Test: bloblist_test_init: bloblist.c
101 Test: bloblist_test_reloc: bloblist.c
102 Test: bloblist_test_resize_fail: bloblist.c
103 Test: bloblist_test_resize_last: bloblist.c
104 Test: bloblist_test_shrink: bloblist.c
105 Failures: 0
106
107Run just a single test in a suite::
108
109 => ut bloblist bloblist_test_grow
110 Test: bloblist_test_grow: bloblist.c
111 Failures: 0
Simon Glassfb998c22022-10-29 19:47:12 -0600112
113Show information about tests::
114
115 => ut info
116 Test suites: 21
117 Total tests: 642