On Tue, 16 Sept 2025 at 10:13, Kaibo Ma ent3rm4n@gmail.com wrote:
The `kunit_test` proc macro only checks for the `test` attribute immediately preceding a `fn`. If the function is disabled via a `cfg`, the generated code would result in a compile error referencing a non-existent function [1].
This collects attributes and specifically cherry-picks `cfg` attributes to be duplicated inside KUnit wrapper functions such that a test function disabled via `cfg` compiles and is marked as skipped in KUnit correctly.
Link: https://lore.kernel.org/rust-for-linux/CANiq72==48=69hYiDo1321pCzgn_n1_jg=ez... [1] Closes: https://github.com/Rust-for-Linux/linux/issues/1185 Suggested-by: Miguel Ojeda ojeda@kernel.org Suggested-by: David Gow davidgow@google.com Signed-off-by: Kaibo Ma ent3rm4n@gmail.com
v1 -> v2: applied suggestion such that cfg'd out tests show as skipped on KUnit
Thanks: this looks good to me now. I'd still love for there to be a way to totally remove tests which are disabled, but I suspect it's best to avoid adding the complexity involved in handling that until we actually need it. (Maybe never!)
So this is: Reviewed-by: David Gow davidgow@google.com
Thanks, -- David