All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/3] a few test.py improvements
@ 2025-12-17 18:42 David Lechner
  2025-12-17 18:42 ` [PATCH v2 1/3] test.py: check ubconfig exists before using it David Lechner
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: David Lechner @ 2025-12-17 18:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marek Vasut, Simon Glass, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot, David Lechner

While trying to run the test suite for the first time, I encountered a
few minor issues. Here are a few patches to address them.

---
Changes in v2:
- Dropped patch adding setuptools to test/py/requirements.txt
- New patch to add setuptools to scripts/dtc/pylibfdt/requirements.txt
  instead.
- Changed test.py patch to set ubconfig to None rather than checking for
  its existence in globals().
- Link to v1: https://lore.kernel.org/r/20251121-a-few-test-py-improvements-v1-0-bacb4148fb0d@baylibre.com

---
David Lechner (3):
      test.py: check ubconfig exists before using it
      doc: pytest: mention additional requirements for venv
      pylibfdt: add requirements.txt for setuptools

 doc/develop/pytest/usage.rst          | 4 ++++
 scripts/dtc/pylibfdt/requirements.txt | 1 +
 test/py/conftest.py                   | 5 +++--
 3 files changed, 8 insertions(+), 2 deletions(-)
---
base-commit: a333d9e59f6675c9541c34643f334dbf50898647
change-id: 20251121-a-few-test-py-improvements-b91babfc3e05

Best regards,
-- 
David Lechner <dlechner@baylibre.com>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v2 1/3] test.py: check ubconfig exists before using it
  2025-12-17 18:42 [PATCH v2 0/3] a few test.py improvements David Lechner
@ 2025-12-17 18:42 ` David Lechner
  2025-12-27 14:52   ` Simon Glass
  2025-12-17 18:42 ` [PATCH v2 2/3] doc: pytest: mention additional requirements for venv David Lechner
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 8+ messages in thread
From: David Lechner @ 2025-12-17 18:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marek Vasut, Simon Glass, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot, David Lechner

Set ubconfig to None and add a check in the show_timings() function of
test/py/test.py to ensure that the global ubconfig variable was actually
initialized before access attributes.

If tests fail early, e.g. because --build failed, ubconfig may not have
been initialized yet and results in an exception in an atexit handler.
Adding this check avoids unnecessary noise in the output.

    Exception ignored in atexit callback: <function cleanup at 0x7de475ea6b60>
    Traceback (most recent call last):
    File "u-boot/test/py/conftest.py", line 669, in cleanup
        show_timings()
    File "u-boot/test/py/conftest.py", line 616, in show_timings
        if ubconfig.timing:
        ^^^^^^^^
    NameError: name 'ubconfig' is not defined

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
v2 changes:
- Set to None and check for not None instead of using 'in globals()'
---
 test/py/conftest.py | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/test/py/conftest.py b/test/py/conftest.py
index 8ce680a92a0..5689fcd0349 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -28,9 +28,10 @@ import sys
 from spawn import BootFail, Timeout, Unexpected, handle_exception
 import time
 
-# Globals: The HTML log file, and the top-level fixture
+# Globals: The HTML log file, the top-level fixture and the config container
 log = None
 ubman_fix = None
+ubconfig = None
 
 TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__))
 
@@ -613,7 +614,7 @@ def show_timings():
         if too_long:
             show_bar(f'>{get_time_delta(max_dur)}', too_long_msecs, too_long)
         log.info(buf.getvalue())
