summaryrefslogtreecommitdiff
path: root/rust/kernel/error.rs
diff options
context:
space:
mode:
authorMiguel Ojeda <ojeda@kernel.org>2025-07-26 20:07:50 +0200
committerDanilo Krummrich <dakr@kernel.org>2025-08-24 15:29:51 +0200
commit17d5efcbfe6f3da23afb79d84c27cefb2b3f331a (patch)
tree60f2a68ddbc19d7bf3f3df2168f07ad3ba1e5ea5 /rust/kernel/error.rs
parentac9eea3d08c25fb213deb113d246ff5dadb31fbc (diff)
rust: kernel: remove support for unused host `#[test]`s
Since commit 028df914e546 ("rust: str: convert `rusttest` tests into KUnit"), we do not have anymore host `#[test]`s that run in the host. Moreover, we do not plan to add any new ones -- tests should generally run within KUnit, since there they are built the same way the kernel does. While we may want to have some way to define tests that can also be run outside the kernel, we still want to test within the kernel too [1], and thus would likely use a custom syntax anyway to define them. Thus simplify the `rusttest` target by removing support for host `#[test]`s for the `kernel` crate. This still maintains the support for the `macros` crate, even though we do not have any such tests there. Link: https://lore.kernel.org/rust-for-linux/CABVgOS=AKHSfifp0S68K3jgNZAkALBr=7iFb=niryG5WDxjSrg@mail.gmail.com/ [1] Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Reviewed-by: Danilo Krummrich <dakr@kernel.org> Reviewed-by: David Gow <davidgow@google.com> Link: https://lore.kernel.org/r/20250726180750.2735836-1-ojeda@kernel.org Signed-off-by: Danilo Krummrich <dakr@kernel.org>
Diffstat (limited to 'rust/kernel/error.rs')
-rw-r--r--rust/kernel/error.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/rust/kernel/error.rs b/rust/kernel/error.rs
index a41de293dcd1..67da2d118e65 100644
--- a/rust/kernel/error.rs
+++ b/rust/kernel/error.rs
@@ -158,7 +158,7 @@ impl Error {
}
/// Returns a string representing the error, if one exists.
- #[cfg(not(any(test, testlib)))]
+ #[cfg(not(testlib))]
pub fn name(&self) -> Option<&'static CStr> {
// SAFETY: Just an FFI call, there are no extra safety requirements.
let ptr = unsafe { bindings::errname(-self.0.get()) };
@@ -175,7 +175,7 @@ impl Error {
/// When `testlib` is configured, this always returns `None` to avoid the dependency on a
/// kernel function so that tests that use this (e.g., by calling [`Result::unwrap`]) can still
/// run in userspace.
- #[cfg(any(test, testlib))]
+ #[cfg(testlib)]
pub fn name(&self) -> Option<&'static CStr> {
None
}