File: run_manual.rst

package info (click to toggle)
linux 6.1.8-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 1,488,076 kB
  • sloc: ansic: 23,401,844; asm: 266,744; sh: 108,976; makefile: 49,705; python: 36,927; perl: 36,810; cpp: 6,044; yacc: 4,904; lex: 2,722; awk: 1,440; ruby: 25; sed: 5
file content (57 lines) | stat: -rw-r--r-- 1,940 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
.. SPDX-License-Identifier: GPL-2.0

============================
Run Tests without kunit_tool
============================

If we do not want to use kunit_tool (For example: we want to integrate
with other systems, or run tests on real hardware), we can
include KUnit in any kernel, read out results, and parse manually.

.. note:: KUnit is not designed for use in a production system. It is
          possible that tests may reduce the stability or security of
          the system.

Configure the Kernel
====================

KUnit tests can run without kunit_tool. This can be useful, if:

- We have an existing kernel configuration to test.
- Need to run on real hardware (or using an emulator/VM kunit_tool
  does not support).
- Wish to integrate with some existing testing systems.

KUnit is configured with the ``CONFIG_KUNIT`` option, and individual
tests can also be built by enabling their config options in our
``.config``. KUnit tests usually (but don't always) have config options
ending in ``_KUNIT_TEST``. Most tests can either be built as a module,
or be built into the kernel.

.. note ::

	We can enable the ``KUNIT_ALL_TESTS`` config option to
	automatically enable all tests with satisfied dependencies. This is
	a good way of quickly testing everything applicable to the current
	config.

Once we have built our kernel (and/or modules), it is simple to run
the tests. If the tests are built-in, they will run automatically on the
kernel boot. The results will be written to the kernel log (``dmesg``)
in TAP format.

If the tests are built as modules, they will run when the module is
loaded.

.. code-block :: bash

	# modprobe example-test

The results will appear in TAP format in ``dmesg``.

.. note ::

	If ``CONFIG_KUNIT_DEBUGFS`` is enabled, KUnit test results will
	be accessible from the ``debugfs`` filesystem (if mounted).
	They will be in ``/sys/kernel/debug/kunit/<test_suite>/results``, in
	TAP format.