-    if ubconfig.timing:
+    if ubconfig is not None and ubconfig.timing:
         print(buf.getvalue(), end='')
 
 

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 2/3] doc: pytest: mention additional requirements for venv
  2025-12-17 18:42 [PATCH v2 0/3] a few test.py improvements David Lechner
  2025-12-17 18:42 ` [PATCH v2 1/3] test.py: check ubconfig exists before using it David Lechner
@ 2025-12-17 18:42 ` David Lechner
  2025-12-27 14:52   ` Simon Glass
  2025-12-17 18:42 ` [PATCH v2 3/3] pylibfdt: add requirements.txt for setuptools David Lechner
  2025-12-18 10:59 ` [PATCH v2 0/3] a few test.py improvements Mattijs Korpershoek
  3 siblings, 1 reply; 8+ messages in thread
From: David Lechner @ 2025-12-17 18:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marek Vasut, Simon Glass, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot, David Lechner

Add a paragraph explaining that in addition to the requirements.txt
for test/py/test.py itself, users may need to install additional python
packages depending on the U-Boot configuration being built.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
v2 changes: none
---
 doc/develop/pytest/usage.rst | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/doc/develop/pytest/usage.rst b/doc/develop/pytest/usage.rst
index df3821da20d..f8b32c07edd 100644
--- a/doc/develop/pytest/usage.rst
+++ b/doc/develop/pytest/usage.rst
@@ -90,6 +90,10 @@ environment.  This can be done via the following commands:
     $ . ./venv/bin/activate
     $ pip install -r test/py/requirements.txt
 
+In order to use the ``--build`` option of ``test.py`` there may be additional
+python packages required depending on the configuration being built. These can
+be found with ``find . -name "*.requirements*.txt"``.
+
 Testing sandbox
 ---------------
 

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v2 3/3] pylibfdt: add requirements.txt for setuptools
  2025-12-17 18:42 [PATCH v2 0/3] a few test.py improvements David Lechner
  2025-12-17 18:42 ` [PATCH v2 1/3] test.py: check ubconfig exists before using it David Lechner
  2025-12-17 18:42 ` [PATCH v2 2/3] doc: pytest: mention additional requirements for venv David Lechner
@ 2025-12-17 18:42 ` David Lechner
  2025-12-27 14:52   ` Simon Glass
  2025-12-18 10:59 ` [PATCH v2 0/3] a few test.py improvements Mattijs Korpershoek
  3 siblings, 1 reply; 8+ messages in thread
From: David Lechner @ 2025-12-17 18:42 UTC (permalink / raw)
  To: Tom Rini
  Cc: Marek Vasut, Simon Glass, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot, David Lechner

Add a requirements.txt file to the pylibfdt script directory to specify
setuptools as a dependency. This follows the pattern of each tool in
U-Boot having its own requirements.txt file. The version is set to
78.1.1 to avoid conflict with the same in tools/patman/requirements.txt.

Signed-off-by: David Lechner <dlechner@baylibre.com>
---
v2 changes:
- new patch
---
 scripts/dtc/pylibfdt/requirements.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/scripts/dtc/pylibfdt/requirements.txt b/scripts/dtc/pylibfdt/requirements.txt
new file mode 100644
index 00000000000..b7dbecdd587
--- /dev/null
+++ b/scripts/dtc/pylibfdt/requirements.txt
@@ -0,0 +1 @@
+setuptools==78.1.1

-- 
2.43.0


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 0/3] a few test.py improvements
  2025-12-17 18:42 [PATCH v2 0/3] a few test.py improvements David Lechner
                   ` (2 preceding siblings ...)
  2025-12-17 18:42 ` [PATCH v2 3/3] pylibfdt: add requirements.txt for setuptools David Lechner
