]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
rust: add `kunit_tests` to the prelude
authorMiguel Ojeda <ojeda@kernel.org>
Fri, 2 May 2025 21:51:28 +0000 (23:51 +0200)
committerMiguel Ojeda <ojeda@kernel.org>
Tue, 27 May 2025 18:09:59 +0000 (20:09 +0200)
It is convenient to have certain things in the `kernel` prelude, and
means kernel developers will find it even easier to start writing tests.

And, anyway, nobody should need to use this identifier for anything else.

Thus add it to the prelude.

Reviewed-by: David Gow <davidgow@google.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250502215133.1923676-4-ojeda@kernel.org
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/kunit.rs
rust/kernel/prelude.rs
rust/macros/lib.rs

index 355e9d56dada9016c226eab7de6985e797af84eb..4b8cdcb21e7772414024246a98e2d39187ddcbb3 100644 (file)
@@ -6,6 +6,7 @@
 //!
 //! Reference: <https://docs.kernel.org/dev-tools/kunit/index.html>
 
+use crate::prelude::*;
 use core::{ffi::c_void, fmt};
 
 /// Prints a KUnit error-level message.
@@ -40,8 +41,6 @@ pub fn info(args: fmt::Arguments<'_>) {
     }
 }
 
-use macros::kunit_tests;
-
 /// Asserts that a boolean expression is `true` at runtime.
 ///
 /// Public but hidden since it should only be used from generated tests.
index f869b02f1f25f86552c727150417177a2b5d0708..2f30a398dddd1e4529fd9811c64f8371ac80ceca 100644 (file)
@@ -22,7 +22,7 @@ pub use ::ffi::{
 pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec, Vec};
 
 #[doc(no_inline)]
-pub use macros::{export, module, vtable};
+pub use macros::{export, kunit_tests, module, vtable};
 
 pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, Init, PinInit, Zeroable};
 
index bb5df3b730fc2284d2a066550d25e428a95b4de7..fa847cf3a9b5f4200600a0c74ec78ad5e43e8118 100644 (file)
@@ -407,7 +407,7 @@ pub fn paste(input: TokenStream) -> TokenStream {
 /// # Examples
 ///
 /// ```ignore
-/// # use macros::kunit_tests;
+/// # use kernel::prelude::*;
 /// #[kunit_tests(kunit_test_suit_name)]
 /// mod tests {
 ///     #[test]