blob: 45bc9ffbdc59638a90c201be7aa98822e5313ad5 [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 Glass85ba7c32022-10-29 19:47:13 -060014 ut [-r<runs>] [-f] [-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
33For a list of available test suites, type `ut` by itself.
34
35Each test is normally run once, although those marked with `UT_TESTF_DM` are
36run 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
59List available unit-test suites::
60
61 => ut
62 ut - unit tests
63
64 Usage:
65 ut [-r] [-f] [<suite>] - run unit tests
66 -r<runs> Number of times to run each test
67 -f Force 'manual' tests to run as well
68 <suite> Test suite to run, or all
69
70 Suites:
71 all - execute all enabled tests
72 addrmap - very basic test of addrmap command
73 bloblist - bloblist implementation
74 bootstd - standard boot implementation
75 compression - compressors and bootm decompression
76 dm - driver model
77 env - environment
78 fdt - fdt command
79 loadm - loadm command parameters and loading memory blob
80 lib - library functions
81 log - logging functions
82 mem - memory-related commands
83 overlay - device tree overlays
84 print - printing things to the console
85 setexpr - setexpr command
86 str - basic test of string functions
87 time - very basic test of time functions
88 unicode - Unicode functions
89
90Run one of the suites::
91
92 => ut bloblist
93 Running 14 bloblist tests
94 Test: bloblist_test_align: bloblist.c
95 Test: bloblist_test_bad_blob: bloblist.c
96 Test: bloblist_test_blob: bloblist.c
97 Test: bloblist_test_blob_ensure: bloblist.c
98 Test: bloblist_test_blob_maxsize: bloblist.c
99 Test: bloblist_test_checksum: bloblist.c
100 Test: bloblist_test_cmd_info: bloblist.c
101 Test: bloblist_test_cmd_list: bloblist.c
102 Test: bloblist_test_grow: bloblist.c
103 Test: bloblist_test_init: bloblist.c
104 Test: bloblist_test_reloc: bloblist.c
105 Test: bloblist_test_resize_fail: bloblist.c
106 Test: bloblist_test_resize_last: bloblist.c
107 Test: bloblist_test_shrink: bloblist.c
108 Failures: 0
109
110Run just a single test in a suite::
111
112 => ut bloblist bloblist_test_grow
113 Test: bloblist_test_grow: bloblist.c
114 Failures: 0
Simon Glassfb998c22022-10-29 19:47:12 -0600115
116Show information about tests::
117
118 => ut info
119 Test suites: 21
120 Total tests: 642