Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0+: |
| 2 | |
| 3 | ut command |
| 4 | ========== |
| 5 | |
| 6 | Synopis |
| 7 | ------- |
| 8 | |
| 9 | :: |
| 10 | |
Simon Glass | 85ba7c3 | 2022-10-29 19:47:13 -0600 | [diff] [blame] | 11 | ut [-r<runs>] [-f] [-I<n>:<one_test>] [<suite> [<test>]] |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 12 | |
| 13 | <runs> Number of times to run each test |
| 14 | -f Force 'manual' tests to run as well |
Simon Glass | 85ba7c3 | 2022-10-29 19:47:13 -0600 | [diff] [blame] | 15 | <n> Run <one test> after <n> other tests have run |
| 16 | <one_test> Name of the 'one' test to run |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 17 | <suite> Test suite to run, or `all` |
| 18 | <test> Name of single test to run |
| 19 | |
| 20 | Description |
| 21 | ----------- |
| 22 | |
| 23 | The ut command runs unit tests written in C. |
| 24 | |
| 25 | Typically the command is run on :ref:`arch/sandbox/sandbox:sandbox` since it |
| 26 | includes a near-complete set of emulators, no code-size limits, many CONFIG |
| 27 | options enabled and runs easily in CI without needing QEMU. It is also possible |
| 28 | to run some tests on real boards. |
| 29 | |
| 30 | For a list of available test suites, type `ut` by itself. |
| 31 | |
| 32 | Each test is normally run once, although those marked with `UT_TESTF_DM` are |
| 33 | run with livetree and flattree where possible. To run a test more than once, |
| 34 | use the `-r` flag. |
| 35 | |
| 36 | Manual tests are normally skipped by this command. Use `-f` to run them. See |
| 37 | See :ref:`develop/tests_writing:mixing python and c` for more information on |
| 38 | manual test. |
| 39 | |
Simon Glass | 85ba7c3 | 2022-10-29 19:47:13 -0600 | [diff] [blame] | 40 | When running unit tests, some may have side effects which cause a subsequent |
| 41 | test to break. This can sometimes be seen when using 'ut dm' or similar. To |
| 42 | fix this, select the 'one' test which breaks. Then tell the 'ut' command to |
| 43 | run this one test after a certain number of other tests have run. Using a |
| 44 | binary search method with `-I` you can quickly figure one which test is causing |
| 45 | the problem. |
| 46 | |
Simon Glass | 3814e89 | 2022-10-29 19:47:11 -0600 | [diff] [blame] | 47 | Generally all tests in the suite are run. To run just a single test from the |
| 48 | suite, provide the <test> argument. |
| 49 | |
| 50 | See :ref:`develop/tests_writing:writing c tests` for more information on how to |
| 51 | write unit tests. |
| 52 | |
| 53 | Example |
| 54 | ------- |
| 55 | |
| 56 | List 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 | |
| 87 | Run 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 | |
| 107 | Run 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 Glass | fb998c2 | 2022-10-29 19:47:12 -0600 | [diff] [blame] | 112 | |
| 113 | Show information about tests:: |
| 114 | |
| 115 | => ut info |
| 116 | Test suites: 21 |
| 117 | Total tests: 642 |