Skip to content

Commit c4c0574

Browse files
committed
rust: add kunit_tests to the prelude
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 <[email protected]> Acked-by: Danilo Krummrich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Miguel Ojeda <[email protected]>
1 parent eb2fe74 commit c4c0574

File tree

3 files changed

+3
-4
lines changed

3 files changed

+3
-4
lines changed

rust/kernel/kunit.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
//!
77
//! Reference: <https://docs.kernel.org/dev-tools/kunit/index.html>
88
9+
use crate::prelude::*;
910
use core::{ffi::c_void, fmt};
1011

1112
/// Prints a KUnit error-level message.
@@ -40,8 +41,6 @@ pub fn info(args: fmt::Arguments<'_>) {
4041
}
4142
}
4243

43-
use macros::kunit_tests;
44-
4544
/// Asserts that a boolean expression is `true` at runtime.
4645
///
4746
/// Public but hidden since it should only be used from generated tests.

rust/kernel/prelude.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ pub use ::ffi::{
2222
pub use crate::alloc::{flags::*, Box, KBox, KVBox, KVVec, KVec, VBox, VVec, Vec};
2323

2424
#[doc(no_inline)]
25-
pub use macros::{export, module, vtable};
25+
pub use macros::{export, kunit_tests, module, vtable};
2626

2727
pub use pin_init::{init, pin_data, pin_init, pinned_drop, InPlaceWrite, Init, PinInit, Zeroable};
2828

rust/macros/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ pub fn paste(input: TokenStream) -> TokenStream {
407407
/// # Examples
408408
///
409409
/// ```ignore
410-
/// # use macros::kunit_tests;
410+
/// # use kernel::prelude::*;
411411
/// #[kunit_tests(kunit_test_suit_name)]
412412
/// mod tests {
413413
/// #[test]

0 commit comments

Comments
 (0)