1.. SPDX-License-Identifier: GPL-2.0 2 3================= 4kunit_tool How-To 5================= 6 7What is kunit_tool? 8=================== 9 10kunit_tool is a script (``tools/testing/kunit/kunit.py``) that aids in building 11the Linux kernel as UML (`User Mode Linux 12<http://user-mode-linux.sourceforge.net/>`_), running KUnit tests, parsing 13the test results and displaying them in a user friendly manner. 14 15kunit_tool addresses the problem of being able to run tests without needing a 16virtual machine or actual hardware with User Mode Linux. User Mode Linux is a 17Linux architecture, like ARM or x86; however, unlike other architectures it 18compiles the kernel as a standalone Linux executable that can be run like any 19other program directly inside of a host operating system. To be clear, it does 20not require any virtualization support: it is just a regular program. 21 22What is a .kunitconfig? 23======================= 24 25It's just a defconfig that kunit_tool looks for in the base directory. 26kunit_tool uses it to generate a .config as you might expect. In addition, it 27verifies that the generated .config contains the CONFIG options in the 28.kunitconfig; the reason it does this is so that it is easy to be sure that a 29CONFIG that enables a test actually ends up in the .config. 30 31How do I use kunit_tool? 32======================== 33 34If a kunitconfig is present at the root directory, all you have to do is: 35 36.. code-block:: bash 37 38 ./tools/testing/kunit/kunit.py run 39 40However, you most likely want to use it with the following options: 41 42.. code-block:: bash 43 44 ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` 45 46- ``--timeout`` sets a maximum amount of time to allow tests to run. 47- ``--jobs`` sets the number of threads to use to build the kernel. 48 49.. note:: 50 This command will work even without a .kunitconfig file: if no 51 .kunitconfig is present, a default one will be used instead. 52 53For 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 58