linux/rust/macros
Miguel Ojeda 950b306c29 rust: kunit: support checked -> Results in KUnit #[test]s
Currently, return values of KUnit `#[test]` functions are ignored.

Thus introduce support for `-> Result` functions by checking their
returned values.

At the same time, require that test functions return `()` or `Result<T,
E>`, which should avoid mistakes, especially with non-`#[must_use]`
types. Other types can be supported in the future if needed.

With this, a failing test like:

    #[test]
    fn my_test() -> Result {
        f()?;
        Ok(())
    }

will output:

    [    3.744214]     KTAP version 1
    [    3.744287]     # Subtest: my_test_suite
    [    3.744378]     # speed: normal
    [    3.744399]     1..1
    [    3.745817]     # my_test: ASSERTION FAILED at rust/kernel/lib.rs:321
    [    3.745817]     Expected is_test_result_ok(my_test()) to be true, but is false
    [    3.747152]     # my_test.speed: normal
    [    3.747199]     not ok 1 my_test
    [    3.747345] not ok 4 my_test_suite

Reviewed-by: David Gow <davidgow@google.com>
Acked-by: Danilo Krummrich <dakr@kernel.org>
Link: https://lore.kernel.org/r/20250502215133.1923676-3-ojeda@kernel.org
[ Used `::kernel` for paths. - Miguel ]
Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2025-05-27 20:09:59 +02:00
..
concat_idents.rs
export.rs rust: add #[export] macro 2025-03-09 20:52:46 +01:00
helpers.rs rust: kunit: support KUnit-mapped assert! macros in #[test]s 2025-05-27 20:07:09 +02:00
kunit.rs rust: kunit: support checked -> Results in KUnit #[test]s 2025-05-27 20:09:59 +02:00
lib.rs rust: kunit: support KUnit-mapped assert! macros in #[test]s 2025-05-27 20:07:09 +02:00
module.rs rust: use absolute paths in macros referencing core and kernel 2025-05-23 00:12:14 +02:00
paste.rs rust: clean Rust 1.88.0's clippy::uninlined_format_args lint 2025-05-07 00:11:47 +02:00
quote.rs rust: make pin-init its own crate 2025-03-16 21:59:19 +01:00
vtable.rs rust: macros: vtable: fix HAS_* redefinition (gen_const_name) 2023-08-09 21:15:07 +02:00