Re: [PATCH 5/7] rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'s

2025-05-04 Thread David Gow
On Mon, 5 May 2025 at 05:54, Miguel Ojeda wrote: > > On Sun, May 4, 2025 at 8:23 PM Tamir Duberstein wrote: > > > > I see. Up to you, obviously, but ISTM that this degree of freedom is > > unnecessary, but perhaps there's a benefit I'm underappreciating? > > Well, having this allows one to write

Re: [PATCH 4/7] rust: str: convert `rusttest` tests into KUnit

2025-05-04 Thread David Gow
On Mon, 5 May 2025 at 03:02, Miguel Ojeda wrote: > > On Sun, May 4, 2025 at 8:39 PM Tamir Duberstein wrote: > > > > One example is > > https://github.com/torvalds/linux/blob/59c9ab3e8cc7f56cd65608f6e938b5ae96eb9cd2/tools/testing/radix-tree/xarray.c. > > > > It might be that these are necessary b

Re: [PATCH 2/7] rust: kunit: support checked `-> Result`s in KUnit `#[test]`s

2025-05-04 Thread David Gow
On Mon, 5 May 2025 at 02:00, Miguel Ojeda wrote: > > On Sun, May 4, 2025 at 7:34 PM Tamir Duberstein wrote: > > > > Why not restrict this to Result<(), E>? > > I guess it is an option -- not sure if there may be a use case. > > > Is it possible to include the error in the output? > > I thought ab

Re: [PATCH] kbuild: use ARCH from compile.h in unclean source tree msg

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 01:25, Shuah Khan wrote: > > When make finds the source tree unclean, it prints a message to run > "make ARCH=x86_64 mrproper" message using the ARCH from the command > line. The ARCH specified in the command line could be different from > the ARCH of the existing build in th

Re: [PATCH 7/7] Documentation: rust: testing: add docs on the new KUnit `#[test]` tests

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:52, Miguel Ojeda wrote: > > There was no documentation yet on the KUnit-based `#[test]`s. > > Thus add it now. > > It includes an explanation about the `assert*!` macros being mapped to > KUnit and the support for `-> Result` introduced in these series. > > Signed-off-by:

Re: [PATCH 6/7] Documentation: rust: rename `#[test]`s to "`rusttest` host tests"

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:52, Miguel Ojeda wrote: > > Now that `rusttest`s are not really used much, clarify the section of > the documentation that describes them. > > In addition, free the section name for the KUnit-based `#[test]`s that > will be added afterwards. To do so, rename the section in

Re: [PATCH 5/7] rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'s

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:52, Miguel Ojeda wrote: > > Since now we have support for returning `-> Result`s, we can convert some > of these tests to use the feature, and serve as a first user for it too. > > Thus convert them. > > This, in turn, simplifies them a fair bit. > > We keep the actual ass

Re: [PATCH 4/7] rust: str: convert `rusttest` tests into KUnit

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:52, Miguel Ojeda wrote: > > In general, we should aim to test as much as possible within the actual > kernel, and not in the build host. > > Thus convert these `rusttest` tests into KUnit tests. > > Signed-off-by: Miguel Ojeda > --- I'm obviously a fan of this. Assuming

Re: [PATCH 3/7] rust: add `kunit_tests` to the prelude

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:52, Miguel Ojeda wrote: > > It is convenient to have certain things in the `kernel` prelude, and > means kernel developers will find it even easier to start writing tests. > > And, anyway, nobody should need to use this identifier for anything else. > > Thus add it to the

Re: [PATCH 2/7] rust: kunit: support checked `-> Result`s in KUnit `#[test]`s

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:51, Miguel Ojeda wrote: > > Currently, return values of KUnit `#[test]` functions are ignored. > > Thus introduce support for `-> Result` functions by checking their > returned values. > > At the same time, require that test functions return `()` or `Result E>`, which shou

Re: [PATCH 1/7] rust: kunit: support KUnit-mapped `assert!` macros in `#[test]`s

2025-05-04 Thread David Gow
On Sat, 3 May 2025 at 05:51, Miguel Ojeda wrote: > > The KUnit `#[test]` support that landed recently is very basic and does > not map the `assert*!` macros into KUnit like the doctests do, so they > panic at the moment. > > Thus implement the custom mapping in a similar way to doctests, reusing >

Re: [PATCH 5/7] rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'s

