Commit fc23c074 authored by Andrey Konovalov's avatar Andrey Konovalov Committed by Linus Torvalds

kasan: docs: update tests section

Update the "Tests" section in KASAN documentation:

 - Add an introductory sentence.

 - Add proper indentation for the list of ways to run KUnit tests.

 - Punctuation, readability, and other minor clean-ups.

Link: https://lkml.kernel.org/r/fb08845e25c8847ffda271fa19cda2621c04a65b.1615559068.git.andreyknvl@google.comSigned-off-by: default avatarAndrey Konovalov <andreyknvl@google.com>
Reviewed-by: default avatarMarco Elver <elver@google.com>
Cc: Alexander Potapenko <glider@google.com>
Cc: Andrey Ryabinin <aryabinin@virtuozzo.com>
Cc: Dmitry Vyukov <dvyukov@google.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent fe547fca
...@@ -420,19 +420,20 @@ saving and restoring the per-page KASAN tag via ...@@ -420,19 +420,20 @@ saving and restoring the per-page KASAN tag via
Tests Tests
~~~~~ ~~~~~
KASAN tests consist of two parts: There are KASAN tests that allow verifying that KASAN works and can detect
certain types of memory corruptions. The tests consist of two parts:
1. Tests that are integrated with the KUnit Test Framework. Enabled with 1. Tests that are integrated with the KUnit Test Framework. Enabled with
``CONFIG_KASAN_KUNIT_TEST``. These tests can be run and partially verified ``CONFIG_KASAN_KUNIT_TEST``. These tests can be run and partially verified
automatically in a few different ways, see the instructions below. automatically in a few different ways; see the instructions below.
2. Tests that are currently incompatible with KUnit. Enabled with 2. Tests that are currently incompatible with KUnit. Enabled with
``CONFIG_KASAN_MODULE_TEST`` and can only be run as a module. These tests can ``CONFIG_KASAN_MODULE_TEST`` and can only be run as a module. These tests can
only be verified manually, by loading the kernel module and inspecting the only be verified manually by loading the kernel module and inspecting the
kernel log for KASAN reports. kernel log for KASAN reports.
Each KUnit-compatible KASAN test prints a KASAN report if an error is detected. Each KUnit-compatible KASAN test prints one of multiple KASAN reports if an
Then the test prints its number and status. error is detected. Then the test prints its number and status.
When a test passes:: When a test passes::
...@@ -460,27 +461,24 @@ Or, if one of the tests failed:: ...@@ -460,27 +461,24 @@ Or, if one of the tests failed::
not ok 1 - kasan not ok 1 - kasan
There are a few ways to run KUnit-compatible KASAN tests. There are a few ways to run KUnit-compatible KASAN tests.
1. Loadable module 1. Loadable module
With ``CONFIG_KUNIT`` enabled, ``CONFIG_KASAN_KUNIT_TEST`` can be built as With ``CONFIG_KUNIT`` enabled, KASAN-KUnit tests can be built as a loadable
a loadable module and run on any architecture that supports KASAN by loading module and run by loading ``test_kasan.ko`` with ``insmod`` or ``modprobe``.
the module with insmod or modprobe. The module is called ``test_kasan``.
2. Built-In 2. Built-In
With ``CONFIG_KUNIT`` built-in, ``CONFIG_KASAN_KUNIT_TEST`` can be built-in With ``CONFIG_KUNIT`` built-in, KASAN-KUnit tests can be built-in as well.
on any architecure that supports KASAN. These and any other KUnit tests enabled In this case, the tests will run at boot as a late-init call.
will run and print the results at boot as a late-init call.
3. Using kunit_tool 3. Using kunit_tool
With ``CONFIG_KUNIT`` and ``CONFIG_KASAN_KUNIT_TEST`` built-in, it's also With ``CONFIG_KUNIT`` and ``CONFIG_KASAN_KUNIT_TEST`` built-in, it is also
possible use ``kunit_tool`` to see the results of these and other KUnit tests possible to use ``kunit_tool`` to see the results of KUnit tests in a more
in a more readable way. This will not print the KASAN reports of the tests that readable way. This will not print the KASAN reports of the tests that passed.
passed. Use `KUnit documentation <https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html>`_ See `KUnit documentation <https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html>`_
for more up-to-date information on ``kunit_tool``. for more up-to-date information on ``kunit_tool``.
.. _KUnit: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html .. _KUnit: https://www.kernel.org/doc/html/latest/dev-tools/kunit/index.html
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment