rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rust: workqueue: Enable execution of doctests
@ 2024-10-12  6:30 Dirk Behme
  2024-10-12  8:15 ` Boqun Feng
  2024-10-14  8:23 ` Alice Ryhl
  0 siblings, 2 replies; 6+ messages in thread
From: Dirk Behme @ 2024-10-12  6:30 UTC (permalink / raw)
  To: rust-for-linux; +Cc: Alice Ryhl, Dirk Behme

Having the Rust doctests enabled these workqueue tests are built but not
executed as the final callers of the print_*() functions are missing.
Add them.

The result is

     # rust_doctest_kernel_workqueue_rs_0.location: 
rust/kernel/workqueue.rs:35
rust_doctests_kernel: The value is: 42
     ok 94 rust_doctest_kernel_workqueue_rs_0
     # rust_doctest_kernel_workqueue_rs_3.location: 
rust/kernel/workqueue.rs:78
rust_doctests_kernel: The value is: 24
rust_doctests_kernel: The second value is: 42
     ok 97 rust_doctest_kernel_workqueue_rs_3

Without this change the "The value ..." outputs are not there meaning 
that this
test code is not run.

Cc: Alice Ryhl <aliceryhl@google.com>
Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
---
  rust/kernel/workqueue.rs | 5 +++++
  1 file changed, 5 insertions(+)

diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
index 10d2bc62e2cf..ba0f397f8b8b 100644
--- a/rust/kernel/workqueue.rs
+++ b/rust/kernel/workqueue.rs
@@ -69,6 +69,8 @@
  //! fn print_later(val: Arc<MyStruct>) {
  //!     let _ = workqueue::system().enqueue(val);
  //! }
+//!
+//! # let _ = print_later(MyStruct::new(42).unwrap());
  //! ```
  //!
  //! The following example shows how multiple `work_struct` fields 
can be used:
@@ -126,6 +128,9 @@
  //! fn print_2_later(val: Arc<MyStruct>) {
  //!     let _ = workqueue::system().enqueue::<Arc<MyStruct>, 2>(val);
  //! }
+//!
+//! # let _ = print_1_later(MyStruct::new(24, 25).unwrap());
+//! # let _ = print_2_later(MyStruct::new(41, 42).unwrap());
  //! ```
  //!
  //! C header: 
[`include/linux/workqueue.h`](srctree/include/linux/workqueue.h)
-- 
2.34.1

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

* Re: [PATCH] rust: workqueue: Enable execution of doctests
  2024-10-12  6:30 [PATCH] rust: workqueue: Enable execution of doctests Dirk Behme
@ 2024-10-12  8:15 ` Boqun Feng
  2024-10-12  8:18   ` Boqun Feng
  2024-10-14  8:23 ` Alice Ryhl
  1 sibling, 1 reply; 6+ messages in thread
From: Boqun Feng @ 2024-10-12  8:15 UTC (permalink / raw)
  To: Dirk Behme; +Cc: rust-for-linux, Alice Ryhl

Hi Dirk,

On Sat, Oct 12, 2024 at 08:30:38AM +0200, Dirk Behme wrote:
> Having the Rust doctests enabled these workqueue tests are built but not
> executed as the final callers of the print_*() functions are missing.
> Add them.
> 

Thanks for doing this!

> The result is
> 
>     # rust_doctest_kernel_workqueue_rs_0.location:
> rust/kernel/workqueue.rs:35
> rust_doctests_kernel: The value is: 42
>     ok 94 rust_doctest_kernel_workqueue_rs_0
>     # rust_doctest_kernel_workqueue_rs_3.location:
> rust/kernel/workqueue.rs:78
> rust_doctests_kernel: The value is: 24
> rust_doctests_kernel: The second value is: 42
>     ok 97 rust_doctest_kernel_workqueue_rs_3
> 
> Without this change the "The value ..." outputs are not there meaning that
> this

Unintended newline here?

> test code is not run.
> 
> Cc: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>
> ---
>  rust/kernel/workqueue.rs | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
> index 10d2bc62e2cf..ba0f397f8b8b 100644
> --- a/rust/kernel/workqueue.rs
> +++ b/rust/kernel/workqueue.rs
> @@ -69,6 +69,8 @@
>  //! fn print_later(val: Arc<MyStruct>) {
>  //!     let _ = workqueue::system().enqueue(val);
>  //! }
> +//!
> +//! # let _ = print_later(MyStruct::new(42).unwrap());

would the `let _` be necessary here? Could you just do:

 +//! # print_later(MyStruct::new(42).unwrap());

?

Otherwise this patch looks good to me.

Regards,
Boqun

>  //! ```
>  //!
>  //! The following example shows how multiple `work_struct` fields can be
> used:
> @@ -126,6 +128,9 @@
>  //! fn print_2_later(val: Arc<MyStruct>) {
>  //!     let _ = workqueue::system().enqueue::<Arc<MyStruct>, 2>(val);
>  //! }
> +//!
> +//! # let _ = print_1_later(MyStruct::new(24, 25).unwrap());
> +//! # let _ = print_2_later(MyStruct::new(41, 42).unwrap());
>  //! ```
>  //!
>  //! C header:
> [`include/linux/workqueue.h`](srctree/include/linux/workqueue.h)
> -- 
> 2.34.1
> 

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

