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 | 85ba7c3 | 2022-10-29 19:47:13 -0600 | [diff] [blame] | 14 | ut [-r<runs>] [-f] [-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 | |
| 33 | For a list of available test suites, type `ut` by itself. |
| 34 | |
| 35 | Each test is normally run once, although those marked with `UT_TESTF_DM` are |
| 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 | |
| 59 | List 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 | |
| 90 | Run 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 | |
| 110 | Run 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 Glass | fb998c2 | 2022-10-29 19:47:12 -0600 | [diff] [blame] | 115 | |
| 116 | Show information about tests:: |
| 117 | |
| 118 | => ut info |
| 119 | Test suites: 21 |
| 120 | Total tests: 642 |