Brendan Higgins | 99e51aa | 2019-11-19 17:17:00 -0800 | [diff] [blame] | 1 | .. SPDX-License-Identifier: GPL-2.0 |
| 2 | |
| 3 | ================= |
| 4 | kunit_tool How-To |
| 5 | ================= |
| 6 | |
| 7 | What is kunit_tool? |
| 8 | =================== |
| 9 | |
| 10 | kunit_tool is a script (``tools/testing/kunit/kunit.py``) that aids in building |
| 11 | the Linux kernel as UML (`User Mode Linux |
| 12 | <http://user-mode-linux.sourceforge.net/>`_), running KUnit tests, parsing |
| 13 | the test results and displaying them in a user friendly manner. |
| 14 | |
| 15 | What is a kunitconfig? |
| 16 | ====================== |
| 17 | |
| 18 | It's just a defconfig that kunit_tool looks for in the base directory. |
| 19 | kunit_tool uses it to generate a .config as you might expect. In addition, it |
| 20 | verifies that the generated .config contains the CONFIG options in the |
| 21 | kunitconfig; the reason it does this is so that it is easy to be sure that a |
| 22 | CONFIG that enables a test actually ends up in the .config. |
| 23 | |
| 24 | How do I use kunit_tool? |
| 25 | ======================== |
| 26 | |
| 27 | If a kunitconfig is present at the root directory, all you have to do is: |
| 28 | |
| 29 | .. code-block:: bash |
| 30 | |
| 31 | ./tools/testing/kunit/kunit.py run |
| 32 | |
| 33 | However, you most likely want to use it with the following options: |
| 34 | |
| 35 | .. code-block:: bash |
| 36 | |
| 37 | ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` |
| 38 | |
| 39 | - ``--timeout`` sets a maximum amount of time to allow tests to run. |
| 40 | - ``--jobs`` sets the number of threads to use to build the kernel. |
| 41 | |
| 42 | If you just want to use the defconfig that ships with the kernel, you can |
| 43 | append the ``--defconfig`` flag as well: |
| 44 | |
| 45 | .. code-block:: bash |
| 46 | |
| 47 | ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` --defconfig |
| 48 | |
| 49 | .. note:: |
| 50 | This command is particularly helpful for getting started because it |
| 51 | just works. No kunitconfig needs to be present. |
| 52 | |
| 53 | For a list of all the flags supported by kunit_tool, you can run: |
| 54 | |
| 55 | .. code-block:: bash |
| 56 | |
| 57 | ./tools/testing/kunit/kunit.py run --help |