]> www.infradead.org Git - users/jedix/linux-maple.git/commit
rust: kunit: add KUnit case and suite macros
authorJosé Expósito <jose.exposito89@gmail.com>
Fri, 7 Mar 2025 09:00:56 +0000 (17:00 +0800)
committerMiguel Ojeda <ojeda@kernel.org>
Thu, 20 Mar 2025 11:26:42 +0000 (12:26 +0100)
commit22097b966f5d2be93b315c791a26d4ed9b37f195
tree3142f79650070a402b1db75ce34e918c80e80524
parentfb625227d540ddead4d21813410a116e9452d232
rust: kunit: add KUnit case and suite macros

Add a couple of Rust const functions and macros to allow to develop
KUnit tests without relying on generated C code:

 - The `kunit_unsafe_test_suite!` Rust macro is similar to the
   `kunit_test_suite` C macro. It requires a NULL-terminated array of
   test cases (see below).
 - The `kunit_case` Rust function is similar to the `KUNIT_CASE` C macro.
   It generates as case from the name and function.
 - The `kunit_case_null` Rust function generates a NULL test case, which
   is to be used as delimiter in `kunit_test_suite!`.

While these functions and macros can be used on their own, a future
patch will introduce another macro to create KUnit tests using a
user-space like syntax.

Signed-off-by: José Expósito <jose.exposito89@gmail.com>
Co-developed-by: Matt Gilbride <mattgilbride@google.com>
Signed-off-by: Matt Gilbride <mattgilbride@google.com>
Co-developed-by: Miguel Ojeda <ojeda@kernel.org>
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
Co-developed-by: David Gow <davidgow@google.com>
Signed-off-by: David Gow <davidgow@google.com>
Link: https://lore.kernel.org/r/20250307090103.918788-2-davidgow@google.com
[ Applied Markdown in comment. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
rust/kernel/kunit.rs