Skip to contentSkip to conversation

test: A few quality-of-life improvements

PATCH Superseded Simon Glass 3 participants 28 messages Jan 25, 2025 – Feb 15, 2025 Arm/Zynq architecture

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover test: A few quality-of-life improvements

This little series includes a few patches to make it easier to work with the Python tests, by shortening identifiers and renaming the 'console' fixture to reflect its role as the top-level fixture.

It also adds a command to fix testing on samus_tpl

This series is based on the previous 'test' series[1]

[1] https://patchwork.ozlabs.org/project/uboot/list/?series=441124

Simon Glass (4):
test/py: Shorten u_boot_console
test: Drop u_boot_ prefix on test files
test/py: Show info about module-loading
test: Make net tests depend on CONFIG_CMD_NET

 doc/develop/py_testing.rst                    |  16 +-
 doc/develop/tests_writing.rst                 |  12 +-
 test/py/conftest.py                           |  89 +++---
 ...u_boot_console_base.py => console_base.py} |   8 +-
 ...onsole_exec_attach.py => console_board.py} |   6 +-
 ..._console_sandbox.py => console_sandbox.py} |   8 +-
 test/py/{u_boot_spawn.py => spawn.py}         |   0
 test/py/tests/fit_util.py                     |  12 +-
 test/py/tests/test_000_version.py             |   8 +-
 test/py/tests/test_android/test_ab.py         |  48 +--
 test/py/tests/test_android/test_abootimg.py   |  92 +++---
 test/py/tests/test_android/test_avb.py        |  50 ++--
 test/py/tests/test_bind.py                    |  72 ++---
 test/py/tests/test_bootmenu.py                |  46 +--
 test/py/tests/test_bootstage.py               |  18 +-
 test/py/tests/test_button.py                  |  16 +-
 test/py/tests/test_cat/test_cat.py            |   6 +-
 test/py/tests/test_dfu.py                     |  54 ++--
 test/py/tests/test_dm.py                      |  28 +-
 .../test_efi_bootmgr/test_efi_bootmgr.py      |  34 +--
 .../tests/test_efi_capsule/capsule_common.py  |  60 ++--
 .../test_capsule_firmware_fit.py              | 100 +++----
 .../test_capsule_firmware_raw.py              | 126 ++++----
 .../test_capsule_firmware_signed_fit.py       | 104 +++----
 .../test_capsule_firmware_signed_raw.py       | 104 +++----
 test/py/tests/test_efi_fit.py                 |   6 +-
 test/py/tests/test_efi_loader.py              |  84 +++---
 .../py/tests/test_efi_secboot/test_authvar.py | 120 ++++----
 test/py/tests/test_efi_secboot/test_signed.py | 148 ++++-----
 .../test_efi_secboot/test_signed_intca.py     |  46 +--
 .../tests/test_efi_secboot/test_unsigned.py   |  42 +--
 test/py/tests/test_efi_selftest.py            | 180 +++++------
 .../py/tests/test_eficonfig/test_eficonfig.py | 106 +++----
 test/py/tests/test_env.py                     |  78 ++---
 test/py/tests/test_event_dump.py              |   6 +-
 test/py/tests/test_extension.py               |  32 +-
 test/py/tests/test_fit.py                     |   6 +-
 test/py/tests/test_fit_auto_signed.py         |   6 +-
 test/py/tests/test_fit_ecdsa.py               |   6 +-
 test/py/tests/test_fit_hashes.py              |   6 +-
 test/py/tests/test_fpga.py                    | 280 +++++++++---------
 test/py/tests/test_fs/conftest.py             |   2 +-
 test/py/tests/test_fs/test_basic.py           | 104 +++----
 test/py/tests/test_fs/test_erofs.py           |  76 ++---
 test/py/tests/test_fs/test_ext.py             | 124 ++++----
 test/py/tests/test_fs/test_fs_cmd.py          |   4 +-
 test/py/tests/test_fs/test_fs_fat.py          |   6 +-
 test/py/tests/test_fs/test_mkdir.py           |  48 +--
 .../test_fs/test_squashfs/test_sqfs_load.py   |  54 ++--
 .../test_fs/test_squashfs/test_sqfs_ls.py     |  64 ++--
 test/py/tests/test_fs/test_symlink.py         |  46 +--
 test/py/tests/test_fs/test_unlink.py          |  50 ++--
 test/py/tests/test_gpio.py                    | 106 +++----
 test/py/tests/test_gpt.py                     | 178 +++++------
 test/py/tests/test_handoff.py                 |   4 +-
 test/py/tests/test_help.py                    |  18 +-
 test/py/tests/test_i2c.py                     |  44 +--
 test/py/tests/test_kconfig.py                 |  10 +-
 test/py/tests/test_log.py                     |  10 +-
 test/py/tests/test_lsblk.py                   |   4 +-
 test/py/tests/test_md.py                      |  22 +-
 test/py/tests/test_mdio.py                    |  32 +-
 test/py/tests/test_memtest.py                 |  26 +-
 test/py/tests/test_mii.py                     |  50 ++--
 test/py/tests/test_mmc.py                     | 148 ++++-----
 test/py/tests/test_mmc_rd.py                  |  54 ++--
 test/py/tests/test_mmc_wr.py                  |  20 +-
 test/py/tests/test_net.py                     | 142 ++++-----
 test/py/tests/test_net_boot.py                | 144 ++++-----
 test/py/tests/test_of_migrate.py              |  14 +-
 test/py/tests/test_ofplatdata.py              |   6 +-
 test/py/tests/test_optee_rpmb.py              |  10 +-
 test/py/tests/test_part.py                    |   4 +-
 test/py/tests/test_pinmux.py                  |  32 +-
 test/py/tests/test_pstore.py                  |  48 +--
 test/py/tests/test_qfw.py                     |   8 +-
 test/py/tests/test_reset.py                   |  24 +-
 test/py/tests/test_sandbox_exit.py            |  28 +-
 test/py/tests/test_sandbox_opts.py            |  10 +-
 test/py/tests/test_saveenv.py                 |  70 ++---
 test/py/tests/test_scp03.py                   |   8 +-
 test/py/tests/test_scsi.py                    |  48 +--
 test/py/tests/test_semihosting/test_hostfs.py |  14 +-
 test/py/tests/test_sf.py                      |  66 ++---
 test/py/tests/test_shell_basics.py            |  30 +-
 test/py/tests/test_sleep.py                   |  26 +-
 test/py/tests/test_smbios.py                  |  12 +-
 test/py/tests/test_source.py                  |   6 +-
 test/py/tests/test_spi.py                     | 242 +++++++--------
 test/py/tests/test_spl.py                     |  12 +-
 test/py/tests/test_stackprotector.py          |   8 +-
 test/py/tests/test_tpm2.py                    | 190 ++++++------
 test/py/tests/test_trace.py                   |   6 +-
 test/py/tests/test_ums.py                     |  48 +--
 test/py/tests/test_unknown_cmd.py             |   6 +-
 test/py/tests/test_upl.py                     |   6 +-
 test/py/tests/test_usb.py                     | 206 ++++++-------
 test/py/tests/test_ut.py                      | 128 ++++----
 test/py/tests/test_vbe.py                     |   4 +-
 test/py/tests/test_vbe_vpl.py                 |  14 +-
 test/py/tests/test_vboot.py                   |  12 +-
 test/py/tests/test_vpl.py                     |   8 +-
 test/py/tests/test_xxd/test_xxd.py            |   6 +-
 test/py/tests/test_zynq_secure.py             |  96 +++---
 test/py/tests/test_zynqmp_rpu.py              | 106 +++----
 test/py/tests/test_zynqmp_secure.py           |  42 +--
 test/py/{u_boot_utils.py => utils.py}         |  44 +--
 107 files changed, 2758 insertions(+), 2749 deletions(-)
 rename test/py/{u_boot_console_base.py => console_base.py} (99%)
 rename test/py/{u_boot_console_exec_attach.py => console_board.py} (95%)
 rename test/py/{u_boot_console_sandbox.py => console_sandbox.py} (93%)
 rename test/py/{u_boot_spawn.py => spawn.py} (100%)
 rename test/py/{u_boot_utils.py => utils.py} (89%)
Signature · 1 line
2.43.0
#1 lore raw

PATCH 1/4 test/py: Shorten u_boot_console

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

---

 doc/develop/py_testing.rst                    |  12 +-
 doc/develop/tests_writing.rst                 |  12 +-
 test/py/conftest.py                           |   4 +-
 test/py/tests/fit_util.py                     |  10 +-
 test/py/tests/test_000_version.py             |   8 +-
 test/py/tests/test_android/test_ab.py         |  46 +--
 test/py/tests/test_android/test_abootimg.py   |  90 +++---
 test/py/tests/test_android/test_avb.py        |  48 +--
 test/py/tests/test_bind.py                    |  72 ++---
 test/py/tests/test_bootmenu.py                |  46 +--
 test/py/tests/test_bootstage.py               |  18 +-
 test/py/tests/test_button.py                  |  16 +-
 test/py/tests/test_cat/test_cat.py            |   6 +-
 test/py/tests/test_dfu.py                     |  42 +--
 test/py/tests/test_dm.py                      |  28 +-
 .../test_efi_bootmgr/test_efi_bootmgr.py      |  34 +--
 .../tests/test_efi_capsule/capsule_common.py  |  60 ++--
 .../test_capsule_firmware_fit.py              | 100 +++----
 .../test_capsule_firmware_raw.py              | 126 ++++----
 .../test_capsule_firmware_signed_fit.py       | 104 +++----
 .../test_capsule_firmware_signed_raw.py       | 104 +++----
 test/py/tests/test_efi_fit.py                 |   4 +-
 test/py/tests/test_efi_loader.py              |  82 +++---
 .../py/tests/test_efi_secboot/test_authvar.py | 120 ++++----
 test/py/tests/test_efi_secboot/test_signed.py | 148 +++++-----
 .../test_efi_secboot/test_signed_intca.py     |  46 +--
 .../tests/test_efi_secboot/test_unsigned.py   |  42 +--
 test/py/tests/test_efi_selftest.py            | 180 ++++++------
 .../py/tests/test_eficonfig/test_eficonfig.py | 106 +++----
 test/py/tests/test_env.py                     |  62 ++--
 test/py/tests/test_event_dump.py              |   4 +-
 test/py/tests/test_extension.py               |  30 +-
 test/py/tests/test_fit.py                     |   4 +-
 test/py/tests/test_fit_auto_signed.py         |   4 +-
 test/py/tests/test_fit_ecdsa.py               |   4 +-
 test/py/tests/test_fit_hashes.py              |   4 +-
 test/py/tests/test_fpga.py                    | 278 +++++++++---------
 test/py/tests/test_fs/test_basic.py           | 104 +++----
 test/py/tests/test_fs/test_erofs.py           |  76 ++---
 test/py/tests/test_fs/test_ext.py             | 124 ++++----
 test/py/tests/test_fs/test_fs_cmd.py          |   4 +-
 test/py/tests/test_fs/test_fs_fat.py          |   6 +-
 test/py/tests/test_fs/test_mkdir.py           |  48 +--
 .../test_fs/test_squashfs/test_sqfs_load.py   |  54 ++--
 .../test_fs/test_squashfs/test_sqfs_ls.py     |  64 ++--
 test/py/tests/test_fs/test_symlink.py         |  46 +--
 test/py/tests/test_fs/test_unlink.py          |  50 ++--
 test/py/tests/test_gpio.py                    | 104 +++----
 test/py/tests/test_gpt.py                     | 176 +++++------
 test/py/tests/test_handoff.py                 |   4 +-
 test/py/tests/test_help.py                    |  18 +-
 test/py/tests/test_i2c.py                     |  44 +--
 test/py/tests/test_kconfig.py                 |   8 +-
 test/py/tests/test_log.py                     |  10 +-
 test/py/tests/test_lsblk.py                   |   4 +-
 test/py/tests/test_md.py                      |  20 +-
 test/py/tests/test_mdio.py                    |  32 +-
 test/py/tests/test_memtest.py                 |  26 +-
 test/py/tests/test_mii.py                     |  50 ++--
 test/py/tests/test_mmc.py                     | 146 ++++-----
 test/py/tests/test_mmc_rd.py                  |  52 ++--
 test/py/tests/test_mmc_wr.py                  |  18 +-
 test/py/tests/test_net.py                     | 138 ++++-----
 test/py/tests/test_net_boot.py                | 142 ++++-----
 test/py/tests/test_of_migrate.py              |  12 +-
 test/py/tests/test_ofplatdata.py              |   4 +-
 test/py/tests/test_optee_rpmb.py              |   8 +-
 test/py/tests/test_part.py                    |   4 +-
 test/py/tests/test_pinmux.py                  |  30 +-
 test/py/tests/test_pstore.py                  |  46 +--
 test/py/tests/test_qfw.py                     |   8 +-
 test/py/tests/test_reset.py                   |  24 +-
 test/py/tests/test_sandbox_exit.py            |  28 +-
 test/py/tests/test_sandbox_opts.py            |   8 +-
 test/py/tests/test_saveenv.py                 |  70 ++---
 test/py/tests/test_scp03.py                   |   6 +-
 test/py/tests/test_scsi.py                    |  48 +--
 test/py/tests/test_semihosting/test_hostfs.py |  14 +-
 test/py/tests/test_sf.py                      |  64 ++--
 test/py/tests/test_shell_basics.py            |  30 +-
 test/py/tests/test_sleep.py                   |  26 +-
 test/py/tests/test_smbios.py                  |  12 +-
 test/py/tests/test_source.py                  |   4 +-
 test/py/tests/test_spi.py                     | 240 +++++++--------
 test/py/tests/test_spl.py                     |  12 +-
 test/py/tests/test_stackprotector.py          |   8 +-
 test/py/tests/test_tpm2.py                    | 188 ++++++------
 test/py/tests/test_trace.py                   |   4 +-
 test/py/tests/test_ums.py                     |  40 +--
 test/py/tests/test_unknown_cmd.py             |   6 +-
 test/py/tests/test_upl.py                     |   4 +-
 test/py/tests/test_usb.py                     | 204 ++++++-------
 test/py/tests/test_ut.py                      |  42 +--
 test/py/tests/test_vbe.py                     |   4 +-
 test/py/tests/test_vbe_vpl.py                 |   4 +-
 test/py/tests/test_vboot.py                   |  10 +-
 test/py/tests/test_vpl.py                     |   8 +-
 test/py/tests/test_xxd/test_xxd.py            |   6 +-
 test/py/tests/test_zynq_secure.py             |  94 +++---
 test/py/tests/test_zynqmp_rpu.py              | 106 +++----
 test/py/tests/test_zynqmp_secure.py           |  40 +--
 test/py/u_boot_utils.py                       |  44 +--
 102 files changed, 2591 insertions(+), 2591 deletions(-)
doc/develop/py_testing.rst +6 -6
index 6ff78103409..02367355f93 100644
@@ -473,24 +473,24 @@ Writing tests
 Please refer to the pytest documentation for details of writing pytest tests.
 Details specific to the U-Boot test suite are described below.
 
-A test fixture named `u_boot_console` should be used by each test function. This
+A test fixture named `ubpy` should be used by each test function. This
 provides the means to interact with the U-Boot console, and retrieve board and
 environment configuration information.
 
-The function `u_boot_console.run_command()` executes a shell command on the
+The function `ubpy.run_command()` executes a shell command on the
 U-Boot console, and returns all output from that command. This allows
 validation or interpretation of the command output. This function validates
 that certain strings are not seen on the U-Boot console. These include shell
 error messages and the U-Boot sign-on message (in order to detect unexpected
 board resets). See the source of `u_boot_console_base.py` for a complete list of
 "bad" strings. Some test scenarios are expected to trigger these strings. Use
