Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Documentation: Add debugfs docs with run after boot

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.

Reviewed-by: David Gow <davidgow@google.com>
Signed-off-by: Rae Moar <rmoar@google.com>
Signed-off-by: Shuah Khan <skhan@linuxfoundation.org>

authored by

Rae Moar and committed by
Shuah Khan
e9f0e21c c72a8709

+47 -4
+47 -4
Documentation/dev-tools/kunit/run_manual.rst
··· 49 49 50 50 The results will appear in TAP format in ``dmesg``. 51 51 52 + debugfs 53 + ======= 54 + 55 + KUnit can be accessed from userspace via the debugfs filesystem (See more 56 + information about debugfs at Documentation/filesystems/debugfs.rst). 57 + 58 + If ``CONFIG_KUNIT_DEBUGFS`` is enabled, the KUnit debugfs filesystem is 59 + mounted at /sys/kernel/debug/kunit. You can use this filesystem to perform 60 + the following actions. 61 + 62 + Retrieve Test Results 63 + ===================== 64 + 65 + You can use debugfs to retrieve KUnit test results. The test results are 66 + accessible from the debugfs filesystem in the following read-only file: 67 + 68 + .. code-block :: bash 69 + 70 + /sys/kernel/debug/kunit/<test_suite>/results 71 + 72 + The test results are printed in a KTAP document. Note this document is separate 73 + to the kernel log and thus, may have different test suite numbering. 74 + 75 + Run Tests After Kernel Has Booted 76 + ================================= 77 + 78 + You can use the debugfs filesystem to trigger built-in tests to run after 79 + boot. To run the test suite, you can use the following command to write to 80 + the ``/sys/kernel/debug/kunit/<test_suite>/run`` file: 81 + 82 + .. code-block :: bash 83 + 84 + echo "any string" > /sys/kernel/debugfs/kunit/<test_suite>/run 85 + 86 + As a result, the test suite runs and the results are printed to the kernel 87 + log. 88 + 89 + However, this feature is not available with KUnit suites that use init data, 90 + because init data may have been discarded after the kernel boots. KUnit 91 + suites that use init data should be defined using the 92 + kunit_test_init_section_suites() macro. 93 + 94 + Also, you cannot use this feature to run tests concurrently. Instead a test 95 + will wait to run until other tests have completed or failed. 96 + 52 97 .. note :: 53 98 54 - If ``CONFIG_KUNIT_DEBUGFS`` is enabled, KUnit test results will 55 - be accessible from the ``debugfs`` filesystem (if mounted). 56 - They will be in ``/sys/kernel/debug/kunit/<test_suite>/results``, in 57 - TAP format. 99 + For test authors, to use this feature, tests will need to correctly initialise 100 + and/or clean up any data, so the test runs correctly a second time.