Back to home page

OSCL-LXR

 
 

    


0001 .. SPDX-License-Identifier: GPL-2.0
0002 
0003 ============================
0004 Run Tests without kunit_tool
0005 ============================
0006 
0007 If we do not want to use kunit_tool (For example: we want to integrate
0008 with other systems, or run tests on real hardware), we can
0009 include KUnit in any kernel, read out results, and parse manually.
0010 
0011 .. note:: KUnit is not designed for use in a production system. It is
0012           possible that tests may reduce the stability or security of
0013           the system.
0014 
0015 Configure the Kernel
0016 ====================
0017 
0018 KUnit tests can run without kunit_tool. This can be useful, if:
0019 
0020 - We have an existing kernel configuration to test.
0021 - Need to run on real hardware (or using an emulator/VM kunit_tool
0022   does not support).
0023 - Wish to integrate with some existing testing systems.
0024 
0025 KUnit is configured with the ``CONFIG_KUNIT`` option, and individual
0026 tests can also be built by enabling their config options in our
0027 ``.config``. KUnit tests usually (but don't always) have config options
0028 ending in ``_KUNIT_TEST``. Most tests can either be built as a module,
0029 or be built into the kernel.
0030 
0031 .. note ::
0032 
0033         We can enable the ``KUNIT_ALL_TESTS`` config option to
0034         automatically enable all tests with satisfied dependencies. This is
0035         a good way of quickly testing everything applicable to the current
0036         config.
0037 
0038 Once we have built our kernel (and/or modules), it is simple to run
0039 the tests. If the tests are built-in, they will run automatically on the
0040 kernel boot. The results will be written to the kernel log (``dmesg``)
0041 in TAP format.
0042 
0043 If the tests are built as modules, they will run when the module is
0044 loaded.
0045 
0046 .. code-block :: bash
0047 
0048         # modprobe example-test
0049 
0050 The results will appear in TAP format in ``dmesg``.
0051 
0052 .. note ::
0053 
0054         If ``CONFIG_KUNIT_DEBUGFS`` is enabled, KUnit test results will
0055         be accessible from the ``debugfs`` filesystem (if mounted).
0056         They will be in ``/sys/kernel/debug/kunit/<test_suite>/results``, in
0057         TAP format.