-`u_boot_console.disable_check()` to temporarily disable checking for specific
+`ubpy.disable_check()` to temporarily disable checking for specific
 strings. See `test_unknown_cmd.py` for an example.
 
 Board- and board-environment configuration values may be accessed as sub-fields
-of the `u_boot_console.config` object, for example
-`u_boot_console.config.ram_base`.
+of the `ubpy.config` object, for example
+`ubpy.config.ram_base`.
 
 Build configuration values (from `.config`) may be accessed via the dictionary
-`u_boot_console.config.buildconfig`, with keys equal to the Kconfig variable
+`ubpy.config.buildconfig`, with keys equal to the Kconfig variable
 names.
doc/develop/tests_writing.rst +6 -6
index 5f3c43d5da2..73e91bf7294 100644
@@ -116,19 +116,19 @@ below are approximate, as measured on an AMD 2950X system. Here is is the test
 in Python::
 
    @pytest.mark.buildconfigspec('cmd_memory')
-   def test_md(u_boot_console):
+   def test_md(ubpy):
        """Test that md reads memory as expected, and that memory can be modified
        using the mw command."""
 
-       ram_base = u_boot_utils.find_ram_base(u_boot_console)
+       ram_base = u_boot_utils.find_ram_base(ubpy)
        addr = '%08x' % ram_base
        val = 'a5f09876'
        expected_response = addr + ': ' + val
-       u_boot_console.run_command('mw ' + addr + ' 0 10')
-       response = u_boot_console.run_command('md ' + addr + ' 10')
+       ubpy.run_command('mw ' + addr + ' 0 10')
+       response = ubpy.run_command('md ' + addr + ' 10')
        assert(not (expected_response in response))
-       u_boot_console.run_command('mw ' + addr + ' ' + val)
-       response = u_boot_console.run_command('md ' + addr + ' 10')
+       ubpy.run_command('mw ' + addr + ' ' + val)
+       response = ubpy.run_command('md ' + addr + ' 10')
        assert(expected_response in response)
 
 This runs a few commands and checks the output. Note that it runs a command,
test/py/conftest.py +2 -2
index a245f32dc8a..d70f621c2bf 100644
@@ -482,8 +482,8 @@ def u_boot_config(request):
      return console.config
 
 @pytest.fixture(scope='function')
-def u_boot_console(request):
-    """Generate the value of a test's u_boot_console fixture.
+def ubpy(request):
+    """Generate the value of a test's ubpy fixture.
 
     Args:
         request: The pytest request.
test/py/tests/fit_util.py +5 -5
index 79718d431a0..16ff8c96c63 100644
@@ -11,7 +11,7 @@ def make_fname(cons, basename):
     """Make a temporary filename
 
     Args:
-        cons (ConsoleBase): u_boot_console to use
+        cons (ConsoleBase): ubpy to use
         basename (str): Base name of file to create (within temporary directory)
     Return:
         Temporary filename
@@ -23,7 +23,7 @@ def make_its(cons, base_its, params, basename='test.its'):
     """Make a sample .its file with parameters embedded
 
     Args:
-        cons (ConsoleBase): u_boot_console to use
+        cons (ConsoleBase): ubpy to use
         base_its (str): Template text for the .its file, typically containing
             %() references
         params (dict of str): Parameters to embed in the %() strings
