summaryrefslogtreecommitdiff
path: root/Documentation/rust
diff options
context:
space:
mode:
authorYury Norov <ynorov@nvidia.com>2026-04-16 23:15:29 -0400
committerMiguel Ojeda <ojeda@kernel.org>2026-06-08 02:30:33 +0200
commit09699b24199ac546037de252ba4907d99f4a8c7a (patch)
treef3976312b428caa4502255a446b9d575b8c05d65 /Documentation/rust
parente74b7a3f5aee02c7df33c79991fd867ce421051b (diff)
downloadlinux-next-09699b24199ac546037de252ba4907d99f4a8c7a.tar.gz
linux-next-09699b24199ac546037de252ba4907d99f4a8c7a.zip
Documentation: rust: testing: add Kconfig guidance
Now that the Rust KUnit tests are protected with Kconfig, update the documentation to mention it. Signed-off-by: Yury Norov <ynorov@nvidia.com> Reviewed-by: David Gow <david@davidgow.net> Acked-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260417031531.315281-4-ynorov@nvidia.com [ Fixed the paragraph by moving the new sentence above. Added gate in the other example as well. Applied proper formatting. Reworded slightly. - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Diffstat (limited to 'Documentation/rust')
-rw-r--r--Documentation/rust/testing.rst5
1 files changed, 5 insertions, 0 deletions
diff --git a/Documentation/rust/testing.rst b/Documentation/rust/testing.rst
index f43cb77bcc69..e3943aceceb9 100644
--- a/Documentation/rust/testing.rst
+++ b/Documentation/rust/testing.rst
@@ -140,11 +140,15 @@ are also mapped to KUnit.
These tests are introduced by the ``kunit_tests`` procedural macro, which takes
the name of the test suite as an argument.
+Each test suite should be guarded by a Kconfig option in
+``rust/kernel/Kconfig.test``.
+
For instance, assume we want to test the function ``f`` from the documentation
tests section. We could write, in the same file where we have our function:
.. code-block:: rust
+ #[cfg(CONFIG_RUST_MYMOD_KUNIT_TEST)]
#[kunit_tests(rust_kernel_mymod)]
mod tests {
use super::*;
@@ -173,6 +177,7 @@ the unit type ``()``) or ``Result`` (i.e. any ``Result<T, E>``). For instance:
.. code-block:: rust
+ #[cfg(CONFIG_RUST_MYMOD_KUNIT_TEST)]
#[kunit_tests(rust_kernel_mymod)]
mod tests {
use super::*;