[PATCH v2 2/2] Documentation: Add debugfs docs with run after boot

From: Rae Moar
Date: Fri Sep 08 2023 - 17:32:17 EST


Expand the documentation on the KUnit debugfs filesystem on the
run_manual.rst page.

Add section describing how to access results using debugfs.

Add section describing how to run tests after boot using debugfs.

Signed-off-by: Rae Moar <rmoar@xxxxxxxxxx>
Co-developed-by: Sadiya Kazi <sadiyakazi@xxxxxxxxxx>
Signed-off-by: Sadiya Kazi <sadiyakazi@xxxxxxxxxx>
---
Documentation/dev-tools/kunit/run_manual.rst | 45 ++++++++++++++++++--
1 file changed, 41 insertions(+), 4 deletions(-)

diff --git a/Documentation/dev-tools/kunit/run_manual.rst b/Documentation/dev-tools/kunit/run_manual.rst
index e7b46421f247..613385c5ba5b 100644
--- a/Documentation/dev-tools/kunit/run_manual.rst
+++ b/Documentation/dev-tools/kunit/run_manual.rst
@@ -49,9 +49,46 @@ loaded.

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

+debugfs
+=======
+
+``debugfs`` is a file system that enables user interaction with the files to
+make kernel information available to user space. A user can interact with
+the debugfs filesystem using a variety of file operations, such as open,
+read, and write.
+
+By default, only the root user has access to the debugfs directory.
+
+If ``CONFIG_KUNIT_DEBUGFS`` is enabled, you can use KUnit debugfs
+filesystem to perform the following actions.
+
+Retrieve Test Results
+=====================
+
+You can use debugfs to retrieve KUnit test results. The test results are
+accessible from the debugfs filesystem in the following read-only file:
+
+.. code-block :: bash
+
+ /sys/kernel/debug/kunit/<test_suite>/results
+
+The test results are available in KTAP format.
+
+Run Tests After Kernel Has Booted
+=================================
+
+You can use the debugfs filesystem to trigger built-in tests to run after
+boot. To run the test suite, you can use the following command to write to
+the ``/sys/kernel/debug/kunit/<test_suite>/run`` file:
+
+.. code-block :: bash
+
+ echo "any string" > /sys/kernel/debugfs/kunit/<test_suite>/run
+
+As a result, the test suite runs and the results are printed to the kernel
+log.
+
.. 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.
+ The contents written to the debugfs file
+ ``/sys/kernel/debug/kunit/<test_suite>/run`` are not saved.
--
2.42.0.283.g2d96d420d3-goog