Re: [PATCH 5/6] rust: support running Rust documentation tests as KUnit ones

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Jun 14, 2023 at 08:08:29PM +0200, Miguel Ojeda wrote:
> diff --git a/rust/helpers.c b/rust/helpers.c
> index bb594da56137..49a5e1a4f0ae 100644
> --- a/rust/helpers.c
> +++ b/rust/helpers.c
> @@ -18,6 +18,7 @@
>   * accidentally exposed.
>   */
>  
> +#include <kunit/test-bug.h>

When CONFIG_KUNIT=n, the above file is mostly just a function that
returns "NULL", however, since "NULL" is not defined: kunit/test-bug.h
includes nothing if CONFIG_KUNIT=n, bindgen is not happy about it:

  ./include/kunit/test-bug.h:63:67: error: use of undeclared identifier 'NULL'

, we can fix this in Rust side by adding linux/stddef.h before
kunit/test-bug.h as below, but maybe it's better fixed inside
kunit/test-bug.h?

Regards,
Boqun

-------------------------------->8
diff --git a/rust/helpers.c b/rust/helpers.c
index 49a5e1a4f0ae..048d11c7d796 100644
--- a/rust/helpers.c
+++ b/rust/helpers.c
@@ -18,6 +18,7 @@
  * accidentally exposed.
  */
 
+#include <linux/stddef.h>
 #include <kunit/test-bug.h>
 #include <linux/bug.h>
 #include <linux/build_bug.h>

>  #include <linux/bug.h>
>  #include <linux/build_bug.h>
>  #include <linux/err.h>
> @@ -135,6 +136,12 @@ void rust_helper_put_task_struct(struct task_struct *t)
>  }
>  EXPORT_SYMBOL_GPL(rust_helper_put_task_struct);
>  
> +struct kunit *rust_helper_kunit_get_current_test(void)
> +{
> +	return kunit_get_current_test();
> +}
> +EXPORT_SYMBOL_GPL(rust_helper_kunit_get_current_test);
> +
>  /*
>   * We use `bindgen`'s `--size_t-is-usize` option to bind the C `size_t` type
>   * as the Rust `usize` type, so we can use it in contexts where Rust



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux