Skip to contentSkip to conversation

rust: workqueue: Enable execution of doctests

PATCH Superseded Dirk Behme 4 participants 6 messages Oct 12, 2024 – Oct 14, 2024 Rust

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH 1/1 rust: workqueue: Enable execution of doctests

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.

---
 rust/kernel/workqueue.rs | 5 +++++
 1 file changed, 5 insertions(+)
rust/kernel/workqueue.rs +2 -0
index 10d2bc62e2cf..ba0f397f8b8b 100644
@@ -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)

Signature · 1 line
2.34.1
#1 lore raw

Hi Dirk,

Quoted 4 lines · 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.

Thanks for doing this!

Quoted 12 lines

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

Quoted 2 lines

Without this change the "The value ..." outputs are not there meaning that this

Unintended newline here?

Quoted 13 lines

test code is not run.

---
 rust/kernel/workqueue.rs | 5 +++++
 1 file changed, 5 insertions(+)
rust/kernel/workqueue.rs +0 -0
index 10d2bc62e2cf..ba0f397f8b8b 100644

rust/kernel/workqueue.rs line 73

Quoted 5 lines
rust/kernel/workqueue.rs +2 -0
@@ -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

Quoted 18 lines
rust/kernel/workqueue.rs +0 -0
 //! ```
 //!
 //! The following example shows how multiple `work_struct` fields can be

used:

rust/kernel/workqueue.rs +3 -0
@@ -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)

Signature · 1 line
2.34.1
#2 lore raw

On Sat, Oct 12, 2024 at 01:15:47AM -0700, Boqun Feng wrote:
[...]

Quoted 2 lines

Otherwise this patch looks good to me.

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

Regards,
Boqun

[...]

reviewer
#4 lore raw
In reply to Boqun Feng
Quoted 8 lines · Boqun Feng

On Sat, Oct 12, 2024 at 01:15:47AM -0700, Boqun Feng wrote:
[...]

Quoted 2 lines

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

reviewer Reviewed-by on v1 1/1
#5 lore raw
In reply to Dirk Behme
Quoted 17 lines · 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

Quoted 6 lines

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

One nit below. With that fixed:

rust/kernel/workqueue.rs line 73

Quoted 10 lines
rust/kernel/workqueue.rs +2 -0
index 10d2bc62e2cf..ba0f397f8b8b 100644
@@ -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