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