mirror of
https://github.com/torvalds/linux.git
synced 2026-07-27 01:32:21 +02:00
rust: tests: add Kconfig for KUnit test
There are 6 individual Rust KUnit test suites (plus the doctests one). All the tests are compiled unconditionally now, which adds ~200 kB to the kernel image for me on x86_64. As Rust matures, this bloating will inevitably grow. Add Kconfig.test which includes a RUST_KUNIT_TESTS menu, and all individual tests under it. As usual, new tests are all enabled if KUNIT_ALL_TESTS=y. Suggested-by: Alice Ryhl <aliceryhl@google.com> Signed-off-by: Yury Norov <ynorov@nvidia.com> Reviewed-by: David Gow <david@davidgow.net> Acked-by: Gary Guo <gary@garyguo.net> Link: https://patch.msgid.link/20260417031531.315281-3-ynorov@nvidia.com [ Fixed capitalization. Used singular for "API" for consistency. Reworded to clarify these are suites and that there exists the doctests one (which is the biggest at the moment by far). - Miguel ] Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
This commit is contained in:
parent
90b67443f0
commit
e74b7a3f5a
|
|
@ -2213,6 +2213,8 @@ config RUST
|
|||
|
||||
If unsure, say N.
|
||||
|
||||
source "rust/kernel/Kconfig.test"
|
||||
|
||||
config RUSTC_VERSION_TEXT
|
||||
string
|
||||
depends on RUST
|
||||
|
|
|
|||
76
rust/kernel/Kconfig.test
Normal file
76
rust/kernel/Kconfig.test
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
menuconfig RUST_KUNIT_TESTS
|
||||
bool "Rust KUnit tests"
|
||||
depends on KUNIT && RUST
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This menu collects all options for Rust KUnit tests.
|
||||
See Documentation/rust/testing.rst for how to protect
|
||||
unit tests with these options.
|
||||
|
||||
Say Y here to enable Rust KUnit tests.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
if RUST_KUNIT_TESTS
|
||||
config RUST_ALLOCATOR_KUNIT_TEST
|
||||
bool "KUnit tests for Rust allocator API" if !KUNIT_ALL_TESTS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit tests for the Rust allocator API.
|
||||
These are only for development and testing, not for regular
|
||||
kernel use cases.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config RUST_KVEC_KUNIT_TEST
|
||||
bool "KUnit tests for Rust KVec API" if !KUNIT_ALL_TESTS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit tests for the Rust KVec API.
|
||||
These are only for development and testing, not for
|
||||
regular kernel use cases.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config RUST_BITMAP_KUNIT_TEST
|
||||
bool "KUnit tests for Rust bitmap API" if !KUNIT_ALL_TESTS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit tests for the Rust bitmap API.
|
||||
These are only for development and testing, not for regular
|
||||
kernel use cases.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config RUST_KUNIT_SELFTEST
|
||||
bool "KUnit selftests for Rust" if !KUNIT_ALL_TESTS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit selftests. These are only
|
||||
for development and testing, not for regular kernel
|
||||
use cases.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config RUST_STR_KUNIT_TEST
|
||||
bool "KUnit tests for Rust strings API" if !KUNIT_ALL_TESTS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit tests for the Rust strings API.
|
||||
These are only for development and testing, not for regular
|
||||
kernel use cases.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
config RUST_ATOMICS_KUNIT_TEST
|
||||
bool "KUnit tests for Rust atomics API" if !KUNIT_ALL_TESTS
|
||||
default KUNIT_ALL_TESTS
|
||||
help
|
||||
This option enables KUnit tests for the Rust atomics API.
|
||||
These are only for development and testing, not for regular
|
||||
kernel use cases.
|
||||
|
||||
If unsure, say N.
|
||||
|
||||
endif
|
||||
|
|
@ -265,6 +265,7 @@ unsafe fn realloc(
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(CONFIG_RUST_ALLOCATOR_KUNIT_TEST)]
|
||||
#[macros::kunit_tests(rust_allocator)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -1508,6 +1508,7 @@ fn drop(&mut self) {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(CONFIG_RUST_KVEC_KUNIT_TEST)]
|
||||
#[macros::kunit_tests(rust_kvec)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -499,6 +499,7 @@ pub fn next_zero_bit(&self, start: usize) -> Option<usize> {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(CONFIG_RUST_BITMAP_KUNIT_TEST)]
|
||||
#[macros::kunit_tests(rust_kernel_bitmap)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -329,6 +329,7 @@ pub fn in_kunit_test() -> bool {
|
|||
!unsafe { bindings::kunit_get_current_test() }.is_null()
|
||||
}
|
||||
|
||||
#[cfg(CONFIG_RUST_KUNIT_SELFTEST)]
|
||||
#[kunit_tests(rust_kernel_kunit)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -415,6 +415,7 @@ macro_rules! c_str {
|
|||
}};
|
||||
}
|
||||
|
||||
#[cfg(CONFIG_RUST_STR_KUNIT_TEST)]
|
||||
#[kunit_tests(rust_kernel_str)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
|
|
|||
|
|
@ -154,6 +154,7 @@ fn rhs_into_delta(rhs: usize) -> isize_atomic_repr {
|
|||
}
|
||||
}
|
||||
|
||||
#[cfg(CONFIG_RUST_ATOMICS_KUNIT_TEST)]
|
||||
#[macros::kunit_tests(rust_atomics)]
|
||||
mod tests {
|
||||
use super::super::*;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user