[PATCH v2 04/11] rust: helpers: Remove kunit helper

Alistair Francis posted 11 patches 2 weeks, 1 day ago
There is a newer version of this series
[PATCH v2 04/11] rust: helpers: Remove kunit helper
Posted by Alistair Francis 2 weeks, 1 day ago
Now that we support wrap-static-fns we no longer need the custom helper.

Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
---
 rust/bindgen_static_functions | 2 ++
 rust/helpers/helpers.c        | 1 -
 rust/helpers/kunit.c          | 8 --------
 3 files changed, 2 insertions(+), 9 deletions(-)
 delete mode 100644 rust/helpers/kunit.c

diff --git a/rust/bindgen_static_functions b/rust/bindgen_static_functions
index 0269efa83c61..b4032d277e72 100644
--- a/rust/bindgen_static_functions
+++ b/rust/bindgen_static_functions
@@ -9,3 +9,5 @@
 --allowlist-function ERR_PTR
 --allowlist-function IS_ERR
 --allowlist-function PTR_ERR
+
+--allowlist-function kunit_get_current_test
diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
index e089ecdf091f..60b3fdc5c2de 100644
--- a/rust/helpers/helpers.c
+++ b/rust/helpers/helpers.c
@@ -10,7 +10,6 @@
 #include "bug.c"
 #include "build_assert.c"
 #include "build_bug.c"
-#include "kunit.c"
 #include "mutex.c"
 #include "page.c"
 #include "rbtree.c"
diff --git a/rust/helpers/kunit.c b/rust/helpers/kunit.c
deleted file mode 100644
index b85a4d394c11..000000000000
--- a/rust/helpers/kunit.c
+++ /dev/null
@@ -1,8 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-
-#include <kunit/test-bug.h>
-
-struct kunit *rust_helper_kunit_get_current_test(void)
-{
-	return kunit_get_current_test();
-}
-- 
2.47.0
Re: [PATCH v2 04/11] rust: helpers: Remove kunit helper
Posted by Dirk Behme 2 weeks, 1 day ago
Hi Alistair,

On 08.11.2024 04:10, Alistair Francis wrote:
> Now that we support wrap-static-fns we no longer need the custom helper.
> 
> Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> ---
>   rust/bindgen_static_functions | 2 ++
>   rust/helpers/helpers.c        | 1 -
>   rust/helpers/kunit.c          | 8 --------
>   3 files changed, 2 insertions(+), 9 deletions(-)
>   delete mode 100644 rust/helpers/kunit.c
> 
> diff --git a/rust/bindgen_static_functions b/rust/bindgen_static_functions
> index 0269efa83c61..b4032d277e72 100644
> --- a/rust/bindgen_static_functions
> +++ b/rust/bindgen_static_functions
> @@ -9,3 +9,5 @@
>   --allowlist-function ERR_PTR
>   --allowlist-function IS_ERR
>   --allowlist-function PTR_ERR
> +
> +--allowlist-function kunit_get_current_test
> diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
> index e089ecdf091f..60b3fdc5c2de 100644
> --- a/rust/helpers/helpers.c
> +++ b/rust/helpers/helpers.c
> @@ -10,7 +10,6 @@
>   #include "bug.c"
>   #include "build_assert.c"
>   #include "build_bug.c"
> -#include "kunit.c"
>   #include "mutex.c"
>   #include "page.c"
>   #include "rbtree.c"
> diff --git a/rust/helpers/kunit.c b/rust/helpers/kunit.c
> deleted file mode 100644
> index b85a4d394c11..000000000000
> --- a/rust/helpers/kunit.c
> +++ /dev/null
> @@ -1,8 +0,0 @@
> -// SPDX-License-Identifier: GPL-2.0
> -
> -#include <kunit/test-bug.h>
> -
> -struct kunit *rust_helper_kunit_get_current_test(void)
> -{
> -	return kunit_get_current_test();
> -}

