2020-06-26 21:10:17

by Brendan Higgins

[permalink] [raw]
Subject: [PATCH v5 01/12] vmlinux.lds.h: add linker section for KUnit test suites

Add a linker section where KUnit can put references to its test suites.
This patch is the first step in transitioning to dispatching all KUnit
tests from a centralized executor rather than having each as its own
separate late_initcall.

Co-developed-by: Iurii Zaikin <[email protected]>
Signed-off-by: Iurii Zaikin <[email protected]>
Signed-off-by: Brendan Higgins <[email protected]>
Reviewed-by: Stephen Boyd <[email protected]>
---
include/asm-generic/vmlinux.lds.h | 8 ++++++++
1 file changed, 8 insertions(+)

diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
index db600ef218d7d..4f9b036fc9616 100644
--- a/include/asm-generic/vmlinux.lds.h
+++ b/include/asm-generic/vmlinux.lds.h
@@ -881,6 +881,13 @@
KEEP(*(.con_initcall.init)) \
__con_initcall_end = .;

+/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
+#define KUNIT_TEST_SUITES \
+ . = ALIGN(8); \
+ __kunit_suites_start = .; \
+ KEEP(*(.kunit_test_suites)) \
+ __kunit_suites_end = .;
+
#ifdef CONFIG_BLK_DEV_INITRD
#define INIT_RAM_FS \
. = ALIGN(4); \
@@ -1056,6 +1063,7 @@
INIT_CALLS \
CON_INITCALL \
INIT_RAM_FS \
+ KUNIT_TEST_SUITES \
}

#define BSS_SECTION(sbss_align, bss_align, stop_align) \
--
2.27.0.212.ge8ba1cc988-goog


2020-06-26 21:21:12

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH v5 01/12] vmlinux.lds.h: add linker section for KUnit test suites

On Fri, Jun 26, 2020 at 02:09:06PM -0700, Brendan Higgins wrote:
> Add a linker section where KUnit can put references to its test suites.
> This patch is the first step in transitioning to dispatching all KUnit
> tests from a centralized executor rather than having each as its own
> separate late_initcall.
>
> Co-developed-by: Iurii Zaikin <[email protected]>
> Signed-off-by: Iurii Zaikin <[email protected]>
> Signed-off-by: Brendan Higgins <[email protected]>
> Reviewed-by: Stephen Boyd <[email protected]>
> ---
> include/asm-generic/vmlinux.lds.h | 8 ++++++++
> 1 file changed, 8 insertions(+)
>
> diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> index db600ef218d7d..4f9b036fc9616 100644
> --- a/include/asm-generic/vmlinux.lds.h
> +++ b/include/asm-generic/vmlinux.lds.h
> @@ -881,6 +881,13 @@
> KEEP(*(.con_initcall.init)) \
> __con_initcall_end = .;
>
> +/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */

Nit on naming:

> +#define KUNIT_TEST_SUITES \

I would call this KUNIT_TABLE to maintain the same names as other things
of this nature.

> + . = ALIGN(8); \
> + __kunit_suites_start = .; \
> + KEEP(*(.kunit_test_suites)) \
> + __kunit_suites_end = .;
> +
> #ifdef CONFIG_BLK_DEV_INITRD
> #define INIT_RAM_FS \
> . = ALIGN(4); \
> @@ -1056,6 +1063,7 @@
> INIT_CALLS \
> CON_INITCALL \
> INIT_RAM_FS \
> + KUNIT_TEST_SUITES \
> }

Nack: this must be in INIT_DATA, not in INIT_DATA_SECTION. Not all
architectures use the INIT_DATA_SECTION macro (e.g. arm64), but everything
uses INIT_DATA.


--
Kees Cook

2020-06-26 21:23:33

by Brendan Higgins

[permalink] [raw]
Subject: Re: [PATCH v5 01/12] vmlinux.lds.h: add linker section for KUnit test suites