@@ -43,7 +43,7 @@ def make_fit(cons, mkimage, base_its, params, basename='test.fit', base_fdt=None
     turn this into a .fit image.
 
     Args:
-        cons (ConsoleBase): u_boot_console to use
+        cons (ConsoleBase): ubpy to use
         mkimage (str): Filename of 'mkimage' utility
         base_its (str): Template text for the .its file, typically containing
             %() references
@@ -64,7 +64,7 @@ def make_kernel(cons, basename, text):
     """Make a sample kernel with test data
 
     Args:
-        cons (ConsoleBase): u_boot_console to use
+        cons (ConsoleBase): ubpy to use
         basename (str): base name to write to (will be placed in the temp dir)
         text (str): Contents of the kernel file (will be repeated 100 times)
     Returns:
@@ -82,7 +82,7 @@ def make_dtb(cons, base_fdt, basename):
     """Make a sample .dts file and compile it to a .dtb
 
     Returns:
-        cons (ConsoleBase): u_boot_console to use
+        cons (ConsoleBase): ubpy to use
         Filename of .dtb file created
     """
     src = make_fname(cons, f'{basename}.dts')
test/py/tests/test_000_version.py +4 -4
index bd089ab5439..7ea0e50e9ef 100644
@@ -7,13 +7,13 @@
 # first, simply as a very basic sanity check of the functionality of the U-Boot
 # command prompt.
 
-def test_version(u_boot_console):
+def test_version(ubpy):
     """Test that the "version" command prints the U-Boot version."""
 
     # "version" prints the U-Boot sign-on message. This is usually considered
     # an error, so that any unexpected reboot causes an error. Here, this
     # error detection is disabled since the sign-on message is expected.
-    with u_boot_console.disable_check('main_signon'):
-        response = u_boot_console.run_command('version')
+    with ubpy.disable_check('main_signon'):
+        response = ubpy.run_command('version')
     # Ensure "version" printed what we expected.
-    u_boot_console.validate_version_string_in_text(response)
+    ubpy.validate_version_string_in_text(response)
test/py/tests/test_android/test_ab.py +23 -23

94 lines not on this page · raw message

test/py/tests/test_android/test_abootimg.py +45 -45

175 lines not on this page · raw message

test/py/tests/test_android/test_avb.py +24 -24

130 lines not on this page · raw message

test/py/tests/test_bind.py +36 -36

186 lines not on this page · raw message

test/py/tests/test_bootmenu.py +23 -23

65 lines not on this page · raw message

test/py/tests/test_bootstage.py +9 -9
index bd71a1af3a2..871bfa10609 100644
@@ -24,8 +24,8 @@ env__bootstage_cmd_file = {
 
 @pytest.mark.buildconfigspec('bootstage')
 @pytest.mark.buildconfigspec('cmd_bootstage')
-def test_bootstage_report(u_boot_console):
-    output = u_boot_console.run_command('bootstage report')
+def test_bootstage_report(ubpy):
+    output = ubpy.run_command('bootstage report')
     assert 'Timer summary in microseconds' in output
     assert 'Accumulated time:' in output
     assert 'dm_r' in output
@@ -33,8 +33,8 @@ def test_bootstage_report(u_boot_console):
 @pytest.mark.buildconfigspec('bootstage')
 @pytest.mark.buildconfigspec('cmd_bootstage')
 @pytest.mark.buildconfigspec('bootstage_stash')
-def test_bootstage_stash_and_unstash(u_boot_console):
-    f = u_boot_console.config.env.get('env__bootstage_cmd_file', None)
+def test_bootstage_stash_and_unstash(ubpy):
+    f = ubpy.config.env.get('env__bootstage_cmd_file', None)
     if not f:
         pytest.skip('No bootstage environment file is defined')
 
@@ -43,11 +43,11 @@ def test_bootstage_stash_and_unstash(u_boot_console):
     bootstage_magic = f.get('bootstage_magic_addr')
     expected_text = 'dm_r'
 
-    u_boot_console.run_command('bootstage stash %x %x' % (addr, size))
-    output = u_boot_console.run_command('echo $?')
+    ubpy.run_command('bootstage stash %x %x' % (addr, size))
+    output = ubpy.run_command('echo $?')
     assert output.endswith('0')
 
-    output = u_boot_console.run_command('md %x 100' % addr)
+    output = ubpy.run_command('md %x 100' % addr)
 
     # Check BOOTSTAGE_MAGIC address at 4th byte address
     assert '0x' + output.split('\n')[0].split()[4] == hex(bootstage_magic)
@@ -57,6 +57,6 @@ def test_bootstage_stash_and_unstash(u_boot_console):
     assert expected_text in output_last_col
 
     # Check that unstash works as expected
-    u_boot_console.run_command('bootstage unstash %x %x' % (addr, size))
-    output = u_boot_console.run_command('echo $?')
+    ubpy.run_command('bootstage unstash %x %x' % (addr, size))
+    output = ubpy.run_command('echo $?')
     assert output.endswith('0')
test/py/tests/test_button.py +8 -8
index 3b7f148c8fc..b392c27a90f 100644
@@ -4,10 +4,10 @@ import pytest
 
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('cmd_button')
-def test_button_list(u_boot_console):
+def test_button_list(ubpy):
     """Test listing buttons"""
 
-    response = u_boot_console.run_command('button list; echo rc:$?')
+    response = ubpy.run_command('button list; echo rc:$?')
     assert('button1' in response)
     assert('button2' in response)
     assert('rc:0' in response)
@@ -15,23 +15,23 @@ def test_button_list(u_boot_console):
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('cmd_button')
 @pytest.mark.buildconfigspec('cmd_gpio')
-def test_button_return_code(u_boot_console):
+def test_button_return_code(ubpy):
     """Test correct reporting of the button status
 
     The sandbox gpio driver reports the last output value as input value.
     We can use this in our test to emulate different input statuses.
     """
 
-    u_boot_console.run_command('gpio set a3; gpio input a3');
-    response = u_boot_console.run_command('button button1; echo rc:$?')
+    ubpy.run_command('gpio set a3; gpio input a3');
+    response = ubpy.run_command('button button1; echo rc:$?')
     assert('on' in response)
     assert('rc:0' in response)
 
-    u_boot_console.run_command('gpio clear a3; gpio input a3');
-    response = u_boot_console.run_command('button button1; echo rc:$?')
+    ubpy.run_command('gpio clear a3; gpio input a3');
+    response = ubpy.run_command('button button1; echo rc:$?')
     assert('off' in response)
     assert('rc:1' in response)
 
-    response = u_boot_console.run_command('button nonexistent-button; echo rc:$?')
+    response = ubpy.run_command('button nonexistent-button; echo rc:$?')
     assert('not found' in response)
     assert('rc:1' in response)
test/py/tests/test_cat/test_cat.py +3 -3
index 132527bd4c2..c068935d1ba 100644
@@ -7,14 +7,14 @@ import pytest
 
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('cmd_cat')
-def test_cat(u_boot_console, cat_data):
+def test_cat(ubpy, cat_data):
     """ Unit test for cat
 
     Args:
-        u_boot_console -- U-Boot console
+        ubpy -- U-Boot console
         cat_data -- Path to the disk image used for testing.
     """
-    response = u_boot_console.run_command_list([
+    response = ubpy.run_command_list([
         f'host bind 0 {cat_data}',
         'cat host 0 hello'])
     assert 'hello world' in response
test/py/tests/test_dfu.py +21 -21

116 lines not on this page · raw message

test/py/tests/test_dm.py +14 -14
index be94971e455..c53b865772e 100644
@@ -4,15 +4,15 @@
 import pytest
 
 @pytest.mark.buildconfigspec('cmd_dm')
-def test_dm_compat(u_boot_console):
+def test_dm_compat(ubpy):
     """Test that each driver in `dm tree` is also listed in `dm compat`."""
-    response = u_boot_console.run_command('dm tree')
+    response = ubpy.run_command('dm tree')
     driver_index = response.find('Driver')
     assert driver_index != -1
     drivers = (line[driver_index:].split()[0]
                for line in response[:-1].split('\n')[2:])
 
-    response = u_boot_console.run_command('dm compat')
+    response = ubpy.run_command('dm compat')
     bad_drivers = set()
     for driver in drivers:
         if not driver in response:
@@ -29,7 +29,7 @@ def test_dm_compat(u_boot_console):
     # checking sorting only after UCLASS_AXI_EMUL after which the names should
     # be sorted.
 
-    response = u_boot_console.run_command('dm tree -s')
+    response = ubpy.run_command('dm tree -s')
     lines = response.split('\n')[2:]
     stack = []   # holds where we were up to at the previous indent level
     prev = ''    # uclass name of previous line
@@ -58,27 +58,27 @@ def test_dm_compat(u_boot_console):
 
 
 @pytest.mark.buildconfigspec('cmd_dm')
-def test_dm_drivers(u_boot_console):
+def test_dm_drivers(ubpy):
     """Test that each driver in `dm compat` is also listed in `dm drivers`."""
-    response = u_boot_console.run_command('dm compat')
+    response = ubpy.run_command('dm compat')
     drivers = (line[:20].rstrip() for line in response[:-1].split('\n')[2:])
-    response = u_boot_console.run_command('dm drivers')
+    response = ubpy.run_command('dm drivers')
     for driver in drivers:
         assert driver in response
 
 @pytest.mark.buildconfigspec('cmd_dm')
-def test_dm_static(u_boot_console):
+def test_dm_static(ubpy):
     """Test that each driver in `dm static` is also listed in `dm drivers`."""
-    response = u_boot_console.run_command('dm static')
+    response = ubpy.run_command('dm static')
     drivers = (line[:25].rstrip() for line in response[:-1].split('\n')[2:])
-    response = u_boot_console.run_command('dm drivers')
+    response = ubpy.run_command('dm drivers')
     for driver in drivers:
         assert driver in response
 
 @pytest.mark.buildconfigspec("cmd_dm")
-def test_dm_uclass(u_boot_console):
-    response = u_boot_console.run_command("dm uclass")
+def test_dm_uclass(ubpy):
+    response = ubpy.run_command("dm uclass")
 
 @pytest.mark.buildconfigspec("cmd_dm")
-def test_dm_devres(u_boot_console):
-    response = u_boot_console.run_command("dm devres")
+def test_dm_devres(ubpy):
+    response = ubpy.run_command("dm devres")
test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py +17 -17
index 1bb59d8fcf8..432c51e2797 100644
@@ -8,37 +8,37 @@ import pytest
 @pytest.mark.buildconfigspec('cmd_efidebug')
 @pytest.mark.buildconfigspec('cmd_bootefi_bootmgr')
 @pytest.mark.singlethread
-def test_efi_bootmgr(u_boot_console, efi_bootmgr_data):
+def test_efi_bootmgr(ubpy, efi_bootmgr_data):
     """ Unit test for UEFI bootmanager
     The efidebug command is used to set up UEFI load options.
     The bootefi bootmgr loads initrddump.efi as a payload.
     The crc32 of the loaded initrd.img is checked
 
     Args:
-        u_boot_console -- U-Boot console
+        ubpy -- U-Boot console
         efi_bootmgr_data -- Path to the disk image used for testing.
     """
-    u_boot_console.run_command(cmd = f'host bind 0 {efi_bootmgr_data}')
+    ubpy.run_command(cmd = f'host bind 0 {efi_bootmgr_data}')
 
-    u_boot_console.run_command(cmd = 'efidebug boot add ' \
+    ubpy.run_command(cmd = 'efidebug boot add ' \
         '-b 0001 label-1 host 0:1 initrddump.efi ' \
         '-i host 0:1 initrd-1.img -s nocolor')
-    u_boot_console.run_command(cmd = 'efidebug boot dump')
-    u_boot_console.run_command(cmd = 'efidebug boot order 0001')
-    u_boot_console.run_command(cmd = 'bootefi bootmgr')
-    response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False)
+    ubpy.run_command(cmd = 'efidebug boot dump')
+    ubpy.run_command(cmd = 'efidebug boot order 0001')
+    ubpy.run_command(cmd = 'bootefi bootmgr')
+    response = ubpy.run_command(cmd = 'load', wait_for_echo=False)
     assert 'crc32: 0x181464af' in response
-    u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+    ubpy.run_command(cmd = 'exit', wait_for_echo=False)
 
-    u_boot_console.run_command(cmd = 'efidebug boot add ' \
+    ubpy.run_command(cmd = 'efidebug boot add ' \
         '-B 0002 label-2 host 0:1 initrddump.efi ' \
         '-I host 0:1 initrd-2.img -s nocolor')
-    u_boot_console.run_command(cmd = 'efidebug boot dump')
-    u_boot_console.run_command(cmd = 'efidebug boot order 0002')
-    u_boot_console.run_command(cmd = 'bootefi bootmgr')
-    response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False)
+    ubpy.run_command(cmd = 'efidebug boot dump')
+    ubpy.run_command(cmd = 'efidebug boot order 0002')
+    ubpy.run_command(cmd = 'bootefi bootmgr')
+    response = ubpy.run_command(cmd = 'load', wait_for_echo=False)
     assert 'crc32: 0x811d3515' in response
-    u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+    ubpy.run_command(cmd = 'exit', wait_for_echo=False)
 
-    u_boot_console.run_command(cmd = 'efidebug boot rm 0001')
-    u_boot_console.run_command(cmd = 'efidebug boot rm 0002')
+    ubpy.run_command(cmd = 'efidebug boot rm 0001')
+    ubpy.run_command(cmd = 'efidebug boot rm 0002')
test/py/tests/test_efi_capsule/capsule_common.py +30 -30

161 lines not on this page · raw message

test/py/tests/test_efi_capsule/test_capsule_firmware_fit.py +50 -50

191 lines not on this page · raw message

test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py +63 -63

247 lines not on this page · raw message

test/py/tests/test_efi_capsule/test_capsule_firmware_signed_fit.py +52 -52

192 lines not on this page · raw message

test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py +52 -52

191 lines not on this page · raw message

test/py/tests/test_efi_fit.py +2 -2
index 550058a30fd..fc57536821d 100644
@@ -123,7 +123,7 @@ FDT_DATA = '''
 @pytest.mark.buildconfigspec('fit')
 @pytest.mark.notbuildconfigspec('generate_acpi_table')
 @pytest.mark.requiredtool('dtc')
-def test_efi_fit_launch(u_boot_console):
+def test_efi_fit_launch(ubpy):
     """Test handling of UEFI binaries inside FIT images.
 
     The tests are trying to launch U-Boot's helloworld.efi embedded into
@@ -428,7 +428,7 @@ def test_efi_fit_launch(u_boot_console):
             assert '## Application failed' not in output
             cons.restart_uboot()
 
-    cons = u_boot_console
+    cons = ubpy
     # Array slice removes leading/trailing quotes.
     sys_arch = cons.config.buildconfig.get('config_sys_arch', '"sandbox"')[1:-1]
     if sys_arch == 'arm':
test/py/tests/test_efi_loader.py +41 -41

209 lines not on this page · raw message

test/py/tests/test_efi_secboot/test_authvar.py +60 -60

305 lines not on this page · raw message

test/py/tests/test_efi_secboot/test_signed.py +74 -74

383 lines not on this page · raw message

test/py/tests/test_efi_secboot/test_signed_intca.py +23 -23

46 lines not on this page · raw message

test/py/tests/test_efi_secboot/test_unsigned.py +21 -21

42 lines not on this page · raw message

test/py/tests/test_efi_selftest.py +90 -90

180 lines not on this page · raw message

test/py/tests/test_eficonfig/test_eficonfig.py +53 -53

106 lines not on this page · raw message

test/py/tests/test_env.py +31 -31

62 lines not on this page · raw message

test/py/tests/test_event_dump.py +2 -2
index 45143c1c7d9..51cc9a3a211 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_extension.py +15 -15
index 267cf2ff27c..cb470c1c951 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_fit.py +2 -2
index 8f9c4b26411..bbf2eab33e3 100755

Lines of this file are not shown. View the raw message.

test/py/tests/test_fit_auto_signed.py +2 -2
index 9ea3351619f..6b8f7d1848f 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_fit_ecdsa.py +2 -2
index cc6c0c4dc42..e51120bc15c 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_fit_hashes.py +2 -2
index 4891e77ca2d..7b13c0e748c 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_fpga.py +139 -139

278 lines not on this page · raw message

test/py/tests/test_fs/test_basic.py +52 -52

104 lines not on this page · raw message

test/py/tests/test_fs/test_erofs.py +38 -38

76 lines not on this page · raw message

test/py/tests/test_fs/test_ext.py +62 -62

124 lines not on this page · raw message

test/py/tests/test_fs/test_fs_cmd.py +2 -2
index 700cf3591de..21e74c41269 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_fs/test_fs_fat.py +3 -3
index 4009d0b63a3..6e5f0f68394 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_fs/test_mkdir.py +24 -24

48 lines not on this page · raw message

test/py/tests/test_fs/test_squashfs/test_sqfs_load.py +27 -27

54 lines not on this page · raw message

test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py +32 -32

64 lines not on this page · raw message

test/py/tests/test_fs/test_symlink.py +23 -23

46 lines not on this page · raw message

test/py/tests/test_fs/test_unlink.py +25 -25

50 lines not on this page · raw message

test/py/tests/test_gpio.py +52 -52

104 lines not on this page · raw message

test/py/tests/test_gpt.py +88 -88

176 lines not on this page · raw message

test/py/tests/test_handoff.py +2 -2
index 038f03064a6..c6e28f8bffd 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_help.py +9 -9
index 2325ff69229..a949a488f7c 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_i2c.py +22 -22

44 lines not on this page · raw message

test/py/tests/test_kconfig.py +4 -4
index 0b9e6bc3bd1..bd1f75a795f 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_log.py +5 -5
index 79808674bbe..3001e262e66 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_lsblk.py +2 -2
index a719a48e6ee..1480504a4b6 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_md.py +10 -10
index 83e3c546f4a..550a367d076 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_mdio.py +16 -16
index 89711e70b55..9ff72b9b42c 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_memtest.py +13 -13
index 0618d96f1be..f6250623b5f 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_mii.py +25 -25

50 lines not on this page · raw message

test/py/tests/test_mmc.py +73 -73

146 lines not on this page · raw message

test/py/tests/test_mmc_rd.py +26 -26

52 lines not on this page · raw message

test/py/tests/test_mmc_wr.py +9 -9
index 05e5c1ee85d..2b278cb21cd 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_net.py +69 -69

138 lines not on this page · raw message

test/py/tests/test_net_boot.py +71 -71

142 lines not on this page · raw message

test/py/tests/test_of_migrate.py +6 -6
index 910f7c05510..274ea455f9f 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_ofplatdata.py +2 -2
index 51a188454f3..391d475ca90 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_optee_rpmb.py +4 -4
index 8a081b5c494..8940d4a3073 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_part.py +2 -2
index 2b5184654db..b229cfec9fb 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_pinmux.py +15 -15
index 794994e12d1..e599d2f38fe 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_pstore.py +23 -23

46 lines not on this page · raw message

test/py/tests/test_qfw.py +4 -4
index 8b668c9721a..67a7cc7ce3f 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_reset.py +12 -12
index 00fc31da57d..33a49bff5a5 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_sandbox_exit.py +14 -14
index 706f5fa3594..ff1e9df3673 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_sandbox_opts.py +4 -4
index 422b43cb3bc..a0231f6d453 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_saveenv.py +35 -35

70 lines not on this page · raw message

test/py/tests/test_scp03.py +3 -3
index 1a104b365f7..3ff6c0a2602 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_scsi.py +24 -24

48 lines not on this page · raw message

test/py/tests/test_semihosting/test_hostfs.py +7 -7
index 51f6fa7702c..72ab26d33dd 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_sf.py +32 -32

64 lines not on this page · raw message

test/py/tests/test_shell_basics.py +15 -15
index 68a3f892f6b..c2ff7edf670 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_sleep.py +13 -13
index 8965fc3fea9..5e88166819e 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_smbios.py +6 -6
index 82b0b689830..2d748e96c59 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_source.py +2 -2
index bbc311df6d1..66539cf89c1 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_spi.py +120 -120

240 lines not on this page · raw message

test/py/tests/test_spl.py +6 -6
index 474f430a344..1363adabe2e 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_stackprotector.py +4 -4
index b87392c54ff..37989bd2c3c 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_tpm2.py +94 -94

188 lines not on this page · raw message

test/py/tests/test_trace.py +2 -2
index ec1e624722c..86541c96e0d 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_ums.py +20 -20
index 749b1606235..0078f9568f6 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_unknown_cmd.py +3 -3
index 8fc284a9249..771fab4b3ca 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_upl.py +2 -2
index d94359d8b9b..155e44ddcb6 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_usb.py +102 -102

204 lines not on this page · raw message

test/py/tests/test_ut.py +21 -21

42 lines not on this page · raw message

test/py/tests/test_vbe.py +2 -2
index 861df3f8266..32d97fbf176 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_vbe_vpl.py +2 -2
index ed12d3a4618..7e25924e4e7 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_vboot.py +5 -5
index 7e0e8e44750..72472914f2c 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_vpl.py +4 -4
index 8c472ca7a92..101d77c6962 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_xxd/test_xxd.py +3 -3
index 06b9cfc0003..b081f9fe5a8 100644

Lines of this file are not shown. View the raw message.

test/py/tests/test_zynq_secure.py +47 -47

94 lines not on this page · raw message

test/py/tests/test_zynqmp_rpu.py +53 -53

106 lines not on this page · raw message

test/py/tests/test_zynqmp_secure.py +20 -20
index 570bd2439c1..e2b6ac5a221 100644

Lines of this file are not shown. View the raw message.

test/py/u_boot_utils.py +22 -22

44 lines not on this page · raw message

The rest of this diff is not shown. View the raw message.

Signature · 1 line
2.43.0

Part of the diff is not shown here. View the raw message.

#2 lore raw

Re: [PATCH 1/4] test/py: Shorten u_boot_console

Quoted 12 lines · Simon Glass

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

[snip]

Quoted 1 line
 102 files changed, 2591 insertions(+), 2591 deletions(-)

First, I'm not sure I like "ubpy". I believe "u_boot_console" is because it's how we interact with the stdin/stdout of the running U-Boot. And indeed it provides more than that. But ubpy is too abstract and unclear, and looking at the diffstat, I don't know that big global rename is justified to save text space.

Signature · 1 line
Tom
#3 lore raw

Re: [PATCH 1/4] test/py: Shorten u_boot_console

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

Quoted 6 lines

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

Quoted 8 lines

[snip]

Quoted 1 line
 102 files changed, 2591 insertions(+), 2591 deletions(-)

First, I'm not sure I like "ubpy". I believe "u_boot_console" is because it's how we interact with the stdin/stdout of the running U-Boot. And indeed it provides more than that. But ubpy is too abstract and unclear, and looking at the diffstat, I don't know that big global rename is justified to save text space.

I actually get quite confused hunting around in the fixtures so I suspect others do too. I would like to settle on some better names.

Yes, I don't like ubpy much, either. Your favourite AI suggests 'fixture' or 'test_env', both I which I prefer. The only challenge is that 'env' has various other meanings in U-Boot.

Regards,
Simon

#4 lore raw

Re: [PATCH 1/4] test/py: Shorten u_boot_console

Quoted 27 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

Quoted 6 lines

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

Quoted 8 lines

[snip]

Quoted 1 line
 102 files changed, 2591 insertions(+), 2591 deletions(-)

First, I'm not sure I like "ubpy". I believe "u_boot_console" is because it's how we interact with the stdin/stdout of the running U-Boot. And indeed it provides more than that. But ubpy is too abstract and unclear, and looking at the diffstat, I don't know that big global rename is justified to save text space.

Quoted 6 lines

I actually get quite confused hunting around in the fixtures so I suspect others do too. I would like to settle on some better names.

Yes, I don't like ubpy much, either. Your favourite AI suggests 'fixture' or 'test_env', both I which I prefer. The only challenge is that 'env' has various other meanings in U-Boot.

Yes, until someone has a better suggestion than "ubpy", we should leave things alone. "fixture" has its own meaning within pytest and so that would also be confusing.

Signature · 1 line
Tom
#5 lore raw

Re: [PATCH 1/4] test/py: Shorten u_boot_console

Hi Tom,

Quoted 32 lines · Tom Rini
Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

Quoted 6 lines

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

Quoted 8 lines

[snip]

Quoted 1 line
 102 files changed, 2591 insertions(+), 2591 deletions(-)

First, I'm not sure I like "ubpy". I believe "u_boot_console" is because it's how we interact with the stdin/stdout of the running U-Boot. And indeed it provides more than that. But ubpy is too abstract and unclear, and looking at the diffstat, I don't know that big global rename is justified to save text space.

I actually get quite confused hunting around in the fixtures so I suspect others do too. I would like to settle on some better names.

Quoted 7 lines
Quoted 3 lines

Yes, I don't like ubpy much, either. Your favourite AI suggests 'fixture' or 'test_env', both I which I prefer. The only challenge is that 'env' has various other meanings in U-Boot.

Yes, until someone has a better suggestion than "ubpy", we should leave things alone. "fixture" has its own meaning within pytest and so that would also be confusing.

Yes, ideas welcome. Arguably it is confusing that this one fixture provides a gateway to all the others.

Regards,
Simon

#6 lore raw

Re: [PATCH 1/4] test/py: Shorten u_boot_console

Hi Simon,

Quoted 39 lines · Simon Glass

Hi Tom,

Quoted 36 lines · Tom Rini
Quoted 33 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

Quoted 6 lines

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

Quoted 8 lines

[snip]

Quoted 1 line
  102 files changed, 2591 insertions(+), 2591 deletions(-)

First, I'm not sure I like "ubpy". I believe "u_boot_console" is because it's how we interact with the stdin/stdout of the running U-Boot. And indeed it provides more than that. But ubpy is too abstract and unclear, and looking at the diffstat, I don't know that big global rename is justified to save text space.

I actually get quite confused hunting around in the fixtures so I suspect others do too. I would like to settle on some better names.

Yes, I don't like ubpy much, either. Your favourite AI suggests 'fixture' or 'test_env', both I which I prefer. The only challenge is that 'env' has various other meanings in U-Boot.

Quoted 6 lines
Quoted 3 lines

Yes, until someone has a better suggestion than "ubpy", we should leave things alone. "fixture" has its own meaning within pytest and so that would also be confusing.

Yes, ideas welcome. Arguably it is confusing that this one fixture provides a gateway to all the others.

I have a couple of names to suggest:
1) "ubintf"/"ub_interface" - As it interacts with U-Boot during testing and acts as the primary interface.
2) "ubman"/"ub_manager" - As it manages multiple things in tests, not only limited to console.

Regards,
Love Kumar

Quoted 3 lines

Regards,
Simon

#7 lore raw

Re: [PATCH 1/4] test/py: Shorten u_boot_console

Hi Love,

Quoted 47 lines · Love Kumar

Hi Simon,

Quoted 43 lines · Simon Glass

Hi Tom,

Quoted 39 lines · Tom Rini
Quoted 27 lines · Simon Glass

Hi Tom,

Quoted 15 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fixture name is quite long and results in lots of verbose code. We know this is U-Boot so the 'u_boot_' part is not necessary.

But it is also a bit of a misnomer, since it provides access to all the information available to tests. It is not just the console.

Quoted 6 lines

It would be too confusing to use con as it would be confused with config and it is probably too short.

So shorten it to 'ubpy'.

Quoted 8 lines

[snip]

Quoted 1 line
  102 files changed, 2591 insertions(+), 2591 deletions(-)

First, I'm not sure I like "ubpy". I believe "u_boot_console" is because it's how we interact with the stdin/stdout of the running U-Boot. And indeed it provides more than that. But ubpy is too abstract and unclear, and looking at the diffstat, I don't know that big global rename is justified to save text space.

Quoted 6 lines

I actually get quite confused hunting around in the fixtures so I suspect others do too. I would like to settle on some better names.