Could you check this? I don't get kunit_get_current_test() in the 
resulting bindings/bindings_generated_static.rs and 
exports_bindings_static_generated.h. So with CONFIG_KUNIT and 
CONFIG_RUST_KERNEL_DOCTESTS being enabled (not sure if both are required 
;) ) I get dozens of errors due to that missing:

error[E0425]: cannot find function `kunit_get_current_test` in crate 
`$crate::bindings`

Reverting only this 4/11 and keeping all other patches of this series 
makes my kernel build fine, though :)


Btw, do we want/need an update of the documentation?

https://docs.kernel.org/rust/general-information.html#bindings

Thanks

Dirk

P.S.: Many thanks for rebasing against rust-next!
Re: [PATCH v2 04/11] rust: helpers: Remove kunit helper
Posted by Alistair Francis 1 week, 5 days ago
On Fri, Nov 8, 2024 at 4:01 PM Dirk Behme <dirk.behme@de.bosch.com> wrote:
>
> Hi Alistair,
>
> On 08.11.2024 04:10, Alistair Francis wrote:
> > Now that we support wrap-static-fns we no longer need the custom helper.
> >
> > Signed-off-by: Alistair Francis <alistair.francis@wdc.com>
> > ---
> >   rust/bindgen_static_functions | 2 ++
> >   rust/helpers/helpers.c        | 1 -
> >   rust/helpers/kunit.c          | 8 --------
> >   3 files changed, 2 insertions(+), 9 deletions(-)
> >   delete mode 100644 rust/helpers/kunit.c
> >
> > diff --git a/rust/bindgen_static_functions b/rust/bindgen_static_functions
> > index 0269efa83c61..b4032d277e72 100644
> > --- a/rust/bindgen_static_functions
> > +++ b/rust/bindgen_static_functions
> > @@ -9,3 +9,5 @@
> >   --allowlist-function ERR_PTR
> >   --allowlist-function IS_ERR
> >   --allowlist-function PTR_ERR
> > +
> > +--allowlist-function kunit_get_current_test
> > diff --git a/rust/helpers/helpers.c b/rust/helpers/helpers.c
> > index e089ecdf091f..60b3fdc5c2de 100644
> > --- a/rust/helpers/helpers.c
> > +++ b/rust/helpers/helpers.c
> > @@ -10,7 +10,6 @@
> >   #include "bug.c"
> >   #include "build_assert.c"
> >   #include "build_bug.c"
> > -#include "kunit.c"
> >   #include "mutex.c"
> >   #include "page.c"
> >   #include "rbtree.c"
> > diff --git a/rust/helpers/kunit.c b/rust/helpers/kunit.c
> > deleted file mode 100644
> > index b85a4d394c11..000000000000
> > --- a/rust/helpers/kunit.c
> > +++ /dev/null
> > @@ -1,8 +0,0 @@
> > -// SPDX-License-Identifier: GPL-2.0
> > -
> > -#include <kunit/test-bug.h>
> > -
> > -struct kunit *rust_helper_kunit_get_current_test(void)
> > -{
> > -     return kunit_get_current_test();
> > -}
>
> Could you check this? I don't get kunit_get_current_test() in the
> resulting bindings/bindings_generated_static.rs and
> exports_bindings_static_generated.h. So with CONFIG_KUNIT and
> CONFIG_RUST_KERNEL_DOCTESTS being enabled (not sure if both are required
> ;) ) I get dozens of errors due to that missing:
>
> error[E0425]: cannot find function `kunit_get_current_test` in crate
> `$crate::bindings`
>
> Reverting only this 4/11 and keeping all other patches of this series
> makes my kernel build fine, though :)

Thanks for testing! I was missing a "#include <kunit/test-bug.h>"

>
>
> Btw, do we want/need an update of the documentation?
>
> https://docs.kernel.org/rust/general-information.html#bindings

Good point, fixed in v3.

Alistair

>
> Thanks
>
> Dirk
>
> P.S.: Many thanks for rebasing against rust-next!
>