diff mbox series

[v4,35/42] test: Rename all linker lists to have a ut_ prefix

Message ID 20210304065106.v4.35.Ide325abe75154eaf4508ab04c88eba23804fa291@changeid
State Superseded
Delegated to: Tom Rini
Headers show
Series test: Refactor tests to have a single test runner | expand

Commit Message

Simon Glass March 4, 2021, 1:51 p.m. UTC
At present each test suite has its own portion of the linker_list section
of the image, but other lists are interspersed. This makes it hard to
enumerate all the available tests without knowing the suites that each one
is in.

Place all tests together in a single contiguous list by giving them
common prefix not used elsewhere in U-Boot. This makes it possible to find
the start and end of all tests.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

(no changes since v3)

Changes in v3:
- Update the pytest collector as well

 include/test/test.h | 8 ++++----
 test/py/conftest.py | 2 +-
 2 files changed, 5 insertions(+), 5 deletions(-)

Comments

Heinrich Schuchardt March 4, 2021, 3:28 p.m. UTC | #1
On 3/4/21 2:51 PM, Simon Glass wrote:
> At present each test suite has its own portion of the linker_list section
> of the image, but other lists are interspersed. This makes it hard to
> enumerate all the available tests without knowing the suites that each one
> is in.
>
> Place all tests together in a single contiguous list by giving them
> common prefix not used elsewhere in U-Boot. This makes it possible to find
> the start and end of all tests.
>
> Signed-off-by: Simon Glass <sjg@chromium.org>
> ---
>
> (no changes since v3)
>
> Changes in v3:
> - Update the pytest collector as well
>
>   include/test/test.h | 8 ++++----
>   test/py/conftest.py | 2 +-
>   2 files changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/include/test/test.h b/include/test/test.h
> index b16c9135f2c..3330dcc72d3 100644
> --- a/include/test/test.h
> +++ b/include/test/test.h
> @@ -86,18 +86,18 @@ struct unit_test {
>    * @_suite:	name of the test suite concatenated with "_test"
>    */
>   #define UNIT_TEST(_name, _flags, _suite)				\
> -	ll_entry_declare(struct unit_test, _name, _suite) = {		\
> +	ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = {	\
>   		.file = __FILE__,					\
>   		.name = #_name,						\
>   		.flags = _flags,					\
>   		.func = _name,						\
>   	}
>
> -/* Get the start of a list of unit tests for a particular category */
> +/* Get the start of a list of unit tests for a particular suite */
>   #define UNIT_TEST_SUITE_START(_suite) \
> -	ll_entry_start(struct unit_test, _suite)
> +	ll_entry_start(struct unit_test, ut_ ## _suite)
>   #define UNIT_TEST_SUITE_COUNT(_suite) \
> -	ll_entry_count(struct unit_test, _suite)
> +	ll_entry_count(struct unit_test, ut_ ## _suite)
>
>   /* Sizes for devres tests */
>   enum {
> diff --git a/test/py/conftest.py b/test/py/conftest.py
> index 9bfd9263455..1b909cde9d3 100644
> --- a/test/py/conftest.py
> +++ b/test/py/conftest.py
> @@ -226,7 +226,7 @@ def pytest_configure(config):
>           import u_boot_console_exec_attach
>           console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
>
> -re_ut_test_list = re.compile(r'_u_boot_list_2_(.*)_test_2_\1_test_(.*)\s*$')
> +re_ut_test_list = re.compile(r'_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$')


We should try to minimize the size of the U-Boot binary. Why do we need
a list that contain both "_ut_" and "_test_"? A single "_ut_" should be
enough to generate a unique section name.

Best regards

Heinrich

>   def generate_ut_subtest(metafunc, fixture_name, sym_path):
>       """Provide parametrization for a ut_subtest fixture.
>
>
Simon Glass March 5, 2021, 4:09 a.m. UTC | #2
Hi Heinrich,

On Thu, 4 Mar 2021 at 10:28, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> On 3/4/21 2:51 PM, Simon Glass wrote:
> > At present each test suite has its own portion of the linker_list section
> > of the image, but other lists are interspersed. This makes it hard to
> > enumerate all the available tests without knowing the suites that each one
> > is in.
> >
> > Place all tests together in a single contiguous list by giving them
> > common prefix not used elsewhere in U-Boot. This makes it possible to find
> > the start and end of all tests.
> >
> > Signed-off-by: Simon Glass <sjg@chromium.org>
> > ---
> >
> > (no changes since v3)
> >
> > Changes in v3:
> > - Update the pytest collector as well
> >
> >   include/test/test.h | 8 ++++----
> >   test/py/conftest.py | 2 +-
> >   2 files changed, 5 insertions(+), 5 deletions(-)
> >
> > diff --git a/include/test/test.h b/include/test/test.h
> > index b16c9135f2c..3330dcc72d3 100644
> > --- a/include/test/test.h
> > +++ b/include/test/test.h
> > @@ -86,18 +86,18 @@ struct unit_test {
> >    * @_suite: name of the test suite concatenated with "_test"
> >    */
> >   #define UNIT_TEST(_name, _flags, _suite)                            \
> > -     ll_entry_declare(struct unit_test, _name, _suite) = {           \
> > +     ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = {    \
> >               .file = __FILE__,                                       \
> >               .name = #_name,                                         \
> >               .flags = _flags,                                        \
> >               .func = _name,                                          \
> >       }
> >
> > -/* Get the start of a list of unit tests for a particular category */
> > +/* Get the start of a list of unit tests for a particular suite */
> >   #define UNIT_TEST_SUITE_START(_suite) \
> > -     ll_entry_start(struct unit_test, _suite)
> > +     ll_entry_start(struct unit_test, ut_ ## _suite)
> >   #define UNIT_TEST_SUITE_COUNT(_suite) \
> > -     ll_entry_count(struct unit_test, _suite)
> > +     ll_entry_count(struct unit_test, ut_ ## _suite)
> >
> >   /* Sizes for devres tests */
> >   enum {
> > diff --git a/test/py/conftest.py b/test/py/conftest.py
> > index 9bfd9263455..1b909cde9d3 100644
> > --- a/test/py/conftest.py
> > +++ b/test/py/conftest.py
> > @@ -226,7 +226,7 @@ def pytest_configure(config):
> >           import u_boot_console_exec_attach
> >           console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
> >
> > -re_ut_test_list = re.compile(r'_u_boot_list_2_(.*)_test_2_\1_test_(.*)\s*$')
> > +re_ut_test_list = re.compile(r'_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$')
>
>
> We should try to minimize the size of the U-Boot binary. Why do we need
> a list that contain both "_ut_" and "_test_"? A single "_ut_" should be
> enough to generate a unique section name.

Possibly you are right. But that is not the subject of this patch.

I think after this series (and applying the patch to select tests with
wildcards) we might be able to do some renaming, since most things are
in macros.

Regards,
Simon
diff mbox series

Patch

diff --git a/include/test/test.h b/include/test/test.h
index b16c9135f2c..3330dcc72d3 100644
--- a/include/test/test.h
+++ b/include/test/test.h
@@ -86,18 +86,18 @@  struct unit_test {
  * @_suite:	name of the test suite concatenated with "_test"
  */
 #define UNIT_TEST(_name, _flags, _suite)				\
-	ll_entry_declare(struct unit_test, _name, _suite) = {		\
+	ll_entry_declare(struct unit_test, _name, ut_ ## _suite) = {	\
 		.file = __FILE__,					\
 		.name = #_name,						\
 		.flags = _flags,					\
 		.func = _name,						\
 	}
 
-/* Get the start of a list of unit tests for a particular category */
+/* Get the start of a list of unit tests for a particular suite */
 #define UNIT_TEST_SUITE_START(_suite) \
-	ll_entry_start(struct unit_test, _suite)
+	ll_entry_start(struct unit_test, ut_ ## _suite)
 #define UNIT_TEST_SUITE_COUNT(_suite) \
-	ll_entry_count(struct unit_test, _suite)
+	ll_entry_count(struct unit_test, ut_ ## _suite)
 
 /* Sizes for devres tests */
 enum {
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 9bfd9263455..1b909cde9d3 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -226,7 +226,7 @@  def pytest_configure(config):
         import u_boot_console_exec_attach
         console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig)
 
-re_ut_test_list = re.compile(r'_u_boot_list_2_(.*)_test_2_\1_test_(.*)\s*$')
+re_ut_test_list = re.compile(r'_u_boot_list_2_ut_(.*)_test_2_\1_test_(.*)\s*$')
 def generate_ut_subtest(metafunc, fixture_name, sym_path):
     """Provide parametrization for a ut_subtest fixture.