Yes, I don't like ubpy much, either. Your favourite AI suggests 'fixture' or 'test_env', both I which I prefer. The only challenge is that 'env' has various other meanings in U-Boot.

Yes, until someone has a better suggestion than "ubpy", we should leave things alone. "fixture" has its own meaning within pytest and so that would also be confusing.

Quoted 8 lines
Quoted 2 lines

Yes, ideas welcome. Arguably it is confusing that this one fixture provides a gateway to all the others.

I have a couple of names to suggest:
1) "ubintf"/"ub_interface" - As it interacts with U-Boot during testing and acts as the primary interface.
2) "ubman"/"ub_manager" - As it manages multiple things in tests, not only limited to console.

Thanks for the ideas. Both of those seem good to me. I'll give it a try with the second one since it is easier to say.

Regards,
Simon

#8 lore raw

PATCH 2/4 test: Drop u_boot_ prefix on test files

In reply to Simon Glass

We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files.

---

 doc/develop/py_testing.rst                    |  4 +-
 doc/develop/tests_writing.rst                 |  2 +-
 test/py/conftest.py                           | 52 +++++------
 ...u_boot_console_base.py => console_base.py} |  8 +-
 ...onsole_exec_attach.py => console_board.py} |  6 +-
 ..._console_sandbox.py => console_sandbox.py} |  8 +-
 test/py/{u_boot_spawn.py => spawn.py}         |  0
 test/py/tests/fit_util.py                     |  2 +-
 test/py/tests/test_android/test_ab.py         | 12 +--
 test/py/tests/test_android/test_abootimg.py   | 10 +--
 test/py/tests/test_android/test_avb.py        |  2 +-
 test/py/tests/test_dfu.py                     | 18 ++--
 test/py/tests/test_efi_fit.py                 |  2 +-
 test/py/tests/test_efi_loader.py              |  4 +-
 test/py/tests/test_env.py                     | 24 +++---
 test/py/tests/test_event_dump.py              |  2 +-
 test/py/tests/test_extension.py               |  2 +-
 test/py/tests/test_fit.py                     |  2 +-
 test/py/tests/test_fit_auto_signed.py         |  2 +-
 test/py/tests/test_fit_ecdsa.py               |  2 +-
 test/py/tests/test_fit_hashes.py              |  2 +-
 test/py/tests/test_fpga.py                    |  8 +-
 test/py/tests/test_fs/conftest.py             |  2 +-
 test/py/tests/test_gpio.py                    |  2 +-
 test/py/tests/test_gpt.py                     | 14 +--
 test/py/tests/test_kconfig.py                 |  2 +-
 test/py/tests/test_md.py                      |  6 +-
 test/py/tests/test_mmc.py                     |  8 +-
 test/py/tests/test_mmc_rd.py                  |  4 +-
 test/py/tests/test_mmc_wr.py                  |  4 +-
 test/py/tests/test_net.py                     |  6 +-
 test/py/tests/test_net_boot.py                |  4 +-
 test/py/tests/test_of_migrate.py              |  2 +-
 test/py/tests/test_ofplatdata.py              |  2 +-
 test/py/tests/test_optee_rpmb.py              |  2 +-
 test/py/tests/test_pinmux.py                  |  2 +-
 test/py/tests/test_pstore.py                  |  2 +-
 test/py/tests/test_sandbox_opts.py            |  2 +-
 test/py/tests/test_scp03.py                   |  2 +-
 test/py/tests/test_sf.py                      | 12 +--
 test/py/tests/test_source.py                  |  2 +-
 test/py/tests/test_spi.py                     | 14 +--
 test/py/tests/test_tpm2.py                    | 10 +--
 test/py/tests/test_trace.py                   |  2 +-
 test/py/tests/test_ums.py                     | 20 ++---
 test/py/tests/test_upl.py                     |  2 +-
 test/py/tests/test_usb.py                     | 12 +--
 test/py/tests/test_ut.py                      | 86 +++++++++----------
 test/py/tests/test_vbe_vpl.py                 | 10 +--
 test/py/tests/test_vboot.py                   |  2 +-
 test/py/tests/test_zynq_secure.py             | 12 +--
 test/py/tests/test_zynqmp_secure.py           |  8 +-
 test/py/{u_boot_utils.py => utils.py}         |  0
 53 files changed, 216 insertions(+), 216 deletions(-)
 rename test/py/{u_boot_console_base.py => console_base.py} (99%)
 rename test/py/{u_boot_console_exec_attach.py => console_board.py} (95%)
 rename test/py/{u_boot_console_sandbox.py => console_sandbox.py} (93%)
 rename test/py/{u_boot_spawn.py => spawn.py} (100%)
 rename test/py/{u_boot_utils.py => utils.py} (100%)
doc/develop/py_testing.rst +2 -2
index 02367355f93..1bb38eb96a3 100644
@@ -125,7 +125,7 @@ browser, but may be read directly as plain text, perhaps with the aid of the
 If sandbox crashes (e.g. with a segfault) you will see message like this::
 
 
-    test/py/u_boot_spawn.py:171: in expect
+    test/py/spawn.py:171: in expect
         c = os.read(self.fd, 1024).decode(errors='replace')
     E   ValueError: U-Boot exited with signal 11 (Signals.SIGSEGV)
 
@@ -482,7 +482,7 @@ U-Boot console, and returns all output from that command. This allows
 validation or interpretation of the command output. This function validates
 that certain strings are not seen on the U-Boot console. These include shell
 error messages and the U-Boot sign-on message (in order to detect unexpected
-board resets). See the source of `u_boot_console_base.py` for a complete list of
+board resets). See the source of `console_base.py` for a complete list of
 "bad" strings. Some test scenarios are expected to trigger these strings. Use
 `ubpy.disable_check()` to temporarily disable checking for specific
 strings. See `test_unknown_cmd.py` for an example.
doc/develop/tests_writing.rst +1 -1
index 73e91bf7294..d37976fc06d 100644
@@ -120,7 +120,7 @@ in Python::
        """Test that md reads memory as expected, and that memory can be modified
        using the mw command."""
 
-       ram_base = u_boot_utils.find_ram_base(ubpy)
+       ram_base = utils.find_ram_base(ubpy)
        addr = '%08x' % ram_base
        val = 'a5f09876'
        expected_response = addr + ': ' + val
test/py/conftest.py +26 -26

138 lines not on this page · raw message

test/py/console_base.py renamed from test/py/u_boot_console_base.py +4 -4
similarity index 99%
rename from test/py/u_boot_console_base.py
rename to test/py/console_base.py
index fa9cd57b04b..b080c389547 100644
@@ -13,8 +13,8 @@ import os
 import pytest
 import re
 import sys
-import u_boot_spawn
-from u_boot_spawn import BootFail, Timeout, Unexpected, handle_exception
+import spawn
+from spawn import BootFail, Timeout, Unexpected, handle_exception
 
 # Regexes for text we expect U-Boot to send to the console.
 pattern_u_boot_spl_signon = re.compile('(U-Boot SPL \\d{4}\\.\\d{2}[^\r\n]*\\))')
@@ -157,9 +157,9 @@ class ConsoleBase(object):
     def get_spawn(self):
         # This is not called, ssubclass must define this.
         # Return a value to avoid:
-        #   u_boot_console_base.py:348:12: E1128: Assigning result of a function
+        #   console_base.py:348:12: E1128: Assigning result of a function
         #   call, where the function returns None (assignment-from-none)
-        return u_boot_spawn.Spawn([])
+        return spawn.Spawn([])
 
 
     def eval_bad_patterns(self):
test/py/console_board.py renamed from test/py/u_boot_console_exec_attach.py +3 -3
similarity index 95%
rename from test/py/u_boot_console_exec_attach.py
rename to test/py/console_board.py
index 8b253b4451d..bacb1e2526c 100644
@@ -8,8 +8,8 @@ physical serial port.
 """
 
 import sys
-from u_boot_spawn import Spawn
-from u_boot_console_base import ConsoleBase
+from spawn import Spawn
+from console_base import ConsoleBase
 
 class ConsoleExecAttach(ConsoleBase):
     """Represents a physical connection to a U-Boot console, typically via a
@@ -53,7 +53,7 @@ class ConsoleExecAttach(ConsoleBase):
             None.
 
         Returns:
-            A u_boot_spawn.Spawn object that is attached to U-Boot.
+            A spawn.Spawn object that is attached to U-Boot.
         """
 
         args = [self.config.board_type, self.config.board_identity]
test/py/console_sandbox.py renamed from test/py/u_boot_console_sandbox.py +4 -4
similarity index 93%
rename from test/py/u_boot_console_sandbox.py
rename to test/py/console_sandbox.py
index 7bc44c78b8b..da55d2fcc1f 100644
@@ -7,8 +7,8 @@ Logic to interact with the sandbox port of U-Boot, running as a sub-process.
 """
 
 import time
-from u_boot_spawn import Spawn
-from u_boot_console_base import ConsoleBase
+from spawn import Spawn
+from console_base import ConsoleBase
 
 class ConsoleSandbox(ConsoleBase):
     """Represents a connection to a sandbox U-Boot console, executed as a sub-
@@ -39,7 +39,7 @@ class ConsoleSandbox(ConsoleBase):
             None.
 
         Returns:
-            A u_boot_spawn.Spawn object that is attached to U-Boot.
+            A spawn.Spawn object that is attached to U-Boot.
         """
 
         bcfg = self.config.buildconfig
@@ -71,7 +71,7 @@ class ConsoleSandbox(ConsoleBase):
             use_dtb: True to use a device tree file, False to run without one
 
         Returns:
-            A u_boot_spawn.Spawn object that is attached to U-Boot.
+            A spawn.Spawn object that is attached to U-Boot.
         """
 
         try:
test/py/spawn.py renamed from test/py/u_boot_spawn.py +0 -0
similarity index 100%
rename from test/py/u_boot_spawn.py
rename to test/py/spawn.py
test/py/tests/fit_util.py +1 -1
index 16ff8c96c63..7aad4030be3 100644
@@ -5,7 +5,7 @@
 
 import os
 
-import u_boot_utils as util
+import utils as util
 
 def make_fname(cons, basename):
     """Make a temporary filename
test/py/tests/test_android/test_ab.py +6 -6
index 71719d86104..320d1566e63 100644
@@ -5,7 +5,7 @@
 
 import os
 import pytest
-import u_boot_utils
+import utils
 
 class ABTestDiskImage(object):
     """Disk Image used by the A/B tests."""
@@ -25,7 +25,7 @@ class ABTestDiskImage(object):
         persistent = ubpy.config.persistent_data_dir + '/' + filename
         self.path = ubpy.config.result_dir  + '/' + filename
 
-        with u_boot_utils.persistent_file_helper(ubpy.log, persistent):
+        with utils.persistent_file_helper(ubpy.log, persistent):
             if os.path.exists(persistent):
                 ubpy.log.action('Disk image file ' + persistent +
                     ' already exists')
@@ -35,16 +35,16 @@ class ABTestDiskImage(object):
                 os.ftruncate(fd, 524288)
                 os.close(fd)
                 cmd = ('sgdisk', persistent)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
 
                 cmd = ('sgdisk', '--new=1:64:512', '--change-name=1:misc',
                     persistent)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
                 cmd = ('sgdisk', '--load-backup=' + persistent)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
 
         cmd = ('cp', persistent, self.path)
-        u_boot_utils.run_and_log(ubpy, cmd)
+        utils.run_and_log(ubpy, cmd)
 
 di = None
 @pytest.fixture(scope='function')
test/py/tests/test_android/test_abootimg.py +5 -5
index 3f3c467e804..a5f8cbb1a47 100644
@@ -6,7 +6,7 @@
 
 import os
 import pytest
-import u_boot_utils
+import utils
 
 """
 These tests rely on disk image (boot.img), which is automatically created by
@@ -122,7 +122,7 @@ class AbootimgTestDiskImage(object):
         persistent = ubpy.config.persistent_data_dir + '/' + filename
         self.path = ubpy.config.result_dir  + '/' + filename
         ubpy.log.action('persistent is ' + persistent)
-        with u_boot_utils.persistent_file_helper(ubpy.log, persistent):
+        with utils.persistent_file_helper(ubpy.log, persistent):
             if os.path.exists(persistent):
                 ubpy.log.action('Disk image file ' + persistent +
                     ' already exists')
@@ -133,12 +133,12 @@ class AbootimgTestDiskImage(object):
                 f.write(hex_img)
                 f.close()
                 cmd = ('xxd', '-r', '-p', gz_hex, gz)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
                 cmd = ('gunzip', '-9', gz)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
 
         cmd = ('cp', persistent, self.path)
-        u_boot_utils.run_and_log(ubpy, cmd)
+        utils.run_and_log(ubpy, cmd)
 
 gtdi1 = None
 @pytest.fixture(scope='function')
test/py/tests/test_android/test_avb.py +1 -1
index 71457f90563..33f3d60b867 100644
@@ -15,7 +15,7 @@ For configuration verification:
 """
 
 import pytest
-import u_boot_utils as util
+import utils as util
 
 # defauld mmc id
 mmc_dev = 1
test/py/tests/test_dfu.py +9 -9
index b2f86f95e76..ee91e95a347 100644
@@ -9,7 +9,7 @@
 import os
 import os.path
 import pytest
-import u_boot_utils
+import utils
 
 """
 Note: This test relies on:
@@ -143,9 +143,9 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
             Nothing.
         """
 
