mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] rust: doctest: unify with other kunit tests
@ 2026-06-16 15:24 Gary Guo
  2026-06-16 15:24 ` [PATCH 1/3] rust: kunit: use `file!()` inside `kunit_assert!` Gary Guo
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Gary Guo @ 2026-06-16 15:24 UTC (permalink / raw)
  To: Miguel Ojeda, Boqun Feng, Björn Roy Baron, Benno Lossin,
	Andreas Hindborg, Alice Ryhl, Trevor Gross, Danilo Krummrich,
	Daniel Almeida, Tamir Duberstein, Alexandre Courbot,
	Onur Özkan, Brendan Higgins, David Gow, Rae Moar
  Cc: rust-for-linux, linux-kernel, linux-kselftest, kunit-dev, Gary Guo

Currently in Rust, kunit tests are handled with `kunit_tests`, while the
doctests generate a lot `extern "C"` functions and invoke them through a
generated C wrapper.

This is currently needed because of the special treatment of file name and
line numbers from doctests. Convert them to override `file!()` and
`line!()` macro instead, and use them inside `kunit_assert!`.

With this it is possible to just generate `#[kunit_tests]` and `#[test]`
for doctests.

Signed-off-by: Gary Guo <gary@garyguo.net>
---
Gary Guo (3):
      rust: kunit: use `file!()` inside `kunit_assert!`
      rust: kunit: use `line!()` inside `kunit_assert!`
      rust: doctest: generate Rust kunit test suites

 Documentation/rust/general-information.rst |  4 +-
 init/Kconfig                               |  3 --
 rust/Makefile                              |  4 +-
 rust/kernel/device_id.rs                   |  2 +-
 rust/kernel/kunit.rs                       | 11 +++--
 rust/kernel/str.rs                         |  2 +-
 rust/macros/helpers.rs                     | 16 -------
 rust/macros/kunit.rs                       |  5 +-
 rust/macros/lib.rs                         |  5 --
 scripts/rustdoc_test_gen.rs                | 73 ++++++++----------------------
 10 files changed, 31 insertions(+), 94 deletions(-)
---
base-commit: c425609d6ac4012c8bbf01ec2e10e801b1923a7b
change-id: 20260616-kunit-348f2c029b1e

Best regards,
--  
Gary Guo <gary@garyguo.net>


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2026-06-22 13:00 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-06-16 15:24 [PATCH 0/3] rust: doctest: unify with other kunit tests Gary Guo
2026-06-16 15:24 ` [PATCH 1/3] rust: kunit: use `file!()` inside `kunit_assert!` Gary Guo
2026-06-20 11:07   ` David Gow
2026-06-16 15:24 ` [PATCH 2/3] rust: kunit: use `line!()` " Gary Guo
2026-06-20 11:07   ` David Gow
2026-06-22 13:00   ` Gary Guo
2026-06-16 15:24 ` [PATCH 3/3] rust: doctest: generate Rust kunit test suites Gary Guo
2026-06-20 11:07   ` David Gow

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®