@ 2025-12-18 10:59 ` Mattijs Korpershoek
  3 siblings, 0 replies; 8+ messages in thread
From: Mattijs Korpershoek @ 2025-12-18 10:59 UTC (permalink / raw)
  To: David Lechner, Tom Rini
  Cc: Marek Vasut, Simon Glass, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot, David Lechner

Hi David,

Thank you for the series

On Wed, Dec 17, 2025 at 12:42, David Lechner <dlechner@baylibre.com> wrote:

> While trying to run the test suite for the first time, I encountered a
> few minor issues. Here are a few patches to address them.
>
> ---
> Changes in v2:
> - Dropped patch adding setuptools to test/py/requirements.txt
> - New patch to add setuptools to scripts/dtc/pylibfdt/requirements.txt
>   instead.
> - Changed test.py patch to set ubconfig to None rather than checking for
>   its existence in globals().
> - Link to v1: https://lore.kernel.org/r/20251121-a-few-test-py-improvements-v1-0-bacb4148fb0d@baylibre.com

Tested on a fresh fedora container with:

$ python -m venv venv
$ source venv/bin/activate
$ pip install -r test/py/requirements.txt
$ pip install -r scripts/dtc/pylibfdt/requirements.txt

Then I could build and test with:

$ ./test/py/test.py --bd sandbox --build -k ut

Tested-by: Mattijs Korpershoek <mkorpershoek@kernel.org> # sandbox

Also, all patches look good to me, so:

Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>

>
> ---
> David Lechner (3):
>       test.py: check ubconfig exists before using it
>       doc: pytest: mention additional requirements for venv
>       pylibfdt: add requirements.txt for setuptools
>
>  doc/develop/pytest/usage.rst          | 4 ++++
>  scripts/dtc/pylibfdt/requirements.txt | 1 +
>  test/py/conftest.py                   | 5 +++--
>  3 files changed, 8 insertions(+), 2 deletions(-)
> ---
> base-commit: a333d9e59f6675c9541c34643f334dbf50898647
> change-id: 20251121-a-few-test-py-improvements-b91babfc3e05
>
> Best regards,
> -- 
> David Lechner <dlechner@baylibre.com>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 1/3] test.py: check ubconfig exists before using it
  2025-12-17 18:42 ` [PATCH v2 1/3] test.py: check ubconfig exists before using it David Lechner
@ 2025-12-27 14:52   ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2025-12-27 14:52 UTC (permalink / raw)
  To: David Lechner
  Cc: Tom Rini, Marek Vasut, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot

Hi David,

On Wed, 17 Dec 2025 at 11:43, David Lechner <dlechner@baylibre.com> wrote:
>
> Set ubconfig to None and add a check in the show_timings() function of
> test/py/test.py to ensure that the global ubconfig variable was actually
> initialized before access attributes.
>
> If tests fail early, e.g. because --build failed, ubconfig may not have
> been initialized yet and results in an exception in an atexit handler.
> Adding this check avoids unnecessary noise in the output.
>
>     Exception ignored in atexit callback: <function cleanup at 0x7de475ea6b60>
>     Traceback (most recent call last):
>     File "u-boot/test/py/conftest.py", line 669, in cleanup
>         show_timings()
>     File "u-boot/test/py/conftest.py", line 616, in show_timings
>         if ubconfig.timing:
>         ^^^^^^^^
>     NameError: name 'ubconfig' is not defined
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> v2 changes:
> - Set to None and check for not None instead of using 'in globals()'
> ---
>  test/py/conftest.py | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/test/py/conftest.py b/test/py/conftest.py
> index 8ce680a92a0..5689fcd0349 100644
> --- a/test/py/conftest.py
> +++ b/test/py/conftest.py
> @@ -28,9 +28,10 @@ import sys
>  from spawn import BootFail, Timeout, Unexpected, handle_exception
>  import time
>
> -# Globals: The HTML log file, and the top-level fixture
> +# Globals: The HTML log file, the top-level fixture and the config container
>  log = None
>  ubman_fix = None
> +ubconfig = None
>
>  TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__))
>
> @@ -613,7 +614,7 @@ def show_timings():
>          if too_long:
>              show_bar(f'>{get_time_delta(max_dur)}', too_long_msecs, too_long)
>          log.info(buf.getvalue())
> -    if ubconfig.timing:
> +    if ubconfig is not None and ubconfig.timing:

if ubconfig and ubconfig.timing

>          print(buf.getvalue(), end='')
>
>
>
> --
> 2.43.0
>