-        u_boot_utils.wait_until_file_open_fails(
+        utils.wait_until_file_open_fails(
             env__usb_dev_port['host_usb_dev_node'], True)
-        fh = u_boot_utils.attempt_to_open_file(
+        fh = utils.attempt_to_open_file(
             env__usb_dev_port['host_usb_dev_node'])
         if fh:
             fh.close()
@@ -164,7 +164,7 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
         cmd = 'dfu 0 ' + env__dfu_config['cmd_params']
         ubpy.run_command(cmd, wait_for_prompt=False)
         ubpy.log.action('Waiting for DFU USB device to appear')
-        fh = u_boot_utils.wait_until_open_succeeds(
+        fh = utils.wait_until_open_succeeds(
             env__usb_dev_port['host_usb_dev_node'])
         fh.close()
 
@@ -190,7 +190,7 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
             ubpy.ctrlc()
             ubpy.log.action(
                 'Waiting for DFU USB device to disappear')
-            u_boot_utils.wait_until_file_open_fails(
+            utils.wait_until_file_open_fails(
                 env__usb_dev_port['host_usb_dev_node'], ignore_errors)
         except:
             if not ignore_errors:
@@ -213,7 +213,7 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
         cmd = ['dfu-util', '-a', alt_setting, up_dn_load_arg, fn]
         if 'host_usb_port_path' in env__usb_dev_port:
             cmd += ['-p', env__usb_dev_port['host_usb_port_path']]
-        u_boot_utils.run_and_log(ubpy, cmd)
+        utils.run_and_log(ubpy, cmd)
         ubpy.wait_for('Ctrl+C to exit ...')
 
     def dfu_write(alt_setting, fn):
@@ -261,7 +261,7 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
             Nothing.
         """
 
-        test_f = u_boot_utils.PersistentRandomFile(ubpy,
+        test_f = utils.PersistentRandomFile(ubpy,
             'dfu_%d.bin' % size, size)
         readback_fn = ubpy.config.result_dir + '/dfu_readback.bin'
 
@@ -279,7 +279,7 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
 
         ubpy.log.action('Comparing written and read data')
         written_hash = test_f.content_hash
-        read_back_hash = u_boot_utils.md5sum_file(readback_fn, size)
+        read_back_hash = utils.md5sum_file(readback_fn, size)
         assert(written_hash == read_back_hash)
 
     # This test may be executed against multiple USB ports. The test takes a
@@ -295,7 +295,7 @@ def test_dfu(ubpy, env__usb_dev_port, env__dfu_config):
     else:
         sizes = []
 
-    dummy_f = u_boot_utils.PersistentRandomFile(ubpy,
+    dummy_f = utils.PersistentRandomFile(ubpy,
         'dfu_dummy.bin', 1024)
 
     alt_setting_test_file = env__dfu_config.get('alt_id_test_file', '0')
test/py/tests/test_efi_fit.py +1 -1
index fc57536821d..934f3fb2a7b 100644
@@ -55,7 +55,7 @@ env__efi_fit_tftp_file = {
 
 import os.path
 import pytest
-import u_boot_utils as util
+import utils as util
 
 # Define the parametrized ITS data to be used for FIT images generation.
 ITS_DATA = '''
test/py/tests/test_efi_loader.py +2 -2
index f654a18bd69..0f7fc2caddf 100644
@@ -53,7 +53,7 @@ env__efi_helloworld_net_http_test_skip = True
 """
 
 import pytest
-import u_boot_utils
+import utils
 
 PROTO_TFTP, PROTO_HTTP = range(0, 2)
 
@@ -132,7 +132,7 @@ def fetch_file(ubpy, env_conf, proto):
 
     addr = f.get('addr', None)
     if not addr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     fn = f['fn']
     if proto == PROTO_TFTP:
test/py/tests/test_env.py +12 -12
index f25504550b3..255d5779932 100644
@@ -13,7 +13,7 @@ from subprocess import call, CalledProcessError
 import tempfile
 
 import pytest
-import u_boot_utils
+import utils
 
 # FIXME: This might be useful for other tests;
 # perhaps refactor it into ConsoleBase or some other state object?
@@ -187,7 +187,7 @@ def test_env_initial_env_file(ubpy):
     except:
         pass
 
-    u_boot_utils.run_and_log(cons, ['make', builddir, 'u-boot-initial-env'])
+    utils.run_and_log(cons, ['make', builddir, 'u-boot-initial-env'])
 
     assert os.path.exists(envfile)
 
@@ -278,7 +278,7 @@ def test_env_import_checksum_no_size(state_test_env):
        env import function.
     """
     c = state_test_env.ubpy
-    ram_base = u_boot_utils.find_ram_base(state_test_env.ubpy)
+    ram_base = utils.find_ram_base(state_test_env.ubpy)
     addr = '%08x' % ram_base
 
     with c.disable_check('error_notification'):
@@ -291,7 +291,7 @@ def test_env_import_whitelist_checksum_no_size(state_test_env):
        env import function when variables are passed as parameters.
     """
     c = state_test_env.ubpy
-    ram_base = u_boot_utils.find_ram_base(state_test_env.ubpy)
+    ram_base = utils.find_ram_base(state_test_env.ubpy)
     addr = '%08x' % ram_base
 
     with c.disable_check('error_notification'):
@@ -303,7 +303,7 @@ def test_env_import_whitelist_checksum_no_size(state_test_env):
 def test_env_import_whitelist(state_test_env):
     """Test importing only a handful of env variables from an environment."""
     c = state_test_env.ubpy
-    ram_base = u_boot_utils.find_ram_base(state_test_env.ubpy)
+    ram_base = utils.find_ram_base(state_test_env.ubpy)
     addr = '%08x' % ram_base
 
     set_var(state_test_env, 'foo1', 'bar1')
@@ -340,7 +340,7 @@ def test_env_import_whitelist_delete(state_test_env):
        environment to be imported.
     """
     c = state_test_env.ubpy
-    ram_base = u_boot_utils.find_ram_base(state_test_env.ubpy)
+    ram_base = utils.find_ram_base(state_test_env.ubpy)
     addr = '%08x' % ram_base
 
     set_var(state_test_env, 'foo1', 'bar1')
@@ -446,16 +446,16 @@ def mk_env_ext4(state_test_env):
         # Some distributions do not add /sbin to the default PATH, where mkfs.ext4 lives
         os.environ["PATH"] += os.pathsep + '/sbin'
         try:
-            u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
-            u_boot_utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
-            sb_content = u_boot_utils.run_and_log(c, 'tune2fs -l %s' % persistent)
+            utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent)
+            utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
+            sb_content = utils.run_and_log(c, 'tune2fs -l %s' % persistent)
             if 'metadata_csum' in sb_content:
-                u_boot_utils.run_and_log(c, 'tune2fs -O ^metadata_csum %s' % persistent)
+                utils.run_and_log(c, 'tune2fs -O ^metadata_csum %s' % persistent)
         except CalledProcessError:
             call('rm -f %s' % persistent, shell=True)
             raise
 
-    u_boot_utils.run_and_log(c, ['cp',  '-f', persistent, fs_img])
+    utils.run_and_log(c, ['cp',  '-f', persistent, fs_img])
     return fs_img
 
 @pytest.mark.boardspec('sandbox')
@@ -560,7 +560,7 @@ def test_env_text(ubpy):
             fname = os.path.join(path, 'infile')
             with open(fname, 'w') as inf:
                 print(intext, file=inf)
-            result = u_boot_utils.run_and_log(cons, ['awk', '-f', script, fname])
+            result = utils.run_and_log(cons, ['awk', '-f', script, fname])
             if expect_val is not None:
                 expect = '#define CONFIG_EXTRA_ENV_TEXT "%s"\n' % expect_val
                 assert result == expect
test/py/tests/test_event_dump.py +1 -1
index 51cc9a3a211..6a3ac795ac0 100644
@@ -4,7 +4,7 @@
 
 import pytest
 import re
-import u_boot_utils as util
+import utils as util
 
 # This is only a partial test - coverting 64-bit sandbox. It does not test
 # big-endian images, nor 32-bit images
test/py/tests/test_extension.py +1 -1
index cb470c1c951..4e678d59bef 100644
@@ -6,7 +6,7 @@
 
 import os
 import pytest
-import u_boot_utils
+import utils
 
 overlay_addr = 0x1000
 
test/py/tests/test_fit.py +1 -1
index bbf2eab33e3..ca3249c913d 100755
@@ -6,7 +6,7 @@
 import os
 import pytest
 import struct
-import u_boot_utils as util
+import utils as util
 import fit_util
 
 # Define a base ITS which we can adjust using % and a dictionary
test/py/tests/test_fit_auto_signed.py +1 -1
index 6b8f7d1848f..038cb2d10ce 100644
@@ -17,7 +17,7 @@ The test does not run the sandbox. It only checks the host tool mkimage.
 
 import os
 import pytest
-import u_boot_utils as util
+import utils as util
 import binascii
 from Cryptodome.Hash import SHA1
 from Cryptodome.Hash import SHA256
test/py/tests/test_fit_ecdsa.py +1 -1
index e51120bc15c..79e633ac333 100644
@@ -12,7 +12,7 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage'
 
 import os
 import pytest
-import u_boot_utils as util
+import utils as util
 from Cryptodome.Hash import SHA256
 from Cryptodome.PublicKey import ECC
 from Cryptodome.Signature import DSS
test/py/tests/test_fit_hashes.py +1 -1
index 7b13c0e748c..fbc01f078b2 100644
@@ -12,7 +12,7 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage'
 
 import os
 import pytest
-import u_boot_utils as util
+import utils as util
 
 kernel_hashes = {
     "sha512" : "f18c1486a2c29f56360301576cdfce4dfd8e8e932d0ed8e239a1f314b8ae1d77b2a58cd7fe32e4075e69448e623ce53b0b6aa6ce5626d2c189a5beae29a68d93",
test/py/tests/test_fpga.py +4 -4
index 5b146d0a2a4..a2e19f7f76d 100644
@@ -8,7 +8,7 @@
 import pytest
 import re
 import random
-import u_boot_utils
+import utils
 
 """
 Note: This test relies on boardenv_* containing configuration values to define
@@ -518,7 +518,7 @@ def test_fpga_secure_bit_auth(ubpy):
 
     addr = f.get('addr', None)
     if not addr:
-      addr = u_boot_utils.find_ram_base(ubpy)
+      addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fn = f['fn']
@@ -546,7 +546,7 @@ def test_fpga_secure_bit_img_auth_kup(ubpy):
 
     keyaddr = f.get('keyaddr', None)
     if not keyaddr:
-      addr = u_boot_utils.find_ram_base(ubpy)
+      addr = utils.find_ram_base(ubpy)
     expected_tftp = 'Bytes transferred = '
     keyfn = f['keyfn']
     output = ubpy.run_command('tftpboot %x %s' % (keyaddr, keyfn))
@@ -554,7 +554,7 @@ def test_fpga_secure_bit_img_auth_kup(ubpy):
 
     addr = f.get('addr', None)
     if not addr:
-      addr = u_boot_utils.find_ram_base(ubpy)
+      addr = utils.find_ram_base(ubpy)
     expected_tftp = 'Bytes transferred = '
     fn = f['enckupfn']
     output = ubpy.run_command('tftpboot %x %s' % (addr, fn))
test/py/tests/test_fs/conftest.py +1 -1
index af2adaf1645..ea25cc75aac 100644
@@ -8,7 +8,7 @@ import pytest
 import re
 from subprocess import call, check_call, check_output, CalledProcessError
 from fstest_defs import *
-import u_boot_utils as util
+import utils as util
 # pylint: disable=E0611
 from tests import fs_helper
 
test/py/tests/test_gpio.py +1 -1
index 1b30fb4726f..d6ebf40e841 100644
@@ -5,7 +5,7 @@
 
 import pytest
 import time
-import u_boot_utils
+import utils
 
 """
 	test_gpio_input is intended to test the fix 4dbc107f4683.
test/py/tests/test_gpt.py +7 -7
index 530545c151d..f312e9ece87 100644
@@ -6,7 +6,7 @@
 
 import os
 import pytest
-import u_boot_utils
+import utils
 
 """
 These tests rely on a 4 MB disk image, which is automatically created by
@@ -63,7 +63,7 @@ class GptTestDiskImage(object):
         persistent = ubpy.config.persistent_data_dir + '/' + filename
         self.path = ubpy.config.result_dir  + '/' + filename
 
-        with u_boot_utils.persistent_file_helper(ubpy.log, persistent):
+        with utils.persistent_file_helper(ubpy.log, persistent):
             if os.path.exists(persistent):
                 ubpy.log.action('Disk image file ' + persistent +
                     ' already exists')
@@ -75,23 +75,23 @@ class GptTestDiskImage(object):
                 cmd = ('sgdisk',
                     '--disk-guid=375a56f7-d6c9-4e81-b5f0-09d41ca89efe',
                     persistent)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
                 # part1 offset 1MB size 1MB
                 cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1',
                     '--partition-guid=1:33194895-67f6-4561-8457-6fdeed4f50a3',
                     '-A 1:set:2',
                     persistent)
                 # part2 offset 2MB size 1.5MB
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
                 cmd = ('sgdisk', '--new=2:4096:7167', '--change-name=2:part2',
                     '--partition-guid=2:cc9c6e4a-6551-4cb5-87be-3210f96c86fb',
                     persistent)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
                 cmd = ('sgdisk', '--load-backup=' + persistent)
-                u_boot_utils.run_and_log(ubpy, cmd)
+                utils.run_and_log(ubpy, cmd)
 
         cmd = ('cp', persistent, self.path)
-        u_boot_utils.run_and_log(ubpy, cmd)
+        utils.run_and_log(ubpy, cmd)
 
 @pytest.fixture(scope='function')
 def state_disk_image(ubpy):
test/py/tests/test_kconfig.py +1 -1
index bd1f75a795f..cd54ac58f83 100644
@@ -4,7 +4,7 @@
 
 import pytest
 
-import u_boot_utils as util
+import utils as util
 
 # This is needed for Azure, since the default '..' directory is not writeable
 TMPDIR = '/tmp/test_kconfig'
test/py/tests/test_md.py +3 -3
index 550a367d076..84e206441d9 100644
@@ -3,14 +3,14 @@
 # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
 
 import pytest
-import u_boot_utils
+import utils
 
 @pytest.mark.buildconfigspec('cmd_memory')
 def test_md(ubpy):
     """Test that md reads memory as expected, and that memory can be modified
     using the mw command."""
 
-    ram_base = u_boot_utils.find_ram_base(ubpy)
+    ram_base = utils.find_ram_base(ubpy)
     addr = '%08x' % ram_base
     val = 'a5f09876'
     expected_response = addr + ': ' + val
@@ -26,7 +26,7 @@ def test_md_repeat(ubpy):
     """Test command repeat (via executing an empty command) operates correctly
     for "md"; the command must repeat and dump an incrementing address."""
 
-    ram_base = u_boot_utils.find_ram_base(ubpy)
+    ram_base = utils.find_ram_base(ubpy)
     addr_base = '%08x' % ram_base
     words = 0x10
     addr_repeat = '%08x' % (ram_base + (words * 4))
test/py/tests/test_mmc.py +4 -4
index ad7faaff5f0..d1f38ac3d63 100644
@@ -4,7 +4,7 @@
 import pytest
 import random
 import re
-import u_boot_utils
+import utils
 
 """
 Note: This test doesn't rely on boardenv_* configuration values but it can
@@ -290,7 +290,7 @@ def test_mmc_fatload_fatwrite(ubpy):
                 for y in mmc_modes:
                     ubpy.run_command('mmc dev %d %d %d' % x, part, y)
                     part_detect = 1
-                    addr = u_boot_utils.find_ram_base(ubpy)
+                    addr = utils.find_ram_base(ubpy)
                     devices[x]['addr_%d' % part] = addr
                     size = random.randint(4, 1 * 1024 * 1024)
                     devices[x]['size_%d' % part] = size
@@ -394,7 +394,7 @@ def test_mmc_ext4load_ext4write(ubpy):
                 for y in mmc_modes:
                     ubpy.run_command('mmc dev %d %d %d' % x, part, y)
                     part_detect = 1
-                    addr = u_boot_utils.find_ram_base(ubpy)
+                    addr = utils.find_ram_base(ubpy)
                     devices[x]['addr_%d' % part] = addr
                     size = random.randint(4, 1 * 1024 * 1024)
                     devices[x]['size_%d' % part] = size
@@ -658,7 +658,7 @@ def test_mmc_fat_read_write_files(ubpy):
                 for y in mmc_modes:
                     ubpy.run_command('mmc dev %d %d %d' % x, part, y)
                     part_detect = 1
-                    addr = u_boot_utils.find_ram_base(ubpy)
+                    addr = utils.find_ram_base(ubpy)
                     count_f = 0
                     addr_l = []
                     size_l = []
test/py/tests/test_mmc_rd.py +2 -2
index 0fc5dbc05a3..5f61810f1e2 100644
@@ -7,7 +7,7 @@
 
 import pytest
 import time
-import u_boot_utils
+import utils
 
 """
 This test relies on boardenv_* to containing configuration values to define
@@ -241,7 +241,7 @@ def test_mmc_rd(ubpy, env__mmc_rd_config):
     bcfg = ubpy.config.buildconfig
     has_cmd_memory = bcfg.get('config_cmd_memory', 'n') == 'y'
     has_cmd_crc32 = bcfg.get('config_cmd_crc32', 'n') == 'y'
-    ram_base = u_boot_utils.find_ram_base(ubpy)
+    ram_base = utils.find_ram_base(ubpy)
     addr = '0x%08x' % ram_base
 
     # Select MMC device
test/py/tests/test_mmc_wr.py +2 -2
index 2b278cb21cd..062ad8c4d0a 100644
@@ -6,7 +6,7 @@
 # to the eMMC or SD card, then reads it back and performs a comparison.
 
 import pytest
-import u_boot_utils
+import utils
 
 """
 This test relies on boardenv_* to containing configuration values to define
@@ -61,7 +61,7 @@ def test_mmc_wr(ubpy, env__mmc_wr_config):
 
     count_bytes = count_sectors * 512
     bcfg = ubpy.config.buildconfig
-    ram_base = u_boot_utils.find_ram_base(ubpy)
+    ram_base = utils.find_ram_base(ubpy)
     src_addr = '0x%08x' % ram_base
     dst_addr = '0x%08x' % (ram_base + count_bytes)
 
test/py/tests/test_net.py +3 -3
index 1c31a9d4727..bdb7e6f372d 100644
@@ -5,7 +5,7 @@
 # tftpboot commands.
 
 import pytest
-import u_boot_utils
+import utils
 import uuid
 import datetime
 import re
@@ -315,7 +315,7 @@ def test_net_nfs(ubpy):
 
     addr = f.get('addr', None)
     if not addr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     fn = f['fn']
     output = ubpy.run_command('nfs %x %s' % (addr, fn))
@@ -411,7 +411,7 @@ def test_net_tftpput(ubpy):
 
     addr = f.get("addr", None)
     if not addr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     sz = f.get("size", None)
     timeout = f.get("timeout", ubpy.p.timeout)
test/py/tests/test_net_boot.py +2 -2
index 025bad7c893..20153b94a2f 100644
@@ -2,7 +2,7 @@
 # (C) Copyright 2023, Advanced Micro Devices, Inc.
 
 import pytest
-import u_boot_utils
+import utils
 import test_net
 import re
 
@@ -130,7 +130,7 @@ def setup_tftpboot_boot(ubpy):
     setup_networking(ubpy)
     addr = f.get('addr', None)
     if not addr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     fn = f['fn']
     timeout = f.get('timeout', 50000)
test/py/tests/test_of_migrate.py +1 -1
index 274ea455f9f..ca6627a115d 100644
@@ -7,7 +7,7 @@
 import os
 import pytest
 
-import u_boot_utils as util
+import utils as util
 
 # This is needed for Azure, since the default '..' directory is not writeable
 TMPDIR1 = '/tmp/test_no_migrate'
test/py/tests/test_ofplatdata.py +1 -1
index 391d475ca90..cb9be2eca50 100644
@@ -2,7 +2,7 @@
 # Copyright (c) 2016 Google, Inc
 
 import pytest
-import u_boot_utils as util
+import utils as util
 
 @pytest.mark.boardspec('sandbox_spl')
 @pytest.mark.buildconfigspec('spl_of_platdata')
test/py/tests/test_optee_rpmb.py +1 -1
index 8940d4a3073..08068bd9f1d 100644
@@ -7,7 +7,7 @@ This tests optee_rpmb cmd in U-Boot
 """
 
 import pytest
-import u_boot_utils as util
+import utils as util
 
 @pytest.mark.buildconfigspec('cmd_optee_rpmb')
 def test_optee_rpmb_read_write(ubpy):
test/py/tests/test_pinmux.py +1 -1
index e599d2f38fe..c171700d5f7 100644
@@ -1,7 +1,7 @@
 # SPDX-License-Identifier: GPL-2.0
 
 import pytest
-import u_boot_utils
+import utils
 
 @pytest.mark.buildconfigspec('cmd_pinmux')
 def test_pinmux_usage_1(ubpy):
test/py/tests/test_pstore.py +1 -1
index 91bbe16a2ac..a66dcc13eda 100644
@@ -3,7 +3,7 @@
 # Author: Frédéric Danis <[email protected]>
 
 import pytest
-import u_boot_utils
+import utils
 import os
 import tempfile
 import shutil
test/py/tests/test_sandbox_opts.py +1 -1
index a0231f6d453..1c1c77f0f98 100644
@@ -4,7 +4,7 @@
 
 import pytest
 
-import u_boot_utils as util
+import utils as util
 
 # This is needed for Azure, since the default '..' directory is not writeable
 TMPDIR = '/tmp/test_cmdline'
test/py/tests/test_scp03.py +1 -1
index 3ff6c0a2602..3ceabdc6a21 100644
@@ -11,7 +11,7 @@ For additional details check doc/usage/scp03.rst
 """
 
 import pytest
-import u_boot_utils as util
+import utils as util
 
 @pytest.mark.buildconfigspec('cmd_scp03')
 def test_scp03(ubpy):
test/py/tests/test_sf.py +6 -6
index 0e9ea0c422f..b5f82f482d5 100644
@@ -5,7 +5,7 @@
 import re
 import pytest
 import random
-import u_boot_utils
+import utils
 
 """
 Note: This test relies on boardenv_* containing configuration values to define
@@ -57,7 +57,7 @@ def sf_prepare(ubpy, env__sf_config):
     """
 
     sf_params = {}
-    sf_params['ram_base'] = u_boot_utils.find_ram_base(ubpy)
+    sf_params['ram_base'] = utils.find_ram_base(ubpy)
 
     probe_id = env__sf_config.get('id', 0)
     speed = env__sf_config.get('speed', 0)
@@ -123,14 +123,14 @@ def sf_read(ubpy, env__sf_config, sf_params):
 
     cmd = 'mw.b %08x %02x %x' % (addr, pattern, count)
     ubpy.run_command(cmd)
-    crc_pattern = u_boot_utils.crc32(ubpy, addr, count)
+    crc_pattern = utils.crc32(ubpy, addr, count)
     if crc_expected:
         assert crc_pattern != crc_expected
 
     cmd = 'sf read %08x %08x %x' % (addr, offset, count)
     response = ubpy.run_command(cmd)
     assert 'Read: OK' in response, 'Read operation failed'
-    crc_readback = u_boot_utils.crc32(ubpy, addr, count)
+    crc_readback = utils.crc32(ubpy, addr, count)
     assert crc_pattern != crc_readback, 'sf read did not update RAM content.'
     if crc_expected:
         assert crc_readback == crc_expected
@@ -156,7 +156,7 @@ def sf_update(ubpy, env__sf_config, sf_params):
 
     cmd = 'mw.b %08x %02x %x' % (addr, pattern, count)
     ubpy.run_command(cmd)
-    crc_pattern = u_boot_utils.crc32(ubpy, addr, count)
+    crc_pattern = utils.crc32(ubpy, addr, count)
 
     cmd = 'sf update %08x %08x %x' % (addr, offset, count)
     ubpy.run_command(cmd)
@@ -201,7 +201,7 @@ def test_sf_erase(ubpy, env__sf_config):
 
     cmd = 'mw.b %08x ff %x' % (addr, count)
     ubpy.run_command(cmd)
-    crc_ffs = u_boot_utils.crc32(ubpy, addr, count)
+    crc_ffs = utils.crc32(ubpy, addr, count)
 
     crc_read = sf_read(ubpy, env__sf_config, sf_params)
     assert crc_ffs == crc_read, 'Unexpected CRC32 after erase operation.'
test/py/tests/test_source.py +1 -1
index 66539cf89c1..1ea50325ef0 100644
@@ -3,7 +3,7 @@
 
 import os
 import pytest
-import u_boot_utils as util
+import utils as util
 
 @pytest.mark.boardspec('sandbox')
 @pytest.mark.buildconfigspec('cmd_echo')
test/py/tests/test_spi.py +7 -7
index 414d44bed1b..c08a2349ca9 100644
@@ -51,7 +51,7 @@ env__spi_lock_unlock = {
 import random
 import re
 import pytest
-import u_boot_utils
+import utils
 
 SPI_DATA = {}
 EXPECTED_ERASE = 'Erased: OK'
@@ -200,7 +200,7 @@ def test_spi_erase_block(ubpy):
 
 def spi_write_twice(ubpy, page_size, erase_size, total_size, timeout):
     ''' Random write till page size, random till size and full size '''
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
 
     old_size = 0
     for size in (
@@ -273,7 +273,7 @@ def test_spi_write_twice(ubpy):
 def spi_write_continues(ubpy, page_size, erase_size, total_size, timeout):
     ''' Write with random size of data to continue SPI write case '''
     spi_erase_block(ubpy, erase_size, total_size)
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
 
     output = ubpy.run_command(f'crc32 {hex(addr + 0x10000)} {hex(total_size)}')
     m = re.search('==> (.+?)$', output)
@@ -329,7 +329,7 @@ def spi_read_twice(ubpy, page_size, total_size, timeout):
     ''' Read the whole SPI flash twice, random_size till full flash size,
     random till page size '''
     for size in random.randint(4, page_size), random.randint(4, total_size), total_size:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
         size = size & ~3
         with ubpy.temporary_timeout(timeout):
             output = ubpy.run_command(
@@ -453,13 +453,13 @@ def protect_ops(ubpy, lock_addr, lock_size, ops="unlock"):
 
 def erase_write_ops(ubpy, start, size):
     ''' Basic erase and write operation for flash '''
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
     flash_ops(ubpy, 'erase', start, size, 0, 0, EXPECTED_ERASE)
     flash_ops(ubpy, 'write', start, size, addr, 0, EXPECTED_WRITE)
 
 def spi_lock_unlock(ubpy, lock_addr, lock_size):
     ''' Lock unlock operations for SPI family flash '''
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
     erase_size = get_erase_size()
 
     # Find the protected/un-protected region
@@ -614,7 +614,7 @@ def test_spi_negative(ubpy):
     total_size = get_total_size()
     erase_size = get_erase_size()
     page_size = get_page_size()
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
     i = 0
     while i < loop:
         # Erase negative test
test/py/tests/test_tpm2.py +5 -5
index 418a974227e..3dea9323835 100644
@@ -4,7 +4,7 @@
 
 import os.path
 import pytest
-import u_boot_utils
+import utils
 import re
 import time
 
@@ -197,7 +197,7 @@ def test_tpm2_get_capability(ubpy):
         tpm2_sandbox_init(ubpy)
 
     force_init(ubpy)
-    ram = u_boot_utils.find_ram_base(ubpy)
+    ram = utils.find_ram_base(ubpy)
 
     read_cap = ubpy.run_command('tpm2 get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram)
     output = ubpy.run_command('echo $?')
@@ -220,7 +220,7 @@ def test_tpm2_dam_parameters(ubpy):
     if is_sandbox(ubpy):
         tpm2_sandbox_init(ubpy)
     force_init(ubpy)
-    ram = u_boot_utils.find_ram_base(ubpy)
+    ram = utils.find_ram_base(ubpy)
 
     # Set the DAM parameters to known values
     ubpy.run_command('tpm2 dam_parameters 3 10 0')
@@ -245,7 +245,7 @@ def test_tpm2_pcr_read(ubpy):
         tpm2_sandbox_init(ubpy)
 
     force_init(ubpy)
-    ram = u_boot_utils.find_ram_base(ubpy)
+    ram = utils.find_ram_base(ubpy)
 
     read_pcr = ubpy.run_command('tpm2 pcr_read 10 0x%x' % ram)
     output = ubpy.run_command('echo $?')
@@ -273,7 +273,7 @@ def test_tpm2_pcr_extend(ubpy):
     if is_sandbox(ubpy):
         tpm2_sandbox_init(ubpy)
     force_init(ubpy)
-    ram = u_boot_utils.find_ram_base(ubpy)
+    ram = utils.find_ram_base(ubpy)
 
     read_pcr = ubpy.run_command('tpm2 pcr_read 10 0x%x' % (ram + 0x20))
     output = ubpy.run_command('echo $?')
test/py/tests/test_trace.py +1 -1
index 86541c96e0d..51a7171eeb3 100644
@@ -6,7 +6,7 @@ import os
 import pytest
 import re
 
-import u_boot_utils as util
+import utils as util
 
 # This is needed for Azure, since the default '..' directory is not writeable
 TMPDIR = '/tmp/test_trace'
test/py/tests/test_ums.py +10 -10
index 0078f9568f6..dec4e75d1d8 100644
@@ -11,7 +11,7 @@ import os.path
 import pytest
 import re
 import time
-import u_boot_utils
+import utils
 
 """
 Note: This test relies on:
@@ -116,7 +116,7 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
     else:
         host_ums_part_node = host_ums_dev_node
 
-    test_f = u_boot_utils.PersistentRandomFile(ubpy, 'ums.bin',
+    test_f = utils.PersistentRandomFile(ubpy, 'ums.bin',
         1024 * 1024);
     if have_writable_fs_partition:
         mounted_test_fn = mount_point + '/' + mount_subdir + test_f.fn
@@ -138,7 +138,7 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
         cmd = 'ums %s %s %s' % (tgt_usb_ctlr, tgt_dev_type, tgt_dev_id)
         ubpy.run_command(cmd, wait_for_prompt=False)
         ubpy.wait_for(re.compile('UMS: LUN.*[\r\n]'))
-        fh = u_boot_utils.wait_until_open_succeeds(host_ums_part_node)
+        fh = utils.wait_until_open_succeeds(host_ums_part_node)
         ubpy.log.action('Reading raw data from UMS device')
         fh.read(4096)
         fh.close()
@@ -155,7 +155,7 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
 
         ubpy.log.action('Mounting exported UMS device')
         cmd = ('/bin/mount', host_ums_part_node)
-        u_boot_utils.run_and_log(ubpy, cmd)
+        utils.run_and_log(ubpy, cmd)
 
     def umount(ignore_errors):
         """Unmount the block device that U-Boot exports.
@@ -172,7 +172,7 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
 
         ubpy.log.action('Unmounting UMS device')
         cmd = ('/bin/umount', host_ums_part_node)
-        u_boot_utils.run_and_log(ubpy, cmd, ignore_errors)
+        utils.run_and_log(ubpy, cmd, ignore_errors)
 
     def stop_ums(ignore_errors):
         """Stop U-Boot's ums shell command from executing.
@@ -193,7 +193,7 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
         ubpy.log.action(
             'Stopping long-running U-Boot ums shell command')
         ubpy.ctrlc()
-        u_boot_utils.wait_until_file_open_fails(host_ums_part_node,
+        utils.wait_until_file_open_fails(host_ums_part_node,
             ignore_errors)
 
     ignore_cleanup_errors = True
@@ -206,11 +206,11 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
             mount()
             ubpy.log.action('Writing test file via UMS')
             cmd = ('rm', '-f', mounted_test_fn)
-            u_boot_utils.run_and_log(ubpy, cmd)
+            utils.run_and_log(ubpy, cmd)
             if os.path.exists(mounted_test_fn):
                 raise Exception('Could not rm target UMS test file')
             cmd = ('cp', test_f.abs_fn, mounted_test_fn)
-            u_boot_utils.run_and_log(ubpy, cmd)
+            utils.run_and_log(ubpy, cmd)
             ignore_cleanup_errors = False
         finally:
             umount(ignore_errors=ignore_cleanup_errors)
@@ -223,9 +223,9 @@ def test_ums(ubpy, env__usb_dev_port, env__block_devs):
         try:
             mount()
             ubpy.log.action('Reading test file back via UMS')
-            read_back_hash = u_boot_utils.md5sum_file(mounted_test_fn)
+            read_back_hash = utils.md5sum_file(mounted_test_fn)
             cmd = ('rm', '-f', mounted_test_fn)
-            u_boot_utils.run_and_log(ubpy, cmd)
+            utils.run_and_log(ubpy, cmd)
             ignore_cleanup_errors = False
         finally:
             umount(ignore_errors=ignore_cleanup_errors)
test/py/tests/test_upl.py +1 -1
index 155e44ddcb6..287e107a885 100644
@@ -6,7 +6,7 @@
 import os
 
 import pytest
-import u_boot_utils
+import utils
 
 @pytest.mark.boardspec('sandbox_vpl')
 def test_upl_handoff(ubpy):
test/py/tests/test_usb.py +6 -6
index 0f6ac4c7d08..ba183252e45 100644
@@ -4,7 +4,7 @@
 import pytest
 import random
 import re
-import u_boot_utils
+import utils
 
 """
 Note: This test doesn't rely on boardenv_* configuration values but it can
@@ -296,7 +296,7 @@ def test_usb_fatls_fatinfo(ubpy):
         pytest.skip('No %s partition detected' % fs.upper())
 
 def usb_fatload_fatwrite(ubpy, fs, x, part):
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
     size = random.randint(4, 1 * 1024 * 1024)
     output = ubpy.run_command('crc32 %x %x' % (addr, size))
     m = re.search('==> (.+?)', output)
@@ -391,7 +391,7 @@ def test_usb_ext4ls(ubpy):
         pytest.skip('No %s partition detected' % fs.upper())
 
 def usb_ext4load_ext4write(ubpy, fs, x, part):
-    addr = u_boot_utils.find_ram_base(ubpy)
+    addr = utils.find_ram_base(ubpy)
     size = random.randint(4, 1 * 1024 * 1024)
     output = ubpy.run_command('crc32 %x %x' % (addr, size))
     m = re.search('==> (.+?)', output)
@@ -505,7 +505,7 @@ def test_usb_ext2load(ubpy):
                 part_detect = 1
                 file, size, expected_crc32 = \
                     usb_ext4load_ext4write(ubpy, fs, x, part)
-                addr = u_boot_utils.find_ram_base(ubpy)
+                addr = utils.find_ram_base(ubpy)
 
                 offset = random.randrange(128, 1024, 128)
                 output = ubpy.run_command(
@@ -572,7 +572,7 @@ def test_usb_load(ubpy):
 
                 for part in partitions:
                     part_detect = 1
-                    addr = u_boot_utils.find_ram_base(ubpy)
+                    addr = utils.find_ram_base(ubpy)
 
                     if fs == 'fat':
                         file, size, expected_crc32 = \
@@ -616,7 +616,7 @@ def test_usb_save(ubpy):
 
                 for part in partitions:
                     part_detect = 1
-                    addr = u_boot_utils.find_ram_base(ubpy)
+                    addr = utils.find_ram_base(ubpy)
                     size = random.randint(4, 1 * 1024 * 1024)
                     file = '%s_%d' % ('uboot_test', size)
 
test/py/tests/test_ut.py +43 -43

205 lines not on this page · raw message

test/py/tests/test_vbe_vpl.py +5 -5
index 7e25924e4e7..313c2f93e18 100644
@@ -6,7 +6,7 @@
 import os
 
 import pytest
-import u_boot_utils
+import utils
 
 @pytest.mark.boardspec('sandbox_vpl')
 @pytest.mark.requiredtool('dtc')
@@ -19,13 +19,13 @@ def test_vbe_vpl(ubpy):
 
     # Enable firmware1 and the mmc that it uses. These are needed for the full
     # VBE flow.
-    u_boot_utils.run_and_log(
+    utils.run_and_log(
         cons, f'fdtput -t s {fdt} /bootstd/firmware0 status disabled')
-    u_boot_utils.run_and_log(
+    utils.run_and_log(
         cons, f'fdtput -t s {fdt} /bootstd/firmware1 status okay')
-    u_boot_utils.run_and_log(
+    utils.run_and_log(
         cons, f'fdtput -t s {fdt} /mmc3 status okay')
-    u_boot_utils.run_and_log(
+    utils.run_and_log(
         cons, f'fdtput -t s {fdt} /mmc3 filename {image_fname}')
 
     # Remove any existing RAM file, so we don't have old data present
test/py/tests/test_vboot.py +1 -1
index 72472914f2c..ffc6477c173 100644
@@ -42,7 +42,7 @@ import os
 import shutil
 import struct
 import pytest
-import u_boot_utils as util
+import utils as util
 import vboot_forge
 import vboot_evil
 
test/py/tests/test_zynq_secure.py +6 -6
index 17b2ea39e8d..b1041d236bb 100644
@@ -3,7 +3,7 @@
 
 import pytest
 import re
-import u_boot_utils
+import utils
 import test_net
 
 """
@@ -68,7 +68,7 @@ def test_zynq_aes_image(ubpy):
 
     srcaddr = f.get('srcaddr', None)
     if not srcaddr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fn = f['fn']
@@ -96,7 +96,7 @@ def test_zynq_aes_bitstream(ubpy):
 
     srcaddr = f.get('srcaddr', None)
     if not srcaddr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fn = f['fnbit']
@@ -124,7 +124,7 @@ def test_zynq_aes_partial_bitstream(ubpy):
 
     srcaddr = f.get('srcaddr', None)
     if not srcaddr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fn = f['fnpbit']
@@ -150,7 +150,7 @@ def test_zynq_rsa_image(ubpy):
 
     srcaddr = f.get('srcaddr', None)
     if not srcaddr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fn = f['fn']
@@ -176,7 +176,7 @@ def test_zynq_rsa_image_invalid(ubpy):
 
     srcaddr = f.get('srcaddr', None)
     if not srcaddr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fninvalid = f['fninvalid']
test/py/tests/test_zynqmp_secure.py +4 -4
index e2b6ac5a221..c6ccc6ba0bc 100644
@@ -3,7 +3,7 @@
 
 import pytest
 import re
-import u_boot_utils
+import utils
 import test_net
 
 """
@@ -45,7 +45,7 @@ def test_zynqmp_secure_boot_image(ubpy):
 
     addr = f.get('addr', None)
     if not addr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
 
     expected_tftp = 'Bytes transferred = '
     fn = f['fn']
@@ -78,7 +78,7 @@ def test_zynqmp_secure_boot_img_kup(ubpy):
 
     keyaddr = f.get('keyaddr', None)
     if not keyaddr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
     expected_tftp = 'Bytes transferred = '
     keyfn = f['keyfn']
     output = ubpy.run_command('tftpboot %x %s' % (keyaddr, keyfn))
@@ -86,7 +86,7 @@ def test_zynqmp_secure_boot_img_kup(ubpy):
 
     addr = f.get('addr', None)
     if not addr:
-        addr = u_boot_utils.find_ram_base(ubpy)
+        addr = utils.find_ram_base(ubpy)
     expected_tftp = 'Bytes transferred = '
     fn = f['enckupfn']
     output = ubpy.run_command('tftpboot %x %s' % (addr, fn))
test/py/utils.py renamed from test/py/u_boot_utils.py +0 -0
similarity index 100%
rename from test/py/u_boot_utils.py
rename to test/py/utils.py
Signature · 1 line
2.43.0
#9 lore raw

Re: [PATCH 2/4] test: Drop u_boot_ prefix on test files

Quoted 4 lines · Simon Glass

We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files.

This is a massive bit of churn and violating namespace best practices when it seems like we really need:
[snip]

test/py/tests/fit_util.py line 8

Quoted 10 lines
test/py/tests/fit_util.py +1 -1
index 16ff8c96c63..7aad4030be3 100644
@@ -5,7 +5,7 @@
 
 import os
 
-import u_boot_utils as util
+import utils as util

A lot more of this type of namespace shortening which I believe is the normal Python-way of solving this issue.

Signature · 1 line
Tom
#10 lore raw

Re: [PATCH 2/4] test: Drop u_boot_ prefix on test files

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 4 lines · Simon Glass

We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files.

This is a massive bit of churn and violating namespace best practices when it seems like we really need:
[snip]

Quoted 6 lines
test/py/tests/fit_util.py +0 -0
index 16ff8c96c63..7aad4030be3 100644
@@ -5,7 +5,7 @@
 
Quoted 4 lines

test/py/tests/fit_util.py line 8

Quoted 4 lines
test/py/tests/fit_util.py +1 -1
 import os
 
-import u_boot_utils as util
+import utils as util

The real namespace is the one in site-packages, where you are supposed to put things in their own modules. The Python tools operate in a proper namespace, but so far the tests don't. They just use whatever directory the file is in. So, for example, we have:

from tests import fs_helper

where 'tests' is the subdir in test/py

One option would be to move the pytests up a directory, with test.py in test/ and the other python files in test/u-boot and the tests in test/pytests or something like that.

Then we would have:

from tests import some_file (*)

like we do in tools

Also, I wouldn't call this 'massive' churn. Most files just have a line or two changed, with test.py and test_ut.py getting more.

Quoted 3 lines

A lot more of this type of namespace shortening which I believe is the normal Python-way of solving this issue.

It doesn't really, since 'util' might conflict with something. When you have a set of related Python files, as with do in test/py it is better to use a namespace. But even then, I think we would want a shorter name.

Regards,
Simon

* "tests" is safe, I believe, since no modules use it it, e.g. it is mentioned here:

[1] https://docs.pytest.org/en/stable/explanation/goodpractices.html#tests-as-part-of-application-code

#11 lore raw

Re: [PATCH 2/4] test: Drop u_boot_ prefix on test files

Quoted 48 lines · Simon Glass

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 4 lines · Simon Glass

We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files.

This is a massive bit of churn and violating namespace best practices when it seems like we really need:
[snip]

Quoted 6 lines
test/py/tests/fit_util.py +0 -0
index 16ff8c96c63..7aad4030be3 100644
@@ -5,7 +5,7 @@
 
Quoted 4 lines

test/py/tests/fit_util.py line 8

Quoted 4 lines
test/py/tests/fit_util.py +1 -1
 import os
 
-import u_boot_utils as util
+import utils as util

The real namespace is the one in site-packages, where you are supposed to put things in their own modules. The Python tools operate in a proper namespace, but so far the tests don't. They just use whatever directory the file is in. So, for example, we have:

from tests import fs_helper

where 'tests' is the subdir in test/py

One option would be to move the pytests up a directory, with test.py in test/ and the other python files in test/u-boot and the tests in test/pytests or something like that.

Then we would have:

from tests import some_file (*)

like we do in tools

Also, I wouldn't call this 'massive' churn. Most files just have a line or two changed, with test.py and test_ut.py getting more.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

A lot more of this type of namespace shortening which I believe is the normal Python-way of solving this issue.

It doesn't really, since 'util' might conflict with something. When you have a set of related Python files, as with do in test/py it is better to use a namespace. But even then, I think we would want a shorter name.

Yes, I suppose I'd rather see (and without the ubpy rename, one thing at a time please!) moving files around such that we can then do more normal "from foo import bar", and also avoid the silly thing of "import utils at util" ;)

Signature · 1 line
Tom
#12 lore raw

Re: [PATCH 2/4] test: Drop u_boot_ prefix on test files

Hi Tom,

Quoted 58 lines · Tom Rini
Quoted 48 lines · Simon Glass

Hi Tom,

Quoted 17 lines · Tom Rini
Quoted 4 lines · Simon Glass

We know this is U-Boot so the prefix serves no purpose other than to make things longer and harder to read. Drop it and rename the files.

This is a massive bit of churn and violating namespace best practices when it seems like we really need:
[snip]

Quoted 6 lines
test/py/tests/fit_util.py +0 -0
index 16ff8c96c63..7aad4030be3 100644
@@ -5,7 +5,7 @@
 
Quoted 4 lines

test/py/tests/fit_util.py line 8

Quoted 4 lines
test/py/tests/fit_util.py +1 -1
 import os
 
-import u_boot_utils as util
+import utils as util

The real namespace is the one in site-packages, where you are supposed to put things in their own modules. The Python tools operate in a proper namespace, but so far the tests don't. They just use whatever directory the file is in. So, for example, we have:

from tests import fs_helper

where 'tests' is the subdir in test/py

One option would be to move the pytests up a directory, with test.py in test/ and the other python files in test/u-boot and the tests in test/pytests or something like that.

Then we would have:

from tests import some_file (*)

like we do in tools

Also, I wouldn't call this 'massive' churn. Most files just have a line or two changed, with test.py and test_ut.py getting more.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

A lot more of this type of namespace shortening which I believe is the normal Python-way of solving this issue.

It doesn't really, since 'util' might conflict with something. When you have a set of related Python files, as with do in test/py it is better to use a namespace. But even then, I think we would want a shorter name.

Quoted 4 lines

Yes, I suppose I'd rather see (and without the ubpy rename, one thing at a time please!) moving files around such that we can then do more normal "from foo import bar", and also avoid the silly thing of "import utils at util" ;)

Yes, OK.

Regards,
Simon

#13 lore raw

PATCH 3/4 test/py: Show info about module-loading

In reply to Simon Glass

It is sometimes tricky to figure out what modules test.py is loading when it starts up. The result can be a silent failure with no clue as to what when wrong.

Add a section which lists the modules loaded as well as those not found.

---

 test/py/conftest.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +20 -13
index 5096c20ed65..23435b7db3c 100644
@@ -286,19 +286,26 @@ def pytest_configure(config):
     ubconfig = ArbitraryAttributeContainer()
     ubconfig.brd = dict()
     ubconfig.env = dict()
-
-    modules = [
-        (ubconfig.brd, 'u_boot_board_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
-            board_identity_filename),
-    ]
-    for (dict_to_fill, module_name) in modules:
-        try:
-            module = __import__(module_name)
-        except ImportError:
-            continue
-        dict_to_fill.update(module.__dict__)
+    not_found = []
+
+    with log.section('Loading lab modules', 'load_modules'):
+        modules = [
+            (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+                board_identity_filename),
+        ]
+        for (dict_to_fill, module_name) in modules:
+            try:
+                module = __import__(module_name)
+            except ImportError:
+                not_found.append(module_name)
+                continue
+            dict_to_fill.update(module.__dict__)
+            log.info(f"Loaded {module}")
+
+        if not_found:
+            log.warning(f"Failed to find modules: {' '.join(not_found)}")
 
     ubconfig.buildconfig = dict()
 
Signature · 1 line
2.43.0
#14 lore raw

Re: [PATCH 3/4] test/py: Show info about module-loading

Quoted 46 lines · Simon Glass

It is sometimes tricky to figure out what modules test.py is loading when it starts up. The result can be a silent failure with no clue as to what when wrong.

Add a section which lists the modules loaded as well as those not found.

---

 test/py/conftest.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +12 -13
index 5096c20ed65..23435b7db3c 100644
@@ -286,19 +286,26 @@ def pytest_configure(config):
     ubconfig = ArbitraryAttributeContainer()
     ubconfig.brd = dict()
     ubconfig.env = dict()
-
-    modules = [
-        (ubconfig.brd, 'u_boot_board_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
-            board_identity_filename),
-    ]
-    for (dict_to_fill, module_name) in modules:
-        try:
-            module = __import__(module_name)
-        except ImportError:
-            continue
-        dict_to_fill.update(module.__dict__)
+    not_found = []
+
+    with log.section('Loading lab modules', 'load_modules'):
+        modules = [
+            (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+                board_identity_filename),
+        ]
+        for (dict_to_fill, module_name) in modules:
+            try:
+                module = __import__(module_name)

test/py/conftest.py def pytest_configure(config): · line 310

Quoted 10 lines
test/py/conftest.py +8 -0
+            except ImportError:
+                not_found.append(module_name)
+                continue
+            dict_to_fill.update(module.__dict__)
+            log.info(f"Loaded {module}")
+
+        if not_found:
+            log.warning(f"Failed to find modules: {' '.join(not_found)}")
 
     ubconfig.buildconfig = dict()

We won't see this warning normally, only if some level of verbosity is used, yes? It's normal to not have both u_boot_boardenv files for example.

Signature · 1 line
Tom
#15 lore raw

Re: [PATCH 3/4] test/py: Show info about module-loading

Hi Tom,

Quoted 57 lines · Tom Rini
Quoted 55 lines · Simon Glass

It is sometimes tricky to figure out what modules test.py is loading when it starts up. The result can be a silent failure with no clue as to what when wrong.

Add a section which lists the modules loaded as well as those not found.

---

 test/py/conftest.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +20 -13
index 5096c20ed65..23435b7db3c 100644
@@ -286,19 +286,26 @@ def pytest_configure(config):
     ubconfig = ArbitraryAttributeContainer()
     ubconfig.brd = dict()
     ubconfig.env = dict()
-
-    modules = [
-        (ubconfig.brd, 'u_boot_board_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
-            board_identity_filename),
-    ]
-    for (dict_to_fill, module_name) in modules:
-        try:
-            module = __import__(module_name)
-        except ImportError:
-            continue
-        dict_to_fill.update(module.__dict__)
+    not_found = []
+
+    with log.section('Loading lab modules', 'load_modules'):
+        modules = [
+            (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+                board_identity_filename),
+        ]
+        for (dict_to_fill, module_name) in modules:
+            try:
+                module = __import__(module_name)
+            except ImportError:
+                not_found.append(module_name)
+                continue
+            dict_to_fill.update(module.__dict__)
+            log.info(f"Loaded {module}")
+
+        if not_found:
+            log.warning(f"Failed to find modules: {' '.join(not_found)}")
 
Quoted 5 lines

test/py/conftest.py def pytest_configure(config): · line 310

Quoted 1 line
test/py/conftest.py +0 -0
     ubconfig.buildconfig = dict()

We won't see this warning normally, only if some level of verbosity is used, yes? It's normal to not have both u_boot_boardenv files for example.

There is a '[-] Section: Loading lab modules' section so you only see it if you open that.

I feel that test.py is a bit cryptic at present.

Regards,
Simon

#16 lore raw

Re: [PATCH 3/4] test/py: Show info about module-loading

Quoted 66 lines · Simon Glass

Hi Tom,

Quoted 57 lines · Tom Rini
Quoted 55 lines · Simon Glass

It is sometimes tricky to figure out what modules test.py is loading when it starts up. The result can be a silent failure with no clue as to what when wrong.

Add a section which lists the modules loaded as well as those not found.

---

 test/py/conftest.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +20 -13
index 5096c20ed65..23435b7db3c 100644
@@ -286,19 +286,26 @@ def pytest_configure(config):
     ubconfig = ArbitraryAttributeContainer()
     ubconfig.brd = dict()
     ubconfig.env = dict()
-
-    modules = [
-        (ubconfig.brd, 'u_boot_board_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
-            board_identity_filename),
-    ]
-    for (dict_to_fill, module_name) in modules:
-        try:
-            module = __import__(module_name)
-        except ImportError:
-            continue
-        dict_to_fill.update(module.__dict__)
+    not_found = []
+
+    with log.section('Loading lab modules', 'load_modules'):
+        modules = [
+            (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+                board_identity_filename),
+        ]
+        for (dict_to_fill, module_name) in modules:
+            try:
+                module = __import__(module_name)
+            except ImportError:
+                not_found.append(module_name)
+                continue
+            dict_to_fill.update(module.__dict__)
+            log.info(f"Loaded {module}")
+
+        if not_found:
+            log.warning(f"Failed to find modules: {' '.join(not_found)}")
 
Quoted 5 lines

test/py/conftest.py def pytest_configure(config): · line 310

Quoted 1 line
test/py/conftest.py +0 -0
     ubconfig.buildconfig = dict()

We won't see this warning normally, only if some level of verbosity is used, yes? It's normal to not have both u_boot_boardenv files for example.

Quoted 4 lines

There is a '[-] Section: Loading lab modules' section so you only see it if you open that.

I feel that test.py is a bit cryptic at present.

I don't follow you, sorry. Open what where?

Signature · 1 line
Tom
#17 lore raw

Re: [PATCH 3/4] test/py: Show info about module-loading

Hi Tom,

Quoted 68 lines · Tom Rini
Quoted 66 lines · Simon Glass

Hi Tom,

Quoted 62 lines · Tom Rini
Quoted 46 lines · Simon Glass

It is sometimes tricky to figure out what modules test.py is loading when it starts up. The result can be a silent failure with no clue as to what when wrong.

Add a section which lists the modules loaded as well as those not found.

---

 test/py/conftest.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +12 -13
index 5096c20ed65..23435b7db3c 100644
@@ -286,19 +286,26 @@ def pytest_configure(config):
     ubconfig = ArbitraryAttributeContainer()
     ubconfig.brd = dict()
     ubconfig.env = dict()
-
-    modules = [
-        (ubconfig.brd, 'u_boot_board_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
-            board_identity_filename),
-    ]
-    for (dict_to_fill, module_name) in modules:
-        try:
-            module = __import__(module_name)
-        except ImportError:
-            continue
-        dict_to_fill.update(module.__dict__)
+    not_found = []
+
+    with log.section('Loading lab modules', 'load_modules'):
+        modules = [
+            (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+                board_identity_filename),
+        ]
+        for (dict_to_fill, module_name) in modules:
+            try:
+                module = __import__(module_name)

test/py/conftest.py def pytest_configure(config): · line 310

Quoted 10 lines
test/py/conftest.py +8 -0
+            except ImportError:
+                not_found.append(module_name)
+                continue
+            dict_to_fill.update(module.__dict__)
+            log.info(f"Loaded {module}")
+
+        if not_found:
+            log.warning(f"Failed to find modules: {' '.join(not_found)}")
 
     ubconfig.buildconfig = dict()

We won't see this warning normally, only if some level of verbosity is used, yes? It's normal to not have both u_boot_boardenv files for example.

Quoted 6 lines
Quoted 4 lines

There is a '[-] Section: Loading lab modules' section so you only see it if you open that.

I feel that test.py is a bit cryptic at present.

I don't follow you, sorry. Open what where?

I mean that the section is collapsed unless you click to open it (when viewed in a web browser).

Regards,
SImon

#18 lore raw

Re: [PATCH 3/4] test/py: Show info about module-loading

Quoted 74 lines · Simon Glass

Hi Tom,

Quoted 71 lines · Tom Rini
Quoted 69 lines · Simon Glass

Hi Tom,

Quoted 57 lines · Tom Rini
Quoted 55 lines · Simon Glass

It is sometimes tricky to figure out what modules test.py is loading when it starts up. The result can be a silent failure with no clue as to what when wrong.

Add a section which lists the modules loaded as well as those not found.

---

 test/py/conftest.py | 33 ++++++++++++++++++++-------------
 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +20 -13
index 5096c20ed65..23435b7db3c 100644
@@ -286,19 +286,26 @@ def pytest_configure(config):
     ubconfig = ArbitraryAttributeContainer()
     ubconfig.brd = dict()
     ubconfig.env = dict()
-
-    modules = [
-        (ubconfig.brd, 'u_boot_board_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
-        (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
-            board_identity_filename),
-    ]
-    for (dict_to_fill, module_name) in modules:
-        try:
-            module = __import__(module_name)
-        except ImportError:
-            continue
-        dict_to_fill.update(module.__dict__)
+    not_found = []
+
+    with log.section('Loading lab modules', 'load_modules'):
+        modules = [
+            (ubconfig.brd, 'u_boot_board_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename),
+            (ubconfig.env, 'u_boot_boardenv_' + board_type_filename + '_' +
+                board_identity_filename),
+        ]
+        for (dict_to_fill, module_name) in modules:
+            try:
+                module = __import__(module_name)
+            except ImportError:
+                not_found.append(module_name)
+                continue
+            dict_to_fill.update(module.__dict__)
+            log.info(f"Loaded {module}")
+
+        if not_found:
+            log.warning(f"Failed to find modules: {' '.join(not_found)}")
 
Quoted 5 lines

test/py/conftest.py def pytest_configure(config): · line 310

Quoted 1 line
test/py/conftest.py +0 -0
     ubconfig.buildconfig = dict()

We won't see this warning normally, only if some level of verbosity is used, yes? It's normal to not have both u_boot_boardenv files for example.

There is a '[-] Section: Loading lab modules' section so you only see it if you open that.

Quoted 6 lines
Quoted 3 lines
Quoted 1 line

I feel that test.py is a bit cryptic at present.

I don't follow you, sorry. Open what where?

I mean that the section is collapsed unless you click to open it (when viewed in a web browser).

Oh, right,
https://u-boot.source-pages.denx.de/-/u-boot/-/jobs/1005206/artifacts/test-log.html
and similar. Yes, anything you want to improve to that part is fine with me. I occasionally look at
https://source.denx.de/u-boot/u-boot/-/pipelines/24337/test_report?job_name=coreboot+test.py
for example but just generally make sure CI saves those reports off for people / tooling that wants to consume them.
https://source.denx.de/u-boot/u-boot/-/jobs/1005206 is what I pay most attention to (and similar output locally).

Signature · 1 line
Tom
#19 lore raw

PATCH 4/4 test: Make net tests depend on CONFIG_CMD_NET

In reply to Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Add a blank line to keep pylint happy.

---
See here:

http://sjg.u-boot.org/u-boot/u-boot/-/jobs/19821

 test/py/tests/test_net.py | 2 ++
 1 file changed, 2 insertions(+)
test/py/tests/test_net.py +2 -0
index bdb7e6f372d..30c6e41334c 100644
@@ -91,6 +91,8 @@ env__router_on_net = True
 net_set_up = False
 net6_set_up = False
 
+
[email protected]('cmd_net')
 def test_net_pre_commands(ubpy):
     """Execute any commands required to enable network hardware.
 
Signature · 1 line
2.43.0
Reviewed-by on v1 4/4
#20 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Signature · 1 line
Tom
#21 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Regards,
Simon

#22 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Quoted 26 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

Quoted 4 lines

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Yes, we should do it globally. Can we not globally also tell tools the deviations from PEP8? I remember back when people would argue about if we should tell file editors what to expect for whitespace, etc :)

Signature · 1 line
Tom
#23 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Hi Tom,

Quoted 28 lines · Tom Rini
Quoted 26 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

Quoted 8 lines
Quoted 4 lines

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Yes, we should do it globally. Can we not globally also tell tools the deviations from PEP8? I remember back when people would argue about if we should tell file editors what to expect for whitespace, etc :)

I'm sure we can do anything. But why deviate? Is it just that you want to avoid churn, or do you actually not like this part of PEP8?

Regards,
Simon

#24 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Quoted 36 lines · Simon Glass

Hi Tom,

Quoted 33 lines · Tom Rini
Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Quoted 6 lines
Quoted 3 lines

Yes, we should do it globally. Can we not globally also tell tools the deviations from PEP8? I remember back when people would argue about if we should tell file editors what to expect for whitespace, etc :)

I'm sure we can do anything. But why deviate? Is it just that you want to avoid churn, or do you actually not like this part of PEP8?

I think it looks bad (personal preference) and we have that in almost none of our tests I suspect so adding blank lines to make PEP8 happy rather than adding hopefully a line to a common file normal tooling reads seems the wrong direction. But I don't care enough to not apply it if someone else does it. I'll add missing blank lines when needed assuming the pylint CI job complains once it's done.

Signature · 1 line
Tom
#25 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Hi Tom,

Quoted 45 lines · Tom Rini
Quoted 36 lines · Simon Glass

Hi Tom,

Quoted 33 lines · Tom Rini
Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Quoted 6 lines
Quoted 3 lines

Yes, we should do it globally. Can we not globally also tell tools the deviations from PEP8? I remember back when people would argue about if we should tell file editors what to expect for whitespace, etc :)

I'm sure we can do anything. But why deviate? Is it just that you want to avoid churn, or do you actually not like this part of PEP8?

Quoted 6 lines

I think it looks bad (personal preference) and we have that in almost none of our tests I suspect so adding blank lines to make PEP8 happy rather than adding hopefully a line to a common file normal tooling reads seems the wrong direction. But I don't care enough to not apply it if someone else does it. I'll add missing blank lines when needed assuming the pylint CI job complains once it's done.

OK. I'm a bit confused about the double-line warning since pylint doesn't actually show it! For now I've changed my IDE to use pylint and disable pycodestyle so now I don't see these.

The current Python files show up with lots of (other) warnings for me and I would like to fix them. But it is quite time-consuming.

Regards,
Simon

#26 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Quoted 55 lines · Simon Glass

Hi Tom,

Quoted 45 lines · Tom Rini
Quoted 36 lines · Simon Glass

Hi Tom,

Quoted 33 lines · Tom Rini
Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Quoted 6 lines
Quoted 3 lines

Yes, we should do it globally. Can we not globally also tell tools the deviations from PEP8? I remember back when people would argue about if we should tell file editors what to expect for whitespace, etc :)

