Skip to content

Commit 6ae2bfd

Browse files
alan-maguireshuahkh
authored andcommitted
kunit: update documentation to describe module-based build
Documentation should describe how to build kunit and tests as modules. Co-developed-by: Knut Omang <[email protected]> Signed-off-by: Knut Omang <[email protected]> Signed-off-by: Alan Maguire <[email protected]> Reviewed-by: Stephen Boyd <[email protected]> Reviewed-by: Brendan Higgins <[email protected]> Signed-off-by: Shuah Khan <[email protected]>
1 parent 9fe124b commit 6ae2bfd

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
lines changed

Documentation/dev-tools/kunit/faq.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ Yes, well, mostly.
2929

3030
For the most part, the KUnit core framework (what you use to write the tests)
3131
can compile to any architecture; it compiles like just another part of the
32-
kernel and runs when the kernel boots. However, there is some infrastructure,
32+
kernel and runs when the kernel boots, or when built as a module, when the
33+
module is loaded. However, there is some infrastructure,
3334
like the KUnit Wrapper (``tools/testing/kunit/kunit.py``) that does not support
3435
other architectures.
3536

Documentation/dev-tools/kunit/index.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ to a standalone program that can be run like any other program directly inside
4949
of a host operating system; to be clear, it does not require any virtualization
5050
support; it is just a regular program.
5151

52+
Alternatively, kunit and kunit tests can be built as modules and tests will
53+
run when the test module is loaded.
54+
5255
KUnit is fast. Excluding build time, from invocation to completion KUnit can run
5356
several dozen tests in only 10 to 20 seconds; this might not sound like a big
5457
deal to some people, but having such fast and easy to run tests fundamentally

Documentation/dev-tools/kunit/usage.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,22 @@ Interspersed in the kernel logs you might see the following:
539539
540540
Congratulations, you just ran a KUnit test on the x86 architecture!
541541

542+
In a similar manner, kunit and kunit tests can also be built as modules,
543+
so if you wanted to run tests in this way you might add the following config
544+
options to your ``.config``:
545+
546+
.. code-block:: none
547+
548+
CONFIG_KUNIT=m
549+
CONFIG_KUNIT_EXAMPLE_TEST=m
550+
551+
Once the kernel is built and installed, a simple
552+
553+
.. code-block:: bash
554+
modprobe example-test
555+
556+
...will run the tests.
557+
542558
Writing new tests for other architectures
543559
-----------------------------------------
544560

0 commit comments

Comments
 (0)