Regards,
SImon

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 2/3] doc: pytest: mention additional requirements for venv
  2025-12-17 18:42 ` [PATCH v2 2/3] doc: pytest: mention additional requirements for venv David Lechner
@ 2025-12-27 14:52   ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2025-12-27 14:52 UTC (permalink / raw)
  To: David Lechner
  Cc: Tom Rini, Marek Vasut, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot

On Wed, 17 Dec 2025 at 11:43, David Lechner <dlechner@baylibre.com> wrote:
>
> Add a paragraph explaining that in addition to the requirements.txt
> for test/py/test.py itself, users may need to install additional python
> packages depending on the U-Boot configuration being built.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> v2 changes: none
> ---
>  doc/develop/pytest/usage.rst | 4 ++++
>  1 file changed, 4 insertions(+)

Reviewed-by: Simon Glass <simon.glass@canonical.com>



>
> diff --git a/doc/develop/pytest/usage.rst b/doc/develop/pytest/usage.rst
> index df3821da20d..f8b32c07edd 100644
> --- a/doc/develop/pytest/usage.rst
> +++ b/doc/develop/pytest/usage.rst
> @@ -90,6 +90,10 @@ environment.  This can be done via the following commands:
>      $ . ./venv/bin/activate
>      $ pip install -r test/py/requirements.txt
>
> +In order to use the ``--build`` option of ``test.py`` there may be additional
> +python packages required depending on the configuration being built. These can
> +be found with ``find . -name "*.requirements*.txt"``.
> +
>  Testing sandbox
>  ---------------
>
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v2 3/3] pylibfdt: add requirements.txt for setuptools
  2025-12-17 18:42 ` [PATCH v2 3/3] pylibfdt: add requirements.txt for setuptools David Lechner
@ 2025-12-27 14:52   ` Simon Glass
  0 siblings, 0 replies; 8+ messages in thread
From: Simon Glass @ 2025-12-27 14:52 UTC (permalink / raw)
  To: David Lechner
  Cc: Tom Rini, Marek Vasut, Mattijs Korpershoek, Jerome Forissier,
	Heinrich Schuchardt, Julien Stephan, u-boot

On Wed, 17 Dec 2025 at 11:43, David Lechner <dlechner@baylibre.com> wrote:
>
> Add a requirements.txt file to the pylibfdt script directory to specify
> setuptools as a dependency. This follows the pattern of each tool in
> U-Boot having its own requirements.txt file. The version is set to
> 78.1.1 to avoid conflict with the same in tools/patman/requirements.txt.
>
> Signed-off-by: David Lechner <dlechner@baylibre.com>
> ---
> v2 changes:
> - new patch
> ---
>  scripts/dtc/pylibfdt/requirements.txt | 1 +
>  1 file changed, 1 insertion(+)

Reviewed-by: Simon Glass <simon.glass@canonical.com>



>
> diff --git a/scripts/dtc/pylibfdt/requirements.txt b/scripts/dtc/pylibfdt/requirements.txt
> new file mode 100644
> index 00000000000..b7dbecdd587
> --- /dev/null
> +++ b/scripts/dtc/pylibfdt/requirements.txt
> @@ -0,0 +1 @@
> +setuptools==78.1.1
>
> --
> 2.43.0
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2025-12-27 14:53 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-17 18:42 [PATCH v2 0/3] a few test.py improvements David Lechner
2025-12-17 18:42 ` [PATCH v2 1/3] test.py: check ubconfig exists before using it David Lechner
2025-12-27 14:52   ` Simon Glass
2025-12-17 18:42 ` [PATCH v2 2/3] doc: pytest: mention additional requirements for venv David Lechner
2025-12-27 14:52   ` Simon Glass
2025-12-17 18:42 ` [PATCH v2 3/3] pylibfdt: add requirements.txt for setuptools David Lechner
2025-12-27 14:52   ` Simon Glass
2025-12-18 10:59 ` [PATCH v2 0/3] a few test.py improvements Mattijs Korpershoek

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.