Skip to content

Rust KUnit `#[test]` support improvements

Miguel Ojeda linux-kselftest linux-patches lkml rust-for-linux 1 version Applied

Status from this message: Applied to `rust-next` -- thanks everyone!

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest7 patches 32 repliesApplied

Patches in v1 Applied

#Subject and filesSizeRepliesApplied
1/7rust: kunit: support KUnit-mapped `assert!` macros in `#[test]`sinit/Kconfig rust/Makefile rust/kernel/kunit.rs +3 more+52 -34 replies
2/7rust: kunit: support checked `-> Result`s in KUnit `#[test]`srust/kernel/kunit.rs rust/macros/kunit.rs+27 -17 replies
3/7rust: add `kunit_tests` to the preluderust/kernel/kunit.rs rust/kernel/prelude.rs rust/macros/lib.rs+3 -41 reply
4/7rust: str: convert `rusttest` tests into KUnitrust/kernel/str.rs+4 -67 replies
5/7rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'srust/kernel/str.rs+30 -386 replies
6/7Documentation: rust: rename `#[test]`s to "`rusttest` host tests"Documentation/rust/testing.rst+7 -61 reply
7/7Documentation: rust: testing: add docs on the new KUnit `#[test]` testsDocumentation/rust/testing.rst+71 -01 reply

Reviews trailers per patch

All 7 patches have a Reviewed-by or Acked-by of their own; the series has one for all of them.

PatchDavid GowDanilo Krummrich
SeriesA-b
1/7R-b
2/7R-b
3/7R-b
4/7R-b
5/7R-b
6/7R-b
7/7R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v1 thread

Cover letter [PATCH 0/7] Rust KUnit `#[test]` support improvements

Improvements that build on top of the very basic #[test] support merged in v6.15.

They are fairly minimal changes, but they allow us to map assert*!s back to KUnit, plus to add support for test functions that return Results.

In essence, they get our #[test]s essentially on par with the documentation tests.

I also took the chance to convert some host #[test]s we had to KUnit in order to showcase the feature.

Finally, I added documentation that was lacking from the original submission.

I hope this helps.

Miguel Ojeda (7):
rust: kunit: support KUnit-mapped assert! macros in #[test]s
rust: kunit: support checked -> Results in KUnit #[test]s
rust: add kunit_tests to the prelude
rust: str: convert rusttest tests into KUnit
rust: str: take advantage of the -> Result support in KUnit

    `#[test]`'s

Documentation: rust: rename #[test]s to "rusttest host tests"
Documentation: rust: testing: add docs on the new KUnit #[test]
tests

 Documentation/rust/testing.rst | 80 ++++++++++++++++++++++++++++++++--
 init/Kconfig                   |  3 ++
 rust/Makefile                  |  3 +-
 rust/kernel/kunit.rs           | 29 ++++++++++--
 rust/kernel/prelude.rs         |  2 +-
 rust/kernel/str.rs             | 76 ++++++++++++++------------------
 rust/macros/helpers.rs         | 16 +++++++
 rust/macros/kunit.rs           | 31 ++++++++++++-
 rust/macros/lib.rs             |  6 ++-
 9 files changed, 191 insertions(+), 55 deletions(-)

base-commit: b4432656b36e5cc1d50a1f2dc15357543add530e --
2.49.0