1*46201d47SHarinder Singh.. SPDX-License-Identifier: GPL-2.0 2*46201d47SHarinder Singh 3*46201d47SHarinder Singh============================ 4*46201d47SHarinder SinghRun Tests without kunit_tool 5*46201d47SHarinder Singh============================ 6*46201d47SHarinder Singh 7*46201d47SHarinder SinghIf we do not want to use kunit_tool (For example: we want to integrate 8*46201d47SHarinder Singhwith other systems, or run tests on real hardware), we can 9*46201d47SHarinder Singhinclude KUnit in any kernel, read out results, and parse manually. 10*46201d47SHarinder Singh 11*46201d47SHarinder Singh.. note:: KUnit is not designed for use in a production system. It is 12*46201d47SHarinder Singh possible that tests may reduce the stability or security of 13*46201d47SHarinder Singh the system. 14*46201d47SHarinder Singh 15*46201d47SHarinder SinghConfigure the Kernel 16*46201d47SHarinder Singh==================== 17*46201d47SHarinder Singh 18*46201d47SHarinder SinghKUnit tests can run without kunit_tool. This can be useful, if: 19*46201d47SHarinder Singh 20*46201d47SHarinder Singh- We have an existing kernel configuration to test. 21*46201d47SHarinder Singh- Need to run on real hardware (or using an emulator/VM kunit_tool 22*46201d47SHarinder Singh does not support). 23*46201d47SHarinder Singh- Wish to integrate with some existing testing systems. 24*46201d47SHarinder Singh 25*46201d47SHarinder SinghKUnit is configured with the ``CONFIG_KUNIT`` option, and individual 26*46201d47SHarinder Singhtests can also be built by enabling their config options in our 27*46201d47SHarinder Singh``.config``. KUnit tests usually (but don't always) have config options 28*46201d47SHarinder Singhending in ``_KUNIT_TEST``. Most tests can either be built as a module, 29*46201d47SHarinder Singhor be built into the kernel. 30*46201d47SHarinder Singh 31*46201d47SHarinder Singh.. note :: 32*46201d47SHarinder Singh 33*46201d47SHarinder Singh We can enable the ``KUNIT_ALL_TESTS`` config option to 34*46201d47SHarinder Singh automatically enable all tests with satisfied dependencies. This is 35*46201d47SHarinder Singh a good way of quickly testing everything applicable to the current 36*46201d47SHarinder Singh config. 37*46201d47SHarinder Singh 38*46201d47SHarinder SinghOnce we have built our kernel (and/or modules), it is simple to run 39*46201d47SHarinder Singhthe tests. If the tests are built-in, they will run automatically on the 40*46201d47SHarinder Singhkernel boot. The results will be written to the kernel log (``dmesg``) 41*46201d47SHarinder Singhin TAP format. 42*46201d47SHarinder Singh 43*46201d47SHarinder SinghIf the tests are built as modules, they will run when the module is 44*46201d47SHarinder Singhloaded. 45*46201d47SHarinder Singh 46*46201d47SHarinder Singh.. code-block :: bash 47*46201d47SHarinder Singh 48*46201d47SHarinder Singh # modprobe example-test 49*46201d47SHarinder Singh 50*46201d47SHarinder SinghThe results will appear in TAP format in ``dmesg``. 51*46201d47SHarinder Singh 52*46201d47SHarinder Singh.. note :: 53*46201d47SHarinder Singh 54*46201d47SHarinder Singh If ``CONFIG_KUNIT_DEBUGFS`` is enabled, KUnit test results will 55*46201d47SHarinder Singh be accessible from the ``debugfs`` filesystem (if mounted). 56*46201d47SHarinder Singh They will be in ``/sys/kernel/debug/kunit/<test_suite>/results``, in 57*46201d47SHarinder Singh TAP format. 58