On Fri, Jun 26, 2020 at 2:20 PM Kees Cook <[email protected]> wrote:
>
> On Fri, Jun 26, 2020 at 02:09:06PM -0700, Brendan Higgins wrote:
> > Add a linker section where KUnit can put references to its test suites.
> > This patch is the first step in transitioning to dispatching all KUnit
> > tests from a centralized executor rather than having each as its own
> > separate late_initcall.
> >
> > Co-developed-by: Iurii Zaikin <[email protected]>
> > Signed-off-by: Iurii Zaikin <[email protected]>
> > Signed-off-by: Brendan Higgins <[email protected]>
> > Reviewed-by: Stephen Boyd <[email protected]>
> > ---
> > include/asm-generic/vmlinux.lds.h | 8 ++++++++
> > 1 file changed, 8 insertions(+)
> >
> > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> > index db600ef218d7d..4f9b036fc9616 100644
> > --- a/include/asm-generic/vmlinux.lds.h
> > +++ b/include/asm-generic/vmlinux.lds.h
> > @@ -881,6 +881,13 @@
> > KEEP(*(.con_initcall.init)) \
> > __con_initcall_end = .;
> >
> > +/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
>
> Nit on naming:
>
> > +#define KUNIT_TEST_SUITES \
>
> I would call this KUNIT_TABLE to maintain the same names as other things
> of this nature.
>
> > + . = ALIGN(8); \
> > + __kunit_suites_start = .; \
> > + KEEP(*(.kunit_test_suites)) \
> > + __kunit_suites_end = .;
> > +
> > #ifdef CONFIG_BLK_DEV_INITRD
> > #define INIT_RAM_FS \
> > . = ALIGN(4); \
> > @@ -1056,6 +1063,7 @@
> > INIT_CALLS \
> > CON_INITCALL \
> > INIT_RAM_FS \
> > + KUNIT_TEST_SUITES \
> > }
>
> Nack: this must be in INIT_DATA, not in INIT_DATA_SECTION. Not all
> architectures use the INIT_DATA_SECTION macro (e.g. arm64), but everything
> uses INIT_DATA.

Oh, maybe that would eliminate the need for the other linkerscript
patches? That would be nice.

Alright, will fix.

2020-07-08 04:43:24

by Luis Chamberlain

[permalink] [raw]
Subject: Re: [PATCH v5 01/12] vmlinux.lds.h: add linker section for KUnit test suites

On Fri, Jun 26, 2020 at 02:22:11PM -0700, Brendan Higgins wrote:
> On Fri, Jun 26, 2020 at 2:20 PM Kees Cook <[email protected]> wrote:
> >
> > On Fri, Jun 26, 2020 at 02:09:06PM -0700, Brendan Higgins wrote:
> > > Add a linker section where KUnit can put references to its test suites.
> > > This patch is the first step in transitioning to dispatching all KUnit
> > > tests from a centralized executor rather than having each as its own
> > > separate late_initcall.
> > >
> > > Co-developed-by: Iurii Zaikin <[email protected]>
> > > Signed-off-by: Iurii Zaikin <[email protected]>
> > > Signed-off-by: Brendan Higgins <[email protected]>
> > > Reviewed-by: Stephen Boyd <[email protected]>
> > > ---
> > > include/asm-generic/vmlinux.lds.h | 8 ++++++++
> > > 1 file changed, 8 insertions(+)
> > >
> > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> > > index db600ef218d7d..4f9b036fc9616 100644
> > > --- a/include/asm-generic/vmlinux.lds.h
> > > +++ b/include/asm-generic/vmlinux.lds.h
> > > @@ -881,6 +881,13 @@
> > > KEEP(*(.con_initcall.init)) \
> > > __con_initcall_end = .;
> > >
> > > +/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
> >
> > Nit on naming:
> >
> > > +#define KUNIT_TEST_SUITES \
> >
> > I would call this KUNIT_TABLE to maintain the same names as other things
> > of this nature.
> >
> > > + . = ALIGN(8); \
> > > + __kunit_suites_start = .; \
> > > + KEEP(*(.kunit_test_suites)) \
> > > + __kunit_suites_end = .;
> > > +
> > > #ifdef CONFIG_BLK_DEV_INITRD
> > > #define INIT_RAM_FS \
> > > . = ALIGN(4); \
> > > @@ -1056,6 +1063,7 @@
> > > INIT_CALLS \
> > > CON_INITCALL \
> > > INIT_RAM_FS \
> > > + KUNIT_TEST_SUITES \
> > > }
> >
> > Nack: this must be in INIT_DATA, not in INIT_DATA_SECTION. Not all
> > architectures use the INIT_DATA_SECTION macro (e.g. arm64), but everything
> > uses INIT_DATA.
>
> Oh, maybe that would eliminate the need for the other linkerscript
> patches? That would be nice.

