mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-31 03:35:32 -04:00
docs/zh_CN: Update rust/testing.rst translation
Update Documentation/rust/testing.rst translation.
Update the translation through commit 09699b2419
("Documentation: rust: testing: add Kconfig guidance")
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Signed-off-by: Ben Guo <ben.guo@openatom.club>
Signed-off-by: Alex Shi <alexs@kernel.org>
This commit is contained in:
@@ -128,10 +128,13 @@ Rust 测试中常用的断言宏是来自 Rust 标准库( ``core`` )中的 `
|
||||
|
||||
这些测试通过 ``kunit_tests`` 过程宏引入,该宏将测试套件的名称作为参数。
|
||||
|
||||
每个测试套件都应该由 ``rust/kernel/Kconfig.test`` 中的 Kconfig 选项保护。
|
||||
|
||||
例如,假设想要测试前面文档测试示例中的函数 ``f``,我们可以在定义该函数的同一文件中编写:
|
||||
|
||||
.. code-block:: rust
|
||||
|
||||
#[cfg(CONFIG_RUST_MYMOD_KUNIT_TEST)]
|
||||
#[kunit_tests(rust_kernel_mymod)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
@@ -158,6 +161,7 @@ Rust 测试中常用的断言宏是来自 Rust 标准库( ``core`` )中的 `
|
||||
|
||||
.. code-block:: rust
|
||||
|
||||
#[cfg(CONFIG_RUST_MYMOD_KUNIT_TEST)]
|
||||
#[kunit_tests(rust_kernel_mymod)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
Reference in New Issue
Block a user