I'm sure we can do anything. But why deviate? Is it just that you want to avoid churn, or do you actually not like this part of PEP8?

Quoted 6 lines

I think it looks bad (personal preference) and we have that in almost none of our tests I suspect so adding blank lines to make PEP8 happy rather than adding hopefully a line to a common file normal tooling reads seems the wrong direction. But I don't care enough to not apply it if someone else does it. I'll add missing blank lines when needed assuming the pylint CI job complains once it's done.

Quoted 6 lines

OK. I'm a bit confused about the double-line warning since pylint doesn't actually show it! For now I've changed my IDE to use pylint and disable pycodestyle so now I don't see these.

The current Python files show up with lots of (other) warnings for me and I would like to fix them. But it is quite time-consuming.

Note that I posted a series this past week that, with one RFC'd exception, fixes everything "make pylint_err" complains about with current pylint.

Signature · 1 line
Tom
#27 lore raw

Re: [PATCH 4/4] test: Make net tests depend on CONFIG_CMD_NET

Hi Tom,

Quoted 61 lines · Tom Rini
Quoted 59 lines · Simon Glass

Hi Tom,

Quoted 45 lines · Tom Rini
Quoted 36 lines · Simon Glass

Hi Tom,

Quoted 33 lines · Tom Rini
Quoted 30 lines · Simon Glass