* Re: [PATCH] rust: workqueue: Enable execution of doctests
  2024-10-12  8:15 ` Boqun Feng
@ 2024-10-12  8:18   ` Boqun Feng
  2024-10-12 10:25     ` Miguel Ojeda
  2024-10-14 11:04     ` Alice Ryhl
  0 siblings, 2 replies; 6+ messages in thread
From: Boqun Feng @ 2024-10-12  8:18 UTC (permalink / raw)
  To: Dirk Behme; +Cc: rust-for-linux, Alice Ryhl

On Sat, Oct 12, 2024 at 01:15:47AM -0700, Boqun Feng wrote:
[...]
> Otherwise this patch looks good to me.
> 

Oh, but you may want to Cc other Rust maintainers and reviewers next
time ;-)

Regards,
Boqun

[...]

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

* Re: [PATCH] rust: workqueue: Enable execution of doctests
  2024-10-12  8:18   ` Boqun Feng
@ 2024-10-12 10:25     ` Miguel Ojeda
  2024-10-14 11:04     ` Alice Ryhl
  1 sibling, 0 replies; 6+ messages in thread
From: Miguel Ojeda @ 2024-10-12 10:25 UTC (permalink / raw)
  To: Boqun Feng; +Cc: Dirk Behme, rust-for-linux, Alice Ryhl

On Sat, Oct 12, 2024 at 10:18 AM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> Oh, but you may want to Cc other Rust maintainers and reviewers next
> time ;-)

Yeah, that may help others see the emails -- we have some notes about
that at https://rust-for-linux.com/contributing#submitting-patches.

Cheers,
Miguel

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

* Re: [PATCH] rust: workqueue: Enable execution of doctests
  2024-10-12  6:30 [PATCH] rust: workqueue: Enable execution of doctests Dirk Behme
  2024-10-12  8:15 ` Boqun Feng
@ 2024-10-14  8:23 ` Alice Ryhl
  1 sibling, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2024-10-14  8:23 UTC (permalink / raw)
  To: Dirk Behme; +Cc: rust-for-linux

On Sat, Oct 12, 2024 at 8:30 AM Dirk Behme <dirk.behme@gmail.com> wrote:
>
> Having the Rust doctests enabled these workqueue tests are built but not
> executed as the final callers of the print_*() functions are missing.
> Add them.
>
> The result is
>
>      # rust_doctest_kernel_workqueue_rs_0.location:
> rust/kernel/workqueue.rs:35
> rust_doctests_kernel: The value is: 42
>      ok 94 rust_doctest_kernel_workqueue_rs_0
>      # rust_doctest_kernel_workqueue_rs_3.location:
> rust/kernel/workqueue.rs:78
> rust_doctests_kernel: The value is: 24
> rust_doctests_kernel: The second value is: 42
>      ok 97 rust_doctest_kernel_workqueue_rs_3
>
> Without this change the "The value ..." outputs are not there meaning
> that this
> test code is not run.
>
> Cc: Alice Ryhl <aliceryhl@google.com>
> Signed-off-by: Dirk Behme <dirk.behme@gmail.com>

One nit below. With that fixed:

Reviewed-by: Alice Ryhl <aliceryhl@google.com>

> diff --git a/rust/kernel/workqueue.rs b/rust/kernel/workqueue.rs
> index 10d2bc62e2cf..ba0f397f8b8b 100644
> --- a/rust/kernel/workqueue.rs
> +++ b/rust/kernel/workqueue.rs
> @@ -69,6 +69,8 @@
>   //! fn print_later(val: Arc<MyStruct>) {
>   //!     let _ = workqueue::system().enqueue(val);
>   //! }
> +//!
> +//! # let _ = print_later(MyStruct::new(42).unwrap());

Having an empty line followed by a hidden line means that the rendered
html will have an unnecessary empty line at the end. Please remove the
empty line.

Alice

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

* Re: [PATCH] rust: workqueue: Enable execution of doctests
  2024-10-12  8:18   ` Boqun Feng
  2024-10-12 10:25     ` Miguel Ojeda
@ 2024-10-14 11:04     ` Alice Ryhl
  1 sibling, 0 replies; 6+ messages in thread
From: Alice Ryhl @ 2024-10-14 11:04 UTC (permalink / raw)
  To: Boqun Feng; +Cc: Dirk Behme, rust-for-linux

On Sat, Oct 12, 2024 at 10:18 AM Boqun Feng <boqun.feng@gmail.com> wrote:
>
> On Sat, Oct 12, 2024 at 01:15:47AM -0700, Boqun Feng wrote:
> [...]
> > Otherwise this patch looks good to me.
> >
>
> Oh, but you may want to Cc other Rust maintainers and reviewers next
> time ;-)

It should go to the workqueue maintainers too, especially Tejun Heo.

Alice

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

end of thread, other threads:[~2024-10-14 11:04 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-12  6:30 [PATCH] rust: workqueue: Enable execution of doctests Dirk Behme
2024-10-12  8:15 ` Boqun Feng
2024-10-12  8:18   ` Boqun Feng
2024-10-12 10:25     ` Miguel Ojeda
2024-10-14 11:04     ` Alice Ryhl
2024-10-14  8:23 ` Alice Ryhl

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).