18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0 28c2ecf20Sopenharmony_ci 38c2ecf20Sopenharmony_ci================= 48c2ecf20Sopenharmony_cikunit_tool How-To 58c2ecf20Sopenharmony_ci================= 68c2ecf20Sopenharmony_ci 78c2ecf20Sopenharmony_ciWhat is kunit_tool? 88c2ecf20Sopenharmony_ci=================== 98c2ecf20Sopenharmony_ci 108c2ecf20Sopenharmony_cikunit_tool is a script (``tools/testing/kunit/kunit.py``) that aids in building 118c2ecf20Sopenharmony_cithe Linux kernel as UML (`User Mode Linux 128c2ecf20Sopenharmony_ci<http://user-mode-linux.sourceforge.net/>`_), running KUnit tests, parsing 138c2ecf20Sopenharmony_cithe test results and displaying them in a user friendly manner. 148c2ecf20Sopenharmony_ci 158c2ecf20Sopenharmony_cikunit_tool addresses the problem of being able to run tests without needing a 168c2ecf20Sopenharmony_civirtual machine or actual hardware with User Mode Linux. User Mode Linux is a 178c2ecf20Sopenharmony_ciLinux architecture, like ARM or x86; however, unlike other architectures it 188c2ecf20Sopenharmony_cicompiles the kernel as a standalone Linux executable that can be run like any 198c2ecf20Sopenharmony_ciother program directly inside of a host operating system. To be clear, it does 208c2ecf20Sopenharmony_cinot require any virtualization support: it is just a regular program. 218c2ecf20Sopenharmony_ci 228c2ecf20Sopenharmony_ciWhat is a .kunitconfig? 238c2ecf20Sopenharmony_ci======================= 248c2ecf20Sopenharmony_ci 258c2ecf20Sopenharmony_ciIt's just a defconfig that kunit_tool looks for in the base directory. 268c2ecf20Sopenharmony_cikunit_tool uses it to generate a .config as you might expect. In addition, it 278c2ecf20Sopenharmony_civerifies that the generated .config contains the CONFIG options in the 288c2ecf20Sopenharmony_ci.kunitconfig; the reason it does this is so that it is easy to be sure that a 298c2ecf20Sopenharmony_ciCONFIG that enables a test actually ends up in the .config. 308c2ecf20Sopenharmony_ci 318c2ecf20Sopenharmony_ciHow do I use kunit_tool? 328c2ecf20Sopenharmony_ci======================== 338c2ecf20Sopenharmony_ci 348c2ecf20Sopenharmony_ciIf a kunitconfig is present at the root directory, all you have to do is: 358c2ecf20Sopenharmony_ci 368c2ecf20Sopenharmony_ci.. code-block:: bash 378c2ecf20Sopenharmony_ci 388c2ecf20Sopenharmony_ci ./tools/testing/kunit/kunit.py run 398c2ecf20Sopenharmony_ci 408c2ecf20Sopenharmony_ciHowever, you most likely want to use it with the following options: 418c2ecf20Sopenharmony_ci 428c2ecf20Sopenharmony_ci.. code-block:: bash 438c2ecf20Sopenharmony_ci 448c2ecf20Sopenharmony_ci ./tools/testing/kunit/kunit.py run --timeout=30 --jobs=`nproc --all` 458c2ecf20Sopenharmony_ci 468c2ecf20Sopenharmony_ci- ``--timeout`` sets a maximum amount of time to allow tests to run. 478c2ecf20Sopenharmony_ci- ``--jobs`` sets the number of threads to use to build the kernel. 488c2ecf20Sopenharmony_ci 498c2ecf20Sopenharmony_ci.. note:: 508c2ecf20Sopenharmony_ci This command will work even without a .kunitconfig file: if no 518c2ecf20Sopenharmony_ci .kunitconfig is present, a default one will be used instead. 528c2ecf20Sopenharmony_ci 538c2ecf20Sopenharmony_ciFor a list of all the flags supported by kunit_tool, you can run: 548c2ecf20Sopenharmony_ci 558c2ecf20Sopenharmony_ci.. code-block:: bash 568c2ecf20Sopenharmony_ci 578c2ecf20Sopenharmony_ci ./tools/testing/kunit/kunit.py run --help 58