Curious, did changing it as Kees suggest fix it for m68k?

Luis

2020-08-04 20:06:33

by Brendan Higgins

[permalink] [raw]
Subject: Re: [PATCH v5 01/12] vmlinux.lds.h: add linker section for KUnit test suites

On Tue, Jul 7, 2020 at 9:31 PM Luis Chamberlain <[email protected]> wrote:
>
> On Fri, Jun 26, 2020 at 02:22:11PM -0700, Brendan Higgins wrote:
> > On Fri, Jun 26, 2020 at 2:20 PM Kees Cook <[email protected]> wrote:
> > >
> > > On Fri, Jun 26, 2020 at 02:09:06PM -0700, Brendan Higgins wrote:
> > > > Add a linker section where KUnit can put references to its test suites.
> > > > This patch is the first step in transitioning to dispatching all KUnit
> > > > tests from a centralized executor rather than having each as its own
> > > > separate late_initcall.
> > > >
> > > > Co-developed-by: Iurii Zaikin <[email protected]>
> > > > Signed-off-by: Iurii Zaikin <[email protected]>
> > > > Signed-off-by: Brendan Higgins <[email protected]>
> > > > Reviewed-by: Stephen Boyd <[email protected]>
> > > > ---
> > > > include/asm-generic/vmlinux.lds.h | 8 ++++++++
> > > > 1 file changed, 8 insertions(+)
> > > >
> > > > diff --git a/include/asm-generic/vmlinux.lds.h b/include/asm-generic/vmlinux.lds.h
> > > > index db600ef218d7d..4f9b036fc9616 100644
> > > > --- a/include/asm-generic/vmlinux.lds.h
> > > > +++ b/include/asm-generic/vmlinux.lds.h
> > > > @@ -881,6 +881,13 @@
> > > > KEEP(*(.con_initcall.init)) \
> > > > __con_initcall_end = .;
> > > >
> > > > +/* Alignment must be consistent with (kunit_suite *) in include/kunit/test.h */
> > >
> > > Nit on naming:
> > >
> > > > +#define KUNIT_TEST_SUITES \
> > >
> > > I would call this KUNIT_TABLE to maintain the same names as other things
> > > of this nature.
> > >
> > > > + . = ALIGN(8); \
> > > > + __kunit_suites_start = .; \
> > > > + KEEP(*(.kunit_test_suites)) \
> > > > + __kunit_suites_end = .;
> > > > +
> > > > #ifdef CONFIG_BLK_DEV_INITRD
> > > > #define INIT_RAM_FS \
> > > > . = ALIGN(4); \
> > > > @@ -1056,6 +1063,7 @@
> > > > INIT_CALLS \
> > > > CON_INITCALL \
> > > > INIT_RAM_FS \
> > > > + KUNIT_TEST_SUITES \
> > > > }
> > >
> > > Nack: this must be in INIT_DATA, not in INIT_DATA_SECTION. Not all
> > > architectures use the INIT_DATA_SECTION macro (e.g. arm64), but everything
> > > uses INIT_DATA.
> >
> > Oh, maybe that would eliminate the need for the other linkerscript
> > patches? That would be nice.

Sorry for the delayed response. I got pulled into some other things.

> Curious, did changing it as Kees suggest fix it for m68k?

It did! There are still some architectures I cannot test due to a lack
of GCC or QEMU support, but it seems to work on everything else now.