Skip to contentSkip to conversation

rust: workqueue: Enable execution of doctests

PATCH Applied Dirk Behme 4 participants 5 messages Oct 16, 2024 – Dec 17, 2024 Rust

lore
Share & tools
lore

Dirk Behme

author
#0 lore raw

PATCH v2 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.

Cc Alice Ryhl <[email protected]>
Cc Miguel Ojeda <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Trevor Gross <[email protected]>
Cc Tejun Heo <[email protected]>

---

Changes in v2:
- Drop 'let _ ='
- Drop empty line
- Add additional maintainers into Cc
- Drop newline in commit message
- Add Reviewed-by from v1

 rust/kernel/workqueue.rs | 3 +++
 1 file changed, 3 insertions(+)
rust/kernel/workqueue.rs +1 -0
index 10d2bc62e2cf..3755c8e5e9ea 100644
@@ -69,6 +69,7 @@
 //! fn print_later(val: Arc<MyStruct>) {
 //!     let _ = workqueue::system().enqueue(val);
 //! }
+//! # print_later(MyStruct::new(42).unwrap());
 //! ```
 //!
 //! The following example shows how multiple `work_struct` fields can

be used:
@@ -126,6 +127,8 @@
//! fn print_2_later(val: Arc<MyStruct>) {
//! let _ = workqueue::system().enqueue::<Arc<MyStruct>, 2>(val);
//! }
+//! # print_1_later(MyStruct::new(24, 25).unwrap()); +//! # 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
Reviewed-by on v2 1/1
#1 lore raw
Quoted 19 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

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

Quoted 7 lines
Cc Alice Ryhl <[email protected]>
Cc Miguel Ojeda <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Trevor Gross <[email protected]>
Cc Tejun Heo <[email protected]>

Regards,
Boqun

Quoted 37 lines

---

Changes in v2:
- Drop 'let _ ='
- Drop empty line
- Add additional maintainers into Cc
- Drop newline in commit message
- Add Reviewed-by from v1

 rust/kernel/workqueue.rs | 3 +++
 1 file changed, 3 insertions(+)
rust/kernel/workqueue.rs +1 -0
index 10d2bc62e2cf..3755c8e5e9ea 100644
@@ -69,6 +69,7 @@
 //! fn print_later(val: Arc<MyStruct>) {
 //!     let _ = workqueue::system().enqueue(val);
 //! }
+//! # print_later(MyStruct::new(42).unwrap());
 //! ```
 //!
 //! The following example shows how multiple `work_struct` fields can

be used:

rust/kernel/workqueue.rs +2 -0
@@ -126,6 +127,8 @@
 //! fn print_2_later(val: Arc<MyStruct>) {
 //!     let _ = workqueue::system().enqueue::<Arc<MyStruct>, 2>(val);
 //! }
+//! # print_1_later(MyStruct::new(24, 25).unwrap());
+//! # 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
Acked-by on v2 1/1
#2 lore raw
In reply to Dirk Behme
Quoted 12 lines · Dirk Behme

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

Nit: normally you would indent "code blocks".

Quoted 8 lines

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

Cc Alice Ryhl <[email protected]>
Cc Miguel Ojeda <[email protected]>
Cc Boqun Feng <[email protected]>
Cc Trevor Gross <[email protected]>
Cc Tejun Heo <[email protected]>

Normally you do not need to use the Cc tag for reviewers/maintainers that are supposed to take the patch.

Quoted 2 lines

This looks fine to me -- Tejun, are you picking it up? If so, please feel free to add:

Otherwise, if you prefer, I can put it through rust-next.

Thanks!

Cheers,
Miguel

Applied
#4 lore raw
In reply to Dirk Behme
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.

Applied to rust-next -- thanks everyone!

[ Reworded slightly. - Miguel ]

Cheers,
Miguel