2025-05-04 Thread Miguel Ojeda
On Sun, May 4, 2025 at 8:23 PM Tamir Duberstein wrote: > > I see. Up to you, obviously, but ISTM that this degree of freedom is > unnecessary, but perhaps there's a benefit I'm underappreciating? Well, having this allows one to write code like the rest of the kernel code, instead of, say, `.unwra

Re: [PATCH bpf-next v1 1/2] ktls, sockmap: Fix missing uncharge operation

2025-05-04 Thread Cong Wang
On Fri, Apr 25, 2025 at 01:59:57PM +0800, Jiayuan Chen wrote: > When we specify apply_bytes, we divide the msg into multiple segments, > each with a length of 'send', and every time we send this part of the data > using tcp_bpf_sendmsg_redir(), we use sk_msg_return_zero() to uncharge the > memory o

Re: [PATCH 4/7] rust: str: convert `rusttest` tests into KUnit

2025-05-04 Thread Miguel Ojeda
On Sun, May 4, 2025 at 8:39 PM Tamir Duberstein wrote: > > One example is > https://github.com/torvalds/linux/blob/59c9ab3e8cc7f56cd65608f6e938b5ae96eb9cd2/tools/testing/radix-tree/xarray.c. > > It might be that these are necessary because the xarray tests don't > use kunit, and so are pretty inc

Re: [PATCH 4/7] rust: str: convert `rusttest` tests into KUnit

2025-05-04 Thread Tamir Duberstein
On Sun, May 4, 2025 at 2:31 PM Miguel Ojeda wrote: > > On Sun, May 4, 2025 at 7:31 PM Tamir Duberstein wrote: > > > > Is that true? The build host is often easier to work with. There's a > > number of host tests on the C side that exist precisely for this > > reason. > > Even for tests that could

Re: [PATCH 4/7] rust: str: convert `rusttest` tests into KUnit

2025-05-04 Thread Miguel Ojeda
On Sun, May 4, 2025 at 7:31 PM Tamir Duberstein wrote: > > Is that true? The build host is often easier to work with. There's a > number of host tests on the C side that exist precisely for this > reason. Even for tests that could run in the host (pure functions), if you test in the host, then yo

Re: [PATCH 5/7] rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'s

2025-05-04 Thread Tamir Duberstein
On Sun, May 4, 2025 at 2:15 PM Miguel Ojeda wrote: > > On Sun, May 4, 2025 at 7:30 PM Tamir Duberstein wrote: > > > > Alice pointed this out in another thread but: one of the downsides of > > returning Result is that in the event of failure the line number where > > the error occurred is no longe

Re: [PATCH 5/7] rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'s

2025-05-04 Thread Miguel Ojeda
On Sun, May 4, 2025 at 7:30 PM Tamir Duberstein wrote: > > Alice pointed this out in another thread but: one of the downsides of > returning Result is that in the event of failure the line number where > the error occurred is no longer contained in the test output. I'm 👎 > on this change for that

Re: [PATCH 2/7] rust: kunit: support checked `-> Result`s in KUnit `#[test]`s

2025-05-04 Thread Miguel Ojeda
On Sun, May 4, 2025 at 7:34 PM Tamir Duberstein wrote: > > Why not restrict this to Result<(), E>? I guess it is an option -- not sure if there may be a use case. > Is it possible to include the error in the output? I thought about giving some more context somehow and perhaps printing it "manua

Re: [PATCH 1/7] rust: kunit: support KUnit-mapped `assert!` macros in `#[test]`s

2025-05-04 Thread Tamir Duberstein
On Fri, May 2, 2025 at 5:53 PM Miguel Ojeda wrote: > > The KUnit `#[test]` support that landed recently is very basic and does > not map the `assert*!` macros into KUnit like the doctests do, so they > panic at the moment. > > Thus implement the custom mapping in a similar way to doctests, reusing

Re: [PATCH 2/7] rust: kunit: support checked `-> Result`s in KUnit `#[test]`s

2025-05-04 Thread Tamir Duberstein
On Fri, May 2, 2025 at 5:53 PM Miguel Ojeda wrote: > > Currently, return values of KUnit `#[test]` functions are ignored. > > Thus introduce support for `-> Result` functions by checking their > returned values. > > At the same time, require that test functions return `()` or `Result E>`, which sh

Re: [PATCH 4/7] rust: str: convert `rusttest` tests into KUnit

2025-05-04 Thread Tamir Duberstein
On Fri, May 2, 2025 at 5:53 PM Miguel Ojeda wrote: > > In general, we should aim to test as much as possible within the actual > kernel, and not in the build host. Is that true? The build host is often easier to work with. There's a number of host tests on the C side that exist precisely for this

Re: [PATCH 5/7] rust: str: take advantage of the `-> Result` support in KUnit `#[test]`'s

2025-05-04 Thread Tamir Duberstein
On Fri, May 2, 2025 at 5:54 PM Miguel Ojeda wrote: > > Since now we have support for returning `-> Result`s, we can convert some > of these tests to use the feature, and serve as a first user for it too. > > Thus convert them. > > This, in turn, simplifies them a fair bit. > > We keep the actual a

[PATCH v2 1/1] selftests/mm/uffd: Refactor non-composite global vars into struct

2025-05-04 Thread Ujwal Kundur
This patch refactors macros and non-composite global variable definitions into a struct that is defined at the start of a test and is passed around instead of relying on global vars. Signed-off-by: Ujwal Kundur --- Changes since v1: - indentation fixes - squash into single patch to assist bise