Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
Heinrich Schuchardt | 1b0c316 | 2024-01-14 14:53:13 +0100 | [diff] [blame] | 3 | .. index:: |
| 4 | single: ut (command) |
| 5 | |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 6 | ut command |
| 7 | ========== |
| 8 | |
Heinrich Schuchardt | 44b09b3 | 2024-03-16 11:09:36 +0100 | [diff] [blame] | 9 | Synopsis |
| 10 | -------- |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 11 | |
| 12 | :: |
| 13 | |
Simon Glass | e411746 | 2025-01-20 14:26:06 -0700 | [diff] [blame^] | 14 | ut [-r<runs>] [-fs] [-I<n>:<one_test>] [<suite> [<test>]] |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 15 | |
| 16 | <runs> Number of times to run each test |
| 17 | -f Force 'manual' tests to run as well |
Simon Glass | 85ba7c3 | 2022-10-29 19:47:13 -0600 | [diff] [blame] | 18 | <n> Run <one test> after <n> other tests have run |
| 19 | <one_test> Name of the 'one' test to run |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 20 | <suite> Test suite to run, or `all` |
| 21 | <test> Name of single test to run |
| 22 | |
| 23 | Description |
| 24 | ----------- |
| 25 | |
| 26 | The ut command runs unit tests written in C. |
| 27 | |
| 28 | Typically the command is run on :ref:`arch/sandbox/sandbox:sandbox` since it |
| 29 | includes a near-complete set of emulators, no code-size limits, many CONFIG |
| 30 | options enabled and runs easily in CI without needing QEMU. It is also possible |
| 31 | to run some tests on real boards. |
| 32 | |
Simon Glass | e411746 | 2025-01-20 14:26:06 -0700 | [diff] [blame^] | 33 | For a list of available test suites, type `ut info -s`. |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 34 | |
Simon Glass | 1a92f83 | 2024-08-22 07:57:48 -0600 | [diff] [blame] | 35 | Each test is normally run once, although those marked with `UTF_DM` are |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 36 | run with livetree and flattree where possible. To run a test more than once, |
| 37 | use the `-r` flag. |
| 38 | |
| 39 | Manual tests are normally skipped by this command. Use `-f` to run them. See |
| 40 | See :ref:`develop/tests_writing:mixing python and c` for more information on |
| 41 | manual test. |
| 42 | |
Simon Glass | 85ba7c3 | 2022-10-29 19:47:13 -0600 | [diff] [blame] | 43 | When running unit tests, some may have side effects which cause a subsequent |
| 44 | test to break. This can sometimes be seen when using 'ut dm' or similar. To |
| 45 | fix this, select the 'one' test which breaks. Then tell the 'ut' command to |
| 46 | run this one test after a certain number of other tests have run. Using a |
| 47 | binary search method with `-I` you can quickly figure one which test is causing |
| 48 | the problem. |
| 49 | |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 50 | Generally all tests in the suite are run. To run just a single test from the |
| 51 | suite, provide the <test> argument. |
| 52 | |
| 53 | See :ref:`develop/tests_writing:writing c tests` for more information on how to |
| 54 | write unit tests. |
| 55 | |
| 56 | Example |
| 57 | ------- |
| 58 | |
Simon Glass | e411746 | 2025-01-20 14:26:06 -0700 | [diff] [blame^] | 59 | Show information about tests:: |
| 60 | |
| 61 | => ut info |
| 62 | Test suites: 23 |
| 63 | Total tests: 833 |
| 64 | |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 65 | List available unit-test suites:: |
| 66 | |
Simon Glass | e411746 | 2025-01-20 14:26:06 -0700 | [diff] [blame^] | 67 | => ut info -s |
| 68 | Test suites: 23 |
| 69 | Total tests: 833 |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 70 | |
Simon Glass | e411746 | 2025-01-20 14:26:06 -0700 | [diff] [blame^] | 71 | 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 Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 96 | |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 97 | |
| 98 | Run 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 | |
| 118 | Run just a single test in a suite:: |
| 119 | |
| 120 | => ut bloblist bloblist_test_grow |
| 121 | Test: bloblist_test_grow: bloblist.c |
| 122 | Failures: 0 |