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

Configure Feed

Select the types of activity you want to include in your feed.

rust: kunit: use `kernel::{fmt,prelude::fmt!}`

Reduce coupling to implementation details of the formatting machinery by
avoiding direct use for `core`'s formatting traits and macros.

Acked-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Reviewed-by: Alice Ryhl <aliceryhl@google.com>
Reviewed-by: Benno Lossin <lossin@kernel.org>
Signed-off-by: Tamir Duberstein <tamird@gmail.com>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>

authored by

Tamir Duberstein and committed by
Miguel Ojeda
aa2417c1 e6aedde2

+5 -5
+4 -4
rust/kernel/kunit.rs
··· 6 6 //! 7 7 //! Reference: <https://docs.kernel.org/dev-tools/kunit/index.html> 8 8 9 + use crate::fmt; 9 10 use crate::prelude::*; 10 - use core::fmt; 11 11 12 12 #[cfg(CONFIG_PRINTK)] 13 13 use crate::c_str; ··· 74 74 // mistake (it is hidden to prevent that). 75 75 // 76 76 // This mimics KUnit's failed assertion format. 77 - $crate::kunit::err(format_args!( 77 + $crate::kunit::err($crate::prelude::fmt!( 78 78 " # {}: ASSERTION FAILED at {FILE}:{LINE}\n", 79 79 $name 80 80 )); 81 - $crate::kunit::err(format_args!( 81 + $crate::kunit::err($crate::prelude::fmt!( 82 82 " Expected {CONDITION} to be true, but is false\n" 83 83 )); 84 - $crate::kunit::err(format_args!( 84 + $crate::kunit::err($crate::prelude::fmt!( 85 85 " Failure not reported to KUnit since this is a non-KUnit task\n" 86 86 )); 87 87 break 'out;
+1 -1
scripts/rustdoc_test_gen.rs
··· 202 202 // This follows the syntax for declaring test metadata in the proposed KTAP v2 spec, which may 203 203 // be used for the proposed KUnit test attributes API. Thus hopefully this will make migration 204 204 // easier later on. 205 - ::kernel::kunit::info(format_args!(" # {kunit_name}.location: {real_path}:{line}\n")); 205 + ::kernel::kunit::info(fmt!(" # {kunit_name}.location: {real_path}:{line}\n")); 206 206 207 207 /// The anchor where the test code body starts. 208 208 #[allow(unused)]