Hi Tom,

Quoted 9 lines · Tom Rini
Quoted 6 lines · Simon Glass

This fails on samus_tpl as there is no 'net' command.

=> net list
Unknown command 'net' - try 'help' !

Fix it by adding a condition for the test.

Quoted 8 lines

For this part,

Quoted 1 line

Add a blank line to keep pylint happy.

Can we silence that pylint? I don't look forward to the churn of adding more blanks everywhere especially since imo it doesn't improve readability either.

Yes, but we would want to do it globally. But it isn't really a good idea IMO. We are trying to use PEP8 which loads of tools expect...e.g. my IDE shows warnings in this case. It might be better to just fix the problems.

As to readability, I'm on the fence...in practice it doesn't matter much as few non-trivial programs have a lot of top-level functions. I would rather keep the tool happy and use the Python style that people expect when coming into the project.

Quoted 6 lines
Quoted 3 lines

Yes, we should do it globally. Can we not globally also tell tools the deviations from PEP8? I remember back when people would argue about if we should tell file editors what to expect for whitespace, etc :)

I'm sure we can do anything. But why deviate? Is it just that you want to avoid churn, or do you actually not like this part of PEP8?

Quoted 6 lines

I think it looks bad (personal preference) and we have that in almost none of our tests I suspect so adding blank lines to make PEP8 happy rather than adding hopefully a line to a common file normal tooling reads seems the wrong direction. But I don't care enough to not apply it if someone else does it. I'll add missing blank lines when needed assuming the pylint CI job complains once it's done.

OK. I'm a bit confused about the double-line warning since pylint doesn't actually show it! For now I've changed my IDE to use pylint and disable pycodestyle so now I don't see these.

Quoted 6 lines
Quoted 2 lines

The current Python files show up with lots of (other) warnings for me and I would like to fix them. But it is quite time-consuming.

Note that I posted a series this past week that, with one RFC'd exception, fixes everything "make pylint_err" complains about with current pylint.

OK, good.

Regards,
Simon