test: A few quality-of-life improvements
v2 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
Changes in v2:
- Use 'ubman' instead
- Add new patch to drop importing utils as util
- Add new patch to drop assigning ubman to cons
Simon Glass (6):
test/py: Shorten u_boot_console
test/py: Drop u_boot_ prefix on test files
test/py: Drop importing utils as util
test/py: Drop assigning ubman to cons
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 | 42 +--
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 | 133 +++++----
test/py/tests/test_android/test_avb.py | 49 ++-
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 | 93 +++---
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 | 82 +++--
test/py/tests/test_event_dump.py | 9 +-
test/py/tests/test_extension.py | 32 +-
test/py/tests/test_fit.py | 67 +++--
test/py/tests/test_fit_auto_signed.py | 35 ++-
test/py/tests/test_fit_ecdsa.py | 31 +-
test/py/tests/test_fit_hashes.py | 29 +-
test/py/tests/test_fpga.py | 280 +++++++++---------
test/py/tests/test_fs/conftest.py | 1 -
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 | 5 +-
test/py/tests/test_help.py | 28 +-
test/py/tests/test_i2c.py | 44 +--
test/py/tests/test_kconfig.py | 16 +-
test/py/tests/test_log.py | 20 +-
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 | 156 +++++-----
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 | 43 ++-
test/py/tests/test_ofplatdata.py | 11 +-
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 | 16 +-
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 | 45 ++-
test/py/tests/test_spi.py | 242 +++++++--------
test/py/tests/test_spl.py | 15 +-
test/py/tests/test_stackprotector.py | 8 +-
test/py/tests/test_suite.py | 68 ++---
test/py/tests/test_tpm2.py | 194 ++++++------
test/py/tests/test_trace.py | 69 +++--
test/py/tests/test_ums.py | 48 +--
test/py/tests/test_unknown_cmd.py | 6 +-
test/py/tests/test_upl.py | 15 +-
test/py/tests/test_usb.py | 206 ++++++-------
test/py/tests/test_ut.py | 224 +++++++-------
test/py/tests/test_vbe.py | 17 +-
test/py/tests/test_vbe_vpl.py | 33 +--
test/py/tests/test_vboot.py | 188 ++++++------
test/py/tests/test_vpl.py | 11 +-
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 +--
108 files changed, 3180 insertions(+), 3196 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
PATCH v2 1/6 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 'ubman'.
---
Changes in v2:
- Use 'ubman' instead
doc/develop/py_testing.rst | 12 +- doc/develop/tests_writing.rst | 12 +- test/py/conftest.py | 4 +- test/py/tests/fit_util.py | 42 +-- 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, 2607 insertions(+), 2607 deletions(-)
doc/develop/py_testing.rst +6 -6
@@ -506,24 +506,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 `ubman` 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 `ubman.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 +`ubman.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 `ubman.config` object, for example +`ubman.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 +`ubman.config.buildconfig`, with keys equal to the Kconfig variable names.
doc/develop/tests_writing.rst +6 -6
@@ -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(ubman): """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(ubman) 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') + ubman.run_command('mw ' + addr + ' 0 10') + response = ubman.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') + ubman.run_command('mw ' + addr + ' ' + val) + response = ubman.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
@@ -486,8 +486,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 ubman(request): + """Generate the value of a test's ubman fixture. Args: request: The pytest request.
test/py/tests/fit_util.py +21 -21
106 lines not on this page · raw message
test/py/tests/test_000_version.py +4 -4
@@ -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(ubman): """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 ubman.disable_check('main_signon'): + response = ubman.run_command('version') # Ensure "version" printed what we expected. - u_boot_console.validate_version_string_in_text(response) + ubman.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
@@ -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(ubman): + output = ubman.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(ubman): + f = ubman.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 $?') + ubman.run_command('bootstage stash %x %x' % (addr, size)) + output = ubman.run_command('echo $?') assert output.endswith('0') - output = u_boot_console.run_command('md %x 100' % addr) + output = ubman.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 $?') + ubman.run_command('bootstage unstash %x %x' % (addr, size)) + output = ubman.run_command('echo $?') assert output.endswith('0')
test/py/tests/test_button.py +8 -8
@@ -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(ubman): """Test listing buttons""" - response = u_boot_console.run_command('button list; echo rc:$?') + response = ubman.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(ubman): """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:$?') + ubman.run_command('gpio set a3; gpio input a3'); + response = ubman.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:$?') + ubman.run_command('gpio clear a3; gpio input a3'); + response = ubman.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 = ubman.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
@@ -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(ubman, cat_data): """ Unit test for cat Args: - u_boot_console -- U-Boot console + ubman -- U-Boot console cat_data -- Path to the disk image used for testing. """ - response = u_boot_console.run_command_list([ + response = ubman.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
@@ -4,15 +4,15 @@ import pytest @pytest.mark.buildconfigspec('cmd_dm') -def test_dm_compat(u_boot_console): +def test_dm_compat(ubman): """Test that each driver in `dm tree` is also listed in `dm compat`.""" - response = u_boot_console.run_command('dm tree') + response = ubman.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 = ubman.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 = ubman.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(ubman): """Test that each driver in `dm compat` is also listed in `dm drivers`.""" - response = u_boot_console.run_command('dm compat') + response = ubman.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 = ubman.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(ubman): """Test that each driver in `dm static` is also listed in `dm drivers`.""" - response = u_boot_console.run_command('dm static') + response = ubman.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 = ubman.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(ubman): + response = ubman.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(ubman): + response = ubman.run_command("dm devres")
test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py +17 -17
@@ -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(ubman, 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 + ubman -- 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}') + ubman.run_command(cmd = f'host bind 0 {efi_bootmgr_data}') - u_boot_console.run_command(cmd = 'efidebug boot add ' \ + ubman.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) + ubman.run_command(cmd = 'efidebug boot dump') + ubman.run_command(cmd = 'efidebug boot order 0001') + ubman.run_command(cmd = 'bootefi bootmgr') + response = ubman.run_command(cmd = 'load', wait_for_echo=False) assert 'crc32: 0x181464af' in response - u_boot_console.run_command(cmd = 'exit', wait_for_echo=False) + ubman.run_command(cmd = 'exit', wait_for_echo=False) - u_boot_console.run_command(cmd = 'efidebug boot add ' \ + ubman.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) + ubman.run_command(cmd = 'efidebug boot dump') + ubman.run_command(cmd = 'efidebug boot order 0002') + ubman.run_command(cmd = 'bootefi bootmgr') + response = ubman.run_command(cmd = 'load', wait_for_echo=False) assert 'crc32: 0x811d3515' in response - u_boot_console.run_command(cmd = 'exit', wait_for_echo=False) + ubman.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') + ubman.run_command(cmd = 'efidebug boot rm 0001') + ubman.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
@@ -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(ubman): """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 = ubman # 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
317 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_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_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_i2c.py +22 -22
44 lines not on this page · 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_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_pstore.py +23 -23
46 lines not on this page · raw message
test/py/tests/test_saveenv.py +35 -35
70 lines not on this page · 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
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_spi.py +120 -120
240 lines not on this page · raw message
test/py/tests/test_tpm2.py +94 -94
188 lines not on this page · 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_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/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.
PATCH v2 2/6 test/py: Drop u_boot_ prefix on test files
In reply to Simon GlassWe 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.
---
(no changes since v1)
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/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
52 files changed, 215 insertions(+), 215 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
@@ -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)
@@ -515,7 +515,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 `ubman.disable_check()` to temporarily disable checking for specific strings. See `test_unknown_cmd.py` for an example.
doc/develop/tests_writing.rst +1 -1
@@ -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(ubman) + ram_base = utils.find_ram_base(ubman) 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
@@ -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
@@ -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
@@ -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
test/py/tests/test_android/test_ab.py +6 -6
@@ -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 = ubman.config.persistent_data_dir + '/' + filename self.path = ubman.config.result_dir + '/' + filename - with u_boot_utils.persistent_file_helper(ubman.log, persistent): + with utils.persistent_file_helper(ubman.log, persistent): if os.path.exists(persistent): ubman.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(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('sgdisk', '--new=1:64:512', '--change-name=1:misc', persistent) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('sgdisk', '--load-backup=' + persistent) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('cp', persistent, self.path) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) di = None @pytest.fixture(scope='function')
test/py/tests/test_android/test_abootimg.py +5 -5
@@ -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 = ubman.config.persistent_data_dir + '/' + filename self.path = ubman.config.result_dir + '/' + filename ubman.log.action('persistent is ' + persistent) - with u_boot_utils.persistent_file_helper(ubman.log, persistent): + with utils.persistent_file_helper(ubman.log, persistent): if os.path.exists(persistent): ubman.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(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('gunzip', '-9', gz) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('cp', persistent, self.path) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) gtdi1 = None @pytest.fixture(scope='function')
test/py/tests/test_android/test_avb.py +1 -1
@@ -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
@@ -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(ubman, 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(ubman, env__usb_dev_port, env__dfu_config): cmd = 'dfu 0 ' + env__dfu_config['cmd_params'] ubman.run_command(cmd, wait_for_prompt=False) ubman.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(ubman, env__usb_dev_port, env__dfu_config): ubman.ctrlc() ubman.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(ubman, 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(ubman, cmd) + utils.run_and_log(ubman, cmd) ubman.wait_for('Ctrl+C to exit ...') def dfu_write(alt_setting, fn):
@@ -261,7 +261,7 @@ def test_dfu(ubman, env__usb_dev_port, env__dfu_config): Nothing. """ - test_f = u_boot_utils.PersistentRandomFile(ubman, + test_f = utils.PersistentRandomFile(ubman, 'dfu_%d.bin' % size, size) readback_fn = ubman.config.result_dir + '/dfu_readback.bin'
@@ -279,7 +279,7 @@ def test_dfu(ubman, env__usb_dev_port, env__dfu_config): ubman.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(ubman, env__usb_dev_port, env__dfu_config): else: sizes = [] - dummy_f = u_boot_utils.PersistentRandomFile(ubman, + dummy_f = utils.PersistentRandomFile(ubman, '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
@@ -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
@@ -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(ubman, env_conf, proto): addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) fn = f['fn'] if proto == PROTO_TFTP:
test/py/tests/test_env.py +12 -12
@@ -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(ubman): 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.ubman - ram_base = u_boot_utils.find_ram_base(state_test_env.ubman) + ram_base = utils.find_ram_base(state_test_env.ubman) 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.ubman - ram_base = u_boot_utils.find_ram_base(state_test_env.ubman) + ram_base = utils.find_ram_base(state_test_env.ubman) 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.ubman - ram_base = u_boot_utils.find_ram_base(state_test_env.ubman) + ram_base = utils.find_ram_base(state_test_env.ubman) 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.ubman - ram_base = u_boot_utils.find_ram_base(state_test_env.ubman) + ram_base = utils.find_ram_base(state_test_env.ubman) 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(ubman): 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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(ubman): addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['fn']
@@ -546,7 +546,7 @@ def test_fpga_secure_bit_img_auth_kup(ubman): keyaddr = f.get('keyaddr', None) if not keyaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' keyfn = f['keyfn'] output = ubman.run_command('tftpboot %x %s' % (keyaddr, keyfn))
@@ -554,7 +554,7 @@ def test_fpga_secure_bit_img_auth_kup(ubman): addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['enckupfn'] output = ubman.run_command('tftpboot %x %s' % (addr, fn))
test/py/tests/test_fs/conftest.py +1 -1
@@ -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
@@ -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
@@ -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 = ubman.config.persistent_data_dir + '/' + filename self.path = ubman.config.result_dir + '/' + filename - with u_boot_utils.persistent_file_helper(ubman.log, persistent): + with utils.persistent_file_helper(ubman.log, persistent): if os.path.exists(persistent): ubman.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(ubman, cmd) + utils.run_and_log(ubman, 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(ubman, cmd) + utils.run_and_log(ubman, 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(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('sgdisk', '--load-backup=' + persistent) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) cmd = ('cp', persistent, self.path) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) @pytest.fixture(scope='function') def state_disk_image(ubman):
test/py/tests/test_kconfig.py +1 -1
@@ -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
@@ -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(ubman): """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(ubman) + ram_base = utils.find_ram_base(ubman) addr = '%08x' % ram_base val = 'a5f09876' expected_response = addr + ': ' + val
@@ -26,7 +26,7 @@ def test_md_repeat(ubman): """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(ubman) + ram_base = utils.find_ram_base(ubman) addr_base = '%08x' % ram_base words = 0x10 addr_repeat = '%08x' % (ram_base + (words * 4))
test/py/tests/test_mmc.py +4 -4
@@ -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(ubman): for y in mmc_modes: ubman.run_command('mmc dev %d %d %d' % x, part, y) part_detect = 1 - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) 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(ubman): for y in mmc_modes: ubman.run_command('mmc dev %d %d %d' % x, part, y) part_detect = 1 - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) 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(ubman): for y in mmc_modes: ubman.run_command('mmc dev %d %d %d' % x, part, y) part_detect = 1 - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) count_f = 0 addr_l = [] size_l = []
test/py/tests/test_mmc_rd.py +2 -2
@@ -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(ubman, env__mmc_rd_config): bcfg = ubman.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(ubman) + ram_base = utils.find_ram_base(ubman) addr = '0x%08x' % ram_base # Select MMC device
test/py/tests/test_mmc_wr.py +2 -2
@@ -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(ubman, env__mmc_wr_config): count_bytes = count_sectors * 512 bcfg = ubman.config.buildconfig - ram_base = u_boot_utils.find_ram_base(ubman) + ram_base = utils.find_ram_base(ubman) src_addr = '0x%08x' % ram_base dst_addr = '0x%08x' % (ram_base + count_bytes)
test/py/tests/test_net.py +3 -3
@@ -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(ubman): addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) fn = f['fn'] output = ubman.run_command('nfs %x %s' % (addr, fn))
@@ -411,7 +411,7 @@ def test_net_tftpput(ubman): addr = f.get("addr", None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) sz = f.get("size", None) timeout = f.get("timeout", ubman.p.timeout)
test/py/tests/test_net_boot.py +2 -2
@@ -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(ubman): setup_networking(ubman) addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) fn = f['fn'] timeout = f.get('timeout', 50000)
test/py/tests/test_of_migrate.py +1 -1
@@ -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
@@ -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
@@ -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(ubman):
test/py/tests/test_pinmux.py +1 -1
@@ -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(ubman):
test/py/tests/test_pstore.py +1 -1
@@ -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
@@ -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
@@ -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(ubman):
test/py/tests/test_sf.py +6 -6
@@ -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(ubman, env__sf_config): """ sf_params = {} - sf_params['ram_base'] = u_boot_utils.find_ram_base(ubman) + sf_params['ram_base'] = utils.find_ram_base(ubman) probe_id = env__sf_config.get('id', 0) speed = env__sf_config.get('speed', 0)
@@ -123,14 +123,14 @@ def sf_read(ubman, env__sf_config, sf_params): cmd = 'mw.b %08x %02x %x' % (addr, pattern, count) ubman.run_command(cmd) - crc_pattern = u_boot_utils.crc32(ubman, addr, count) + crc_pattern = utils.crc32(ubman, addr, count) if crc_expected: assert crc_pattern != crc_expected cmd = 'sf read %08x %08x %x' % (addr, offset, count) response = ubman.run_command(cmd) assert 'Read: OK' in response, 'Read operation failed' - crc_readback = u_boot_utils.crc32(ubman, addr, count) + crc_readback = utils.crc32(ubman, 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(ubman, env__sf_config, sf_params): cmd = 'mw.b %08x %02x %x' % (addr, pattern, count) ubman.run_command(cmd) - crc_pattern = u_boot_utils.crc32(ubman, addr, count) + crc_pattern = utils.crc32(ubman, addr, count) cmd = 'sf update %08x %08x %x' % (addr, offset, count) ubman.run_command(cmd)
@@ -201,7 +201,7 @@ def test_sf_erase(ubman, env__sf_config): cmd = 'mw.b %08x ff %x' % (addr, count) ubman.run_command(cmd) - crc_ffs = u_boot_utils.crc32(ubman, addr, count) + crc_ffs = utils.crc32(ubman, addr, count) crc_read = sf_read(ubman, env__sf_config, sf_params) assert crc_ffs == crc_read, 'Unexpected CRC32 after erase operation.'
test/py/tests/test_source.py +1 -1
@@ -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
@@ -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(ubman): def spi_write_twice(ubman, 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(ubman) + addr = utils.find_ram_base(ubman) old_size = 0 for size in (
@@ -273,7 +273,7 @@ def test_spi_write_twice(ubman): def spi_write_continues(ubman, page_size, erase_size, total_size, timeout): ''' Write with random size of data to continue SPI write case ''' spi_erase_block(ubman, erase_size, total_size) - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) output = ubman.run_command(f'crc32 {hex(addr + 0x10000)} {hex(total_size)}') m = re.search('==> (.+?)$', output)
@@ -329,7 +329,7 @@ def spi_read_twice(ubman, 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(ubman) + addr = utils.find_ram_base(ubman) size = size & ~3 with ubman.temporary_timeout(timeout): output = ubman.run_command(
@@ -453,13 +453,13 @@ def protect_ops(ubman, lock_addr, lock_size, ops="unlock"): def erase_write_ops(ubman, start, size): ''' Basic erase and write operation for flash ''' - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) flash_ops(ubman, 'erase', start, size, 0, 0, EXPECTED_ERASE) flash_ops(ubman, 'write', start, size, addr, 0, EXPECTED_WRITE) def spi_lock_unlock(ubman, lock_addr, lock_size): ''' Lock unlock operations for SPI family flash ''' - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) erase_size = get_erase_size() # Find the protected/un-protected region
@@ -614,7 +614,7 @@ def test_spi_negative(ubman): total_size = get_total_size() erase_size = get_erase_size() page_size = get_page_size() - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) i = 0 while i < loop: # Erase negative test
test/py/tests/test_tpm2.py +5 -5
@@ -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(ubman): tpm2_sandbox_init(ubman) force_init(ubman) - ram = u_boot_utils.find_ram_base(ubman) + ram = utils.find_ram_base(ubman) read_cap = ubman.run_command('tpm2 get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram) output = ubman.run_command('echo $?')
@@ -220,7 +220,7 @@ def test_tpm2_dam_parameters(ubman): if is_sandbox(ubman): tpm2_sandbox_init(ubman) force_init(ubman) - ram = u_boot_utils.find_ram_base(ubman) + ram = utils.find_ram_base(ubman) # Set the DAM parameters to known values ubman.run_command('tpm2 dam_parameters 3 10 0')
@@ -245,7 +245,7 @@ def test_tpm2_pcr_read(ubman): tpm2_sandbox_init(ubman) force_init(ubman) - ram = u_boot_utils.find_ram_base(ubman) + ram = utils.find_ram_base(ubman) read_pcr = ubman.run_command('tpm2 pcr_read 10 0x%x' % ram) output = ubman.run_command('echo $?')
@@ -273,7 +273,7 @@ def test_tpm2_pcr_extend(ubman): if is_sandbox(ubman): tpm2_sandbox_init(ubman) force_init(ubman) - ram = u_boot_utils.find_ram_base(ubman) + ram = utils.find_ram_base(ubman) read_pcr = ubman.run_command('tpm2 pcr_read 10 0x%x' % (ram + 0x20)) output = ubman.run_command('echo $?')
test/py/tests/test_trace.py +1 -1
@@ -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
@@ -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(ubman, env__usb_dev_port, env__block_devs): else: host_ums_part_node = host_ums_dev_node - test_f = u_boot_utils.PersistentRandomFile(ubman, 'ums.bin', + test_f = utils.PersistentRandomFile(ubman, '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(ubman, env__usb_dev_port, env__block_devs): cmd = 'ums %s %s %s' % (tgt_usb_ctlr, tgt_dev_type, tgt_dev_id) ubman.run_command(cmd, wait_for_prompt=False) ubman.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) ubman.log.action('Reading raw data from UMS device') fh.read(4096) fh.close()
@@ -155,7 +155,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs): ubman.log.action('Mounting exported UMS device') cmd = ('/bin/mount', host_ums_part_node) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, cmd) def umount(ignore_errors): """Unmount the block device that U-Boot exports.
@@ -172,7 +172,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs): ubman.log.action('Unmounting UMS device') cmd = ('/bin/umount', host_ums_part_node) - u_boot_utils.run_and_log(ubman, cmd, ignore_errors) + utils.run_and_log(ubman, cmd, ignore_errors) def stop_ums(ignore_errors): """Stop U-Boot's ums shell command from executing.
@@ -193,7 +193,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs): ubman.log.action( 'Stopping long-running U-Boot ums shell command') ubman.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(ubman, env__usb_dev_port, env__block_devs): mount() ubman.log.action('Writing test file via UMS') cmd = ('rm', '-f', mounted_test_fn) - u_boot_utils.run_and_log(ubman, cmd) + utils.run_and_log(ubman, 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(ubman, cmd) + utils.run_and_log(ubman, cmd) ignore_cleanup_errors = False finally: umount(ignore_errors=ignore_cleanup_errors)
@@ -223,9 +223,9 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs): try: mount() ubman.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(ubman, cmd) + utils.run_and_log(ubman, cmd) ignore_cleanup_errors = False finally: umount(ignore_errors=ignore_cleanup_errors)
test/py/tests/test_upl.py +1 -1
@@ -6,7 +6,7 @@ import os import pytest -import u_boot_utils +import utils @pytest.mark.boardspec('sandbox_vpl') def test_upl_handoff(ubman):
test/py/tests/test_usb.py +6 -6
@@ -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(ubman): pytest.skip('No %s partition detected' % fs.upper()) def usb_fatload_fatwrite(ubman, fs, x, part): - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) size = random.randint(4, 1 * 1024 * 1024) output = ubman.run_command('crc32 %x %x' % (addr, size)) m = re.search('==> (.+?)', output)
@@ -391,7 +391,7 @@ def test_usb_ext4ls(ubman): pytest.skip('No %s partition detected' % fs.upper()) def usb_ext4load_ext4write(ubman, fs, x, part): - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) size = random.randint(4, 1 * 1024 * 1024) output = ubman.run_command('crc32 %x %x' % (addr, size)) m = re.search('==> (.+?)', output)
@@ -505,7 +505,7 @@ def test_usb_ext2load(ubman): part_detect = 1 file, size, expected_crc32 = \ usb_ext4load_ext4write(ubman, fs, x, part) - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) offset = random.randrange(128, 1024, 128) output = ubman.run_command(
@@ -572,7 +572,7 @@ def test_usb_load(ubman): for part in partitions: part_detect = 1 - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) if fs == 'fat': file, size, expected_crc32 = \
@@ -616,7 +616,7 @@ def test_usb_save(ubman): for part in partitions: part_detect = 1 - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) 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
@@ -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(ubman): # 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
@@ -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
@@ -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(ubman): srcaddr = f.get('srcaddr', None) if not srcaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['fn']
@@ -96,7 +96,7 @@ def test_zynq_aes_bitstream(ubman): srcaddr = f.get('srcaddr', None) if not srcaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['fnbit']
@@ -124,7 +124,7 @@ def test_zynq_aes_partial_bitstream(ubman): srcaddr = f.get('srcaddr', None) if not srcaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['fnpbit']
@@ -150,7 +150,7 @@ def test_zynq_rsa_image(ubman): srcaddr = f.get('srcaddr', None) if not srcaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['fn']
@@ -176,7 +176,7 @@ def test_zynq_rsa_image_invalid(ubman): srcaddr = f.get('srcaddr', None) if not srcaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fninvalid = f['fninvalid']
test/py/tests/test_zynqmp_secure.py +4 -4
@@ -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(ubman): addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['fn']
@@ -78,7 +78,7 @@ def test_zynqmp_secure_boot_img_kup(ubman): keyaddr = f.get('keyaddr', None) if not keyaddr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' keyfn = f['keyfn'] output = ubman.run_command('tftpboot %x %s' % (keyaddr, keyfn))
@@ -86,7 +86,7 @@ def test_zynqmp_secure_boot_img_kup(ubman): addr = f.get('addr', None) if not addr: - addr = u_boot_utils.find_ram_base(ubman) + addr = utils.find_ram_base(ubman) expected_tftp = 'Bytes transferred = ' fn = f['enckupfn'] output = ubman.run_command('tftpboot %x %s' % (addr, fn))
test/py/utils.py renamed from test/py/u_boot_utils.py +0 -0
Signature · 1 line
2.43.0
Re: [PATCH v2 2/6] test/py: Drop u_boot_ prefix on test files
Hi Simon,
Thank you for the patch.
Quoted 8 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.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
Quoted 11 lines
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/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 ++--Quoted 1 line
test/py/tests/test_efi_fit.py | 2 +-
[...]
PATCH v2 3/6 test/py: Drop importing utils as util
In reply to Simon GlassNow that we have a shorter name, we don't need this sort of thing. Drop it.
---
Changes in v2:
- Add new patch to drop importing utils as util
test/py/tests/fit_util.py | 6 +-- test/py/tests/test_android/test_avb.py | 1 - test/py/tests/test_efi_fit.py | 24 +++++---- test/py/tests/test_event_dump.py | 4 +- test/py/tests/test_fit.py | 4 +- test/py/tests/test_fit_auto_signed.py | 18 +++---- test/py/tests/test_fit_ecdsa.py | 16 +++--- test/py/tests/test_fit_hashes.py | 14 +++--- test/py/tests/test_fs/conftest.py | 1 - test/py/tests/test_kconfig.py | 6 +-- test/py/tests/test_of_migrate.py | 14 +++--- test/py/tests/test_ofplatdata.py | 4 +- test/py/tests/test_optee_rpmb.py | 2 +- test/py/tests/test_sandbox_opts.py | 6 +-- test/py/tests/test_scp03.py | 2 +- test/py/tests/test_source.py | 4 +- test/py/tests/test_trace.py | 18 +++---- test/py/tests/test_vboot.py | 70 +++++++++++++------------- 18 files changed, 110 insertions(+), 104 deletions(-)
test/py/tests/fit_util.py +3 -3
@@ -5,7 +5,7 @@ import os -import utils as util +import utils def make_fname(ubman, basename): """Make a temporary filename
@@ -54,7 +54,7 @@ def make_fit(ubman, mkimage, base_its, params, basename='test.fit', base_fdt=Non """ fit = make_fname(ubman, basename) its = make_its(ubman, base_its, params) - util.run_and_log(ubman, [mkimage, '-f', its, fit]) + utils.run_and_log(ubman, [mkimage, '-f', its, fit]) if base_fdt: with open(make_fname(ubman, 'u-boot.dts'), 'w') as fd: fd.write(base_fdt)
@@ -89,5 +89,5 @@ def make_dtb(ubman, base_fdt, basename): dtb = make_fname(ubman, f'{basename}.dtb') with open(src, 'w', encoding='utf-8') as outf: outf.write(base_fdt) - util.run_and_log(ubman, ['dtc', src, '-O', 'dtb', '-o', dtb]) + utils.run_and_log(ubman, ['dtc', src, '-O', 'dtb', '-o', dtb]) return dtb
test/py/tests/test_android/test_avb.py +0 -1
@@ -15,7 +15,6 @@ For configuration verification: """ import pytest -import utils as util # defauld mmc id mmc_dev = 1
test/py/tests/test_efi_fit.py +13 -11
@@ -55,7 +55,7 @@ env__efi_fit_tftp_file = { import os.path import pytest -import utils as util +import utils # Define the parametrized ITS data to be used for FIT images generation. ITS_DATA = '''
@@ -224,11 +224,11 @@ def test_efi_fit_launch(ubman): """ bin_path = make_fpath(fname) - util.run_and_log(cons, - ['cp', make_fpath('lib/efi_loader/helloworld.efi'), - bin_path]) + utils.run_and_log(cons, + ['cp', make_fpath('lib/efi_loader/helloworld.efi'), + bin_path]) if comp: - util.run_and_log(cons, ['gzip', '-f', bin_path]) + utils.run_and_log(cons, ['gzip', '-f', bin_path]) bin_path += '.gz' return bin_path
@@ -257,9 +257,10 @@ def test_efi_fit_launch(ubman): # Build the test FDT. dtb = make_fpath('test-efi-fit-%s.dtb' % fdt_type) - util.run_and_log(cons, ['dtc', '-I', 'dts', '-O', 'dtb', '-o', dtb, dts]) + utils.run_and_log(cons, + ['dtc', '-I', 'dts', '-O', 'dtb', '-o', dtb, dts]) if comp: - util.run_and_log(cons, ['gzip', '-f', dtb]) + utils.run_and_log(cons, ['gzip', '-f', dtb]) dtb += '.gz' return dtb
@@ -290,7 +291,7 @@ def test_efi_fit_launch(ubman): # Build the test ITS. fit_path = make_fpath('test-efi-fit-helloworld.fit') - util.run_and_log( + utils.run_and_log( cons, [make_fpath('tools/mkimage'), '-f', its_path, fit_path]) return fit_path
@@ -307,7 +308,7 @@ def test_efi_fit_launch(ubman): addr = fit.get('addr', None) if not addr: - addr = util.find_ram_base(cons) + addr = utils.find_ram_base(cons) output = cons.run_command( 'host load hostfs - %x %s/%s' % (addr, fit['dn'], fit['fn']))
@@ -334,7 +335,7 @@ def test_efi_fit_launch(ubman): addr = fit.get('addr', None) if not addr: - addr = util.find_ram_base(cons) + addr = utils.find_ram_base(cons) file_name = fit['fn'] output = cons.run_command('tftpboot %x %s' % (addr, file_name))
@@ -412,7 +413,8 @@ def test_efi_fit_launch(ubman): # Copy image to TFTP root directory. if fit['dn'] != cons.config.build_dir: - util.run_and_log(cons, ['mv', '-f', fit_path, '%s/' % fit['dn']]) + utils.run_and_log(cons, + ['mv', '-f', fit_path, '%s/' % fit['dn']]) # Load FIT image. addr = load_fit_from_host(fit) if is_sandbox else load_fit_from_tftp(fit)
test/py/tests/test_event_dump.py +2 -2
@@ -4,7 +4,7 @@ import pytest import re -import utils as util +import utils # This is only a partial test - coverting 64-bit sandbox. It does not test # big-endian images, nor 32-bit images
@@ -13,7 +13,7 @@ def test_event_dump(ubman): """Test that the "help" command can be executed.""" cons = ubman sandbox = cons.config.build_dir + '/u-boot' - out = util.run_and_log(cons, ['scripts/event_dump.py', sandbox]) + out = utils.run_and_log(cons, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.*
test/py/tests/test_fit.py +2 -2
@@ -6,7 +6,7 @@ import os import pytest import struct -import utils as util +import utils import fit_util # Define a base ITS which we can adjust using % and a dictionary
@@ -165,7 +165,7 @@ def test_fit(ubman): return fname def make_compressed(filename): - util.run_and_log(cons, ['gzip', '-f', '-k', filename]) + utils.run_and_log(cons, ['gzip', '-f', '-k', filename]) return filename + '.gz' def find_matching(text, match):
test/py/tests/test_fit_auto_signed.py +9 -9
@@ -17,7 +17,7 @@ The test does not run the sandbox. It only checks the host tool mkimage. import os import pytest -import utils as util +import utils import binascii from Cryptodome.Hash import SHA1 from Cryptodome.Hash import SHA256
@@ -33,15 +33,15 @@ class SignedFitHelper(object): self.confgs_nodes = set() def __fdt_list(self, path): - return util.run_and_log(self.cons, + return utils.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') def __fdt_get_string(self, node, prop): - return util.run_and_log(self.cons, + return utils.run_and_log(self.cons, f'fdtget -ts {self.fit} {node} {prop}') def __fdt_get_binary(self, node, prop): - numbers = util.run_and_log(self.cons, + numbers = utils.run_and_log(self.cons, f'fdtget -tbi {self.fit} {node} {prop}') bignum = bytearray()
@@ -166,7 +166,7 @@ def test_fit_auto_signed(ubman): s_args = " -k" + tempdir + " -g" + key_name + " -o" + sign_algo # 1 - Create auto FIT with images crc32 checksum, and verify it - util.run_and_log(cons, mkimage + ' -fauto' + b_args + " " + fit_file) + utils.run_and_log(cons, mkimage + ' -fauto' + b_args + " " + fit_file) fit = SignedFitHelper(cons, fit_file) if fit.build_nodes_sets() == 0:
@@ -175,8 +175,8 @@ def test_fit_auto_signed(ubman): fit.check_fit_crc32_images() # 2 - Create auto FIT with signed images, and verify it - util.run_and_log(cons, mkimage + ' -fauto' + b_args + s_args + " " + - fit_file) + utils.run_and_log(cons, mkimage + ' -fauto' + b_args + s_args + " " + + fit_file) fit = SignedFitHelper(cons, fit_file) if fit.build_nodes_sets() == 0:
@@ -185,8 +185,8 @@ def test_fit_auto_signed(ubman): fit.check_fit_signed_images(key_name, sign_algo, verifier) # 3 - Create auto FIT with signed configs and hashed images, and verify it - util.run_and_log(cons, mkimage + ' -fauto-conf' + b_args + s_args + " " + - fit_file) + utils.run_and_log(cons, mkimage + ' -fauto-conf' + b_args + s_args + " " + + fit_file) fit = SignedFitHelper(cons, fit_file) if fit.build_nodes_sets() == 0:
test/py/tests/test_fit_ecdsa.py +9 -7
@@ -12,7 +12,7 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage' import os import pytest -import utils as util +import utils from Cryptodome.Hash import SHA256 from Cryptodome.PublicKey import ECC from Cryptodome.Signature import DSS
@@ -25,14 +25,16 @@ class SignableFitImage(object): self.signable_nodes = set() def __fdt_list(self, path): - return util.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') + return utils.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') def __fdt_set(self, node, **prop_value): for prop, value in prop_value.items(): - util.run_and_log(self.cons, f'fdtput -ts {self.fit} {node} {prop} {value}') + utils.run_and_log(self.cons, + f'fdtput -ts {self.fit} {node} {prop} {value}') def __fdt_get_binary(self, node, prop): - numbers = util.run_and_log(self.cons, f'fdtget -tbi {self.fit} {node} {prop}') + numbers = utils.run_and_log(self.cons, + f'fdtget -tbi {self.fit} {node} {prop}') bignum = bytearray() for little_num in numbers.split():
@@ -53,7 +55,7 @@ class SignableFitImage(object): self.__fdt_set(f'{image}/signature', algo='sha256,ecdsa256') def sign(self, mkimage, key_file): - util.run_and_log(self.cons, [mkimage, '-F', self.fit, f'-G{key_file}']) + utils.run_and_log(self.cons, [mkimage, '-F', self.fit, f'-G{key_file}']) def check_signatures(self, key): for image in self.signable_nodes:
@@ -76,11 +78,11 @@ def test_fit_ecdsa(ubman): def assemble_fit_image(dest_fit, its, destdir): dtc_args = f'-I dts -O dtb -i {destdir}' - util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) + utils.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) def dtc(dts): dtb = dts.replace('.dts', '.dtb') - util.run_and_log(cons, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') + utils.run_and_log(cons, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') cons = ubman mkimage = cons.config.build_dir + '/tools/mkimage'
test/py/tests/test_fit_hashes.py +8 -6
@@ -12,7 +12,7 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage' import os import pytest -import utils as util +import utils kernel_hashes = { "sha512" : "f18c1486a2c29f56360301576cdfce4dfd8e8e932d0ed8e239a1f314b8ae1d77b2a58cd7fe32e4075e69448e623ce53b0b6aa6ce5626d2c189a5beae29a68d93",
@@ -32,14 +32,15 @@ class ReadonlyFitImage(object): self.hashable_nodes = set() def __fdt_list(self, path): - return util.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') + return utils.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') def __fdt_get(self, node, prop): - val = util.run_and_log(self.cons, f'fdtget {self.fit} {node} {prop}') + val = utils.run_and_log(self.cons, f'fdtget {self.fit} {node} {prop}') return val.rstrip('\n') def __fdt_get_sexadecimal(self, node, prop): - numbers = util.run_and_log(self.cons, f'fdtget -tbx {self.fit} {node} {prop}') + numbers = utils.run_and_log(self.cons, + f'fdtget -tbx {self.fit} {node} {prop}') sexadecimal = '' for num in numbers.rstrip('\n').split(' '):
@@ -85,11 +86,12 @@ def test_mkimage_hashes(ubman): def assemble_fit_image(dest_fit, its, destdir): dtc_args = f'-I dts -O dtb -i {destdir}' - util.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) + utils.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) def dtc(dts): dtb = dts.replace('.dts', '.dtb') - util.run_and_log(cons, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') + utils.run_and_log(cons, + f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') cons = ubman mkimage = cons.config.build_dir + '/tools/mkimage'
test/py/tests/test_fs/conftest.py +0 -1
@@ -8,7 +8,6 @@ import pytest import re from subprocess import call, check_call, check_output, CalledProcessError from fstest_defs import * -import utils as util # pylint: disable=E0611 from tests import fs_helper
test/py/tests/test_kconfig.py +3 -3
@@ -4,7 +4,7 @@ import pytest -import utils as util +import utils # This is needed for Azure, since the default '..' directory is not writeable TMPDIR = '/tmp/test_kconfig'
@@ -16,7 +16,7 @@ def test_kconfig(ubman): cons = ubman # This detects build errors in test/lib/kconfig.c - out = util.run_and_log( + out = utils.run_and_log( cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True) assert 'invalid_use_of_IF_ENABLED_INT' in out
@@ -29,7 +29,7 @@ def test_kconfig_spl(ubman): cons = ubman # This detects build errors in test/lib/kconfig_spl.c - out = util.run_and_log( + out = utils.run_and_log( cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox_spl', '-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True) assert 'invalid_use_of_IF_ENABLED_INT' in out
test/py/tests/test_of_migrate.py +7 -7
@@ -7,7 +7,7 @@ import os import pytest -import utils as util +import utils # This is needed for Azure, since the default '..' directory is not writeable TMPDIR1 = '/tmp/test_no_migrate'
@@ -33,8 +33,8 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): dt_dir = os.path.join(build_dir, 'arch', 'sandbox', 'dts') orig_fname = os.path.join(dt_dir, 'sandbox.dtb') out_dts = os.path.join(dt_dir, 'sandbox_out.dts') - util.run_and_log(cons, ['dtc', orig_fname, '-I', 'dtb', '-O', 'dts', - '-o', out_dts]) + utils.run_and_log(cons, ['dtc', orig_fname, '-I', 'dtb', '-O', 'dts', + '-o', out_dts]) # Update it to use an old tag with open(out_dts) as inf:
@@ -45,7 +45,7 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): with open(dts_fname, 'w') as outf: print(data, file=outf) dtb_fname = os.path.join(dt_dir, 'sandbox_oldtag.dtb') - util.run_and_log(cons, ['dtc', dts_fname, '-o', dtb_fname]) + utils.run_and_log(cons, ['dtc', dts_fname, '-o', dtb_fname]) migrate = ['-a', '~CONFIG_OF_TAG_MIGRATE'] if disable_migrate else []
@@ -54,7 +54,7 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): env['EXT_DTB'] = dtb_fname env['DEVICE_TREE'] = 'sandbox_new' env['NO_LTO'] = '1' # Speed up build - out = util.run_and_log( + out = utils.run_and_log( cons, ['./tools/buildman/buildman', '-m', '--board', board, *migrate, '-w', '-o', tmpdir], ignore_errors=True, env=env) return out
@@ -70,7 +70,7 @@ def test_of_no_migrate(ubman): # It should fail to run, since the lcd device will not be bound before # relocation. so won't get its frame-buffer memory - out = util.run_and_log( + out = utils.run_and_log( cons, [os.path.join(TMPDIR1, 'u-boot'), '-D', '-c', 'help'], ignore_errors=True) assert "Video device 'lcd' cannot allocate frame buffer memory" in out
@@ -102,7 +102,7 @@ def test_of_migrate(ubman): 'sandbox', TMPDIR3, disable_migrate=False) # It should show a migration message - out = util.run_and_log( + out = utils.run_and_log( cons, [os.path.join(TMPDIR3, 'u-boot'), '-D', '-c', 'help'], ignore_errors=True) assert "Warning: Device tree includes old 'u-boot,dm-' tags" in out
test/py/tests/test_ofplatdata.py +2 -2
@@ -2,7 +2,7 @@ # Copyright (c) 2016 Google, Inc import pytest -import utils as util +import utils @pytest.mark.boardspec('sandbox_spl') @pytest.mark.buildconfigspec('spl_of_platdata')
@@ -11,7 +11,7 @@ def test_spl_devicetree(ubman): cons = ubman dtb = cons.config.build_dir + '/spl/u-boot-spl.dtb' fdtgrep = cons.config.build_dir + '/tools/fdtgrep' - output = util.run_and_log(cons, [fdtgrep, '-l', dtb]) + output = utils.run_and_log(cons, [fdtgrep, '-l', dtb]) assert "bootph-all" not in output assert "bootph-some-ram" not in output
test/py/tests/test_optee_rpmb.py +1 -1
@@ -7,7 +7,7 @@ This tests optee_rpmb cmd in U-Boot """ import pytest -import utils as util +import utils @pytest.mark.buildconfigspec('cmd_optee_rpmb') def test_optee_rpmb_read_write(ubman):
test/py/tests/test_sandbox_opts.py +3 -3
@@ -4,7 +4,7 @@ import pytest -import utils as util +import utils # This is needed for Azure, since the default '..' directory is not writeable TMPDIR = '/tmp/test_cmdline'
@@ -15,7 +15,7 @@ def test_sandbox_cmdline(ubman): """Test building sandbox without CONFIG_CMDLINE""" cons = ubman - out = util.run_and_log( + utils.run_and_log( cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', '~CMDLINE', '-o', TMPDIR])
@@ -25,6 +25,6 @@ def test_sandbox_lto(ubman): """Test building sandbox without CONFIG_LTO""" cons = ubman - out = util.run_and_log( + utils.run_and_log( cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', '~LTO', '-o', TMPDIR])
test/py/tests/test_scp03.py +1 -1
@@ -11,7 +11,7 @@ For additional details check doc/usage/scp03.rst """ import pytest -import utils as util +import utils @pytest.mark.buildconfigspec('cmd_scp03') def test_scp03(ubman):
test/py/tests/test_source.py +2 -2
@@ -3,7 +3,7 @@ import os import pytest -import utils as util +import utils @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('cmd_echo')
@@ -15,7 +15,7 @@ def test_source(ubman): mkimage = os.path.join(cons.config.build_dir, 'tools/mkimage') its = os.path.join(cons.config.source_dir, 'test/py/tests/source.its') fit = os.path.join(cons.config.build_dir, 'source.itb') - util.run_and_log(cons, (mkimage, '-f', its, fit)) + utils.run_and_log(cons, (mkimage, '-f', its, fit)) cons.run_command(f'host load hostfs - $loadaddr {fit}') assert '2' in cons.run_command('source')
test/py/tests/test_trace.py +9 -9
@@ -6,7 +6,7 @@ import os import pytest import re -import utils as util +import utils # This is needed for Azure, since the default '..' directory is not writeable TMPDIR = '/tmp/test_trace'
@@ -80,12 +80,12 @@ def check_function(cons, fname, proftool, map_fname, trace_dat): map_fname (str): Filename of System.map trace_dat (str): Filename of output file """ - out = util.run_and_log( + out = utils.run_and_log( cons, [proftool, '-t', fname, '-o', trace_dat, '-m', map_fname, 'dump-ftrace']) # Check that trace-cmd can read it - out = util.run_and_log(cons, ['trace-cmd', 'dump', trace_dat]) + out = utils.run_and_log(cons, ['trace-cmd', 'dump', trace_dat]) # Tracing meta data in file /tmp/test_trace/trace.dat: # [Initial format]
@@ -114,7 +114,7 @@ def check_function(cons, fname, proftool, map_fname, trace_dat): # Check that the trace has something useful cmd = f"trace-cmd report -l {trace_dat} |grep -E '(initf_|initr_)'" - out = util.run_and_log(cons, ['sh', '-c', cmd]) + out = utils.run_and_log(cons, ['sh', '-c', cmd]) # Format: # u-boot-1 0..... 60.805596: function: initf_malloc
@@ -156,13 +156,13 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat): """ # Generate the funcgraph format - out = util.run_and_log( + out = utils.run_and_log( cons, [proftool, '-t', fname, '-o', trace_dat, '-m', map_fname, 'dump-ftrace', '-f', 'funcgraph']) # Check that the trace has what we expect cmd = f'trace-cmd report -l {trace_dat} |head -n 70' - out = util.run_and_log(cons, ['sh', '-c', cmd]) + out = utils.run_and_log(cons, ['sh', '-c', cmd]) # First look for this: # u-boot-1 0..... 282.101360: funcgraph_entry: 0.004 us | initf_malloc();
@@ -204,7 +204,7 @@ def check_funcgraph(cons, fname, proftool, map_fname, trace_dat): # Now look for initf_dm() and dm_timer_init() so we can check the bootstage # time cmd = f"trace-cmd report -l {trace_dat} |grep -E '(initf_dm|dm_timer_init)'" - out = util.run_and_log(cons, ['sh', '-c', cmd]) + out = utils.run_and_log(cons, ['sh', '-c', cmd]) start_timestamp = None end_timestamp = None
@@ -241,7 +241,7 @@ def check_flamegraph(cons, fname, proftool, map_fname, trace_fg): """ # Generate the flamegraph format - out = util.run_and_log( + out = utils.run_and_log( cons, [proftool, '-t', fname, '-o', trace_fg, '-m', map_fname, 'dump-flamegraph'])
@@ -258,7 +258,7 @@ def check_flamegraph(cons, fname, proftool, map_fname, trace_fg): assert found == 2 # Generate the timing graph - out = util.run_and_log( + utils.run_and_log( cons, [proftool, '-t', fname, '-o', trace_fg, '-m', map_fname, 'dump-flamegraph', '-f', 'timing'])
test/py/tests/test_vboot.py +36 -34
198 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH v2 3/6] test/py: Drop importing utils as util
Hi Simon,
Thank you for the patch.
Quoted 20 lines · Simon Glass
Now that we have a shorter name, we don't need this sort of thing. Drop it.
Signed-off-by Simon Glass <[email protected]>---
Changes in v2:
- Add new patch to drop importing utils as utiltest/py/tests/fit_util.py | 6 +-- test/py/tests/test_android/test_avb.py | 1 - test/py/tests/test_efi_fit.py | 24 +++++---- test/py/tests/test_event_dump.py | 4 +- test/py/tests/test_fit.py | 4 +- test/py/tests/test_fit_auto_signed.py | 18 +++---- test/py/tests/test_fit_ecdsa.py | 16 +++--- test/py/tests/test_fit_hashes.py | 14 +++--- test/py/tests/test_fs/conftest.py | 1 - test/py/tests/test_kconfig.py | 6 +-- test/py/tests/test_of_migrate.py | 14 +++---
Quoted 8 lines
test/py/tests/test_ofplatdata.py | 4 +- test/py/tests/test_optee_rpmb.py | 2 +- test/py/tests/test_sandbox_opts.py | 6 +-- test/py/tests/test_scp03.py | 2 +- test/py/tests/test_source.py | 4 +- test/py/tests/test_trace.py | 18 +++---- test/py/tests/test_vboot.py | 70 +++++++++++++------------- 18 files changed, 110 insertions(+), 104 deletions(-)
Quoted 1 line
[...]
PATCH v2 4/6 test/py: Drop assigning ubman to cons
In reply to Simon GlassNow that we have a shorter name, we don't need this sort of thing. Just use ubman instead.
---
Changes in v2:
- Add new patch to drop assigning ubman to cons
test/py/tests/test_android/test_abootimg.py | 43 +++--- test/py/tests/test_efi_fit.py | 81 +++++----- test/py/tests/test_env.py | 12 +- test/py/tests/test_event_dump.py | 5 +- test/py/tests/test_fit.py | 63 ++++---- test/py/tests/test_fit_auto_signed.py | 27 ++-- test/py/tests/test_fit_ecdsa.py | 25 ++-- test/py/tests/test_fit_hashes.py | 23 ++- test/py/tests/test_handoff.py | 3 +- test/py/tests/test_help.py | 14 +- test/py/tests/test_kconfig.py | 6 +- test/py/tests/test_log.py | 14 +- test/py/tests/test_mmc.py | 8 +- test/py/tests/test_of_migrate.py | 27 ++-- test/py/tests/test_ofplatdata.py | 7 +- test/py/tests/test_sandbox_opts.py | 6 +- test/py/tests/test_source.py | 41 +++-- test/py/tests/test_spl.py | 5 +- test/py/tests/test_suite.py | 68 ++++----- test/py/tests/test_tpm2.py | 4 +- test/py/tests/test_trace.py | 57 ++++--- test/py/tests/test_upl.py | 11 +- test/py/tests/test_ut.py | 158 ++++++++++---------- test/py/tests/test_vbe.py | 15 +- test/py/tests/test_vbe_vpl.py | 21 ++- test/py/tests/test_vboot.py | 146 +++++++++--------- test/py/tests/test_vpl.py | 5 +- 27 files changed, 432 insertions(+), 463 deletions(-)
test/py/tests/test_android/test_abootimg.py +21 -22
@@ -232,38 +232,37 @@ def test_abootimg(abootimg_disk_image, ubman): def test_abootimgv4(abootimgv4_disk_image_vboot, abootimgv4_disk_image_boot, ubman): """Test the 'abootimg' command with boot image header v4.""" - cons = ubman - cons.log.action('Loading disk image to RAM...') - cons.run_command('setenv loadaddr 0x%x' % (loadaddr)) - cons.run_command('setenv vloadaddr 0x%x' % (vloadaddr)) - cons.run_command('host load hostfs - 0x%x %s' % (vloadaddr, + ubman.log.action('Loading disk image to RAM...') + ubman.run_command('setenv loadaddr 0x%x' % (loadaddr)) + ubman.run_command('setenv vloadaddr 0x%x' % (vloadaddr)) + ubman.run_command('host load hostfs - 0x%x %s' % (vloadaddr, abootimgv4_disk_image_vboot.path)) - cons.run_command('host load hostfs - 0x%x %s' % (loadaddr, + ubman.run_command('host load hostfs - 0x%x %s' % (loadaddr, abootimgv4_disk_image_boot.path)) - cons.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr)) - cons.log.action('Testing \'abootimg get ver\'...') - response = cons.run_command('abootimg get ver') + ubman.run_command('abootimg addr 0x%x 0x%x' % (loadaddr, vloadaddr)) + ubman.log.action('Testing \'abootimg get ver\'...') + response = ubman.run_command('abootimg get ver') assert response == "4" - cons.run_command('abootimg get ver v') - response = cons.run_command('env print v') + ubman.run_command('abootimg get ver v') + response = ubman.run_command('env print v') assert response == 'v=4' - cons.log.action('Testing \'abootimg get recovery_dtbo\'...') - response = cons.run_command('abootimg get recovery_dtbo a') + ubman.log.action('Testing \'abootimg get recovery_dtbo\'...') + response = ubman.run_command('abootimg get recovery_dtbo a') assert response == 'Error: header version must be >= 1 and <= 2 to get dtbo' - cons.log.action('Testing \'abootimg get dtb_load_addr\'...') - cons.run_command('abootimg get dtb_load_addr a') - response = cons.run_command('env print a') + ubman.log.action('Testing \'abootimg get dtb_load_addr\'...') + ubman.run_command('abootimg get dtb_load_addr a') + response = ubman.run_command('env print a') assert response == 'a=11f00000' - cons.log.action('Testing \'abootimg get dtb --index\'...') - cons.run_command('abootimg get dtb --index=1 dtb2_start') - response = cons.run_command('env print dtb2_start') + ubman.log.action('Testing \'abootimg get dtb --index\'...') + ubman.run_command('abootimg get dtb --index=1 dtb2_start') + response = ubman.run_command('env print dtb2_start') correct_str = "dtb2_start=%x" % (dtb2_addr) assert response == correct_str - cons.run_command('fdt addr $dtb2_start') - cons.run_command('fdt get value v / model') - response = cons.run_command('env print v') + ubman.run_command('fdt addr $dtb2_start') + ubman.run_command('fdt get value v / model') + response = ubman.run_command('env print v') assert response == 'v=x2'
test/py/tests/test_efi_fit.py +40 -41
214 lines not on this page · raw message
test/py/tests/test_env.py +5 -7
@@ -177,9 +177,8 @@ def validate_set(state_test_env, var, value): @pytest.mark.boardspec('sandbox') def test_env_initial_env_file(ubman): """Test that the u-boot-initial-env make target works""" - cons = ubman - builddir = 'O=' + cons.config.build_dir - envfile = cons.config.build_dir + '/u-boot-initial-env' + builddir = 'O=' + ubman.config.build_dir + envfile = ubman.config.build_dir + '/u-boot-initial-env' # remove if already exists from an older run try:
@@ -187,7 +186,7 @@ def test_env_initial_env_file(ubman): except: pass - utils.run_and_log(cons, ['make', builddir, 'u-boot-initial-env']) + utils.run_and_log(ubman, ['make', builddir, 'u-boot-initial-env']) assert os.path.exists(envfile)
@@ -560,15 +559,14 @@ def test_env_text(ubman): fname = os.path.join(path, 'infile') with open(fname, 'w') as inf: print(intext, file=inf) - result = utils.run_and_log(cons, ['awk', '-f', script, fname]) + result = utils.run_and_log(ubman, ['awk', '-f', script, fname]) if expect_val is not None: expect = '#define CONFIG_EXTRA_ENV_TEXT "%s"\n' % expect_val assert result == expect else: assert result == '' - cons = ubman - script = os.path.join(cons.config.source_dir, 'scripts', 'env2string.awk') + script = os.path.join(ubman.config.source_dir, 'scripts', 'env2string.awk') # simple script with a single var check_script('fred=123', 'fred=123\\0')
test/py/tests/test_event_dump.py +2 -3
@@ -11,9 +11,8 @@ import utils @pytest.mark.boardspec('sandbox') def test_event_dump(ubman): """Test that the "help" command can be executed.""" - cons = ubman - sandbox = cons.config.build_dir + '/u-boot' - out = utils.run_and_log(cons, ['scripts/event_dump.py', sandbox]) + sandbox = ubman.config.build_dir + '/u-boot' + out = utils.run_and_log(ubman, ['scripts/event_dump.py', sandbox]) expect = '''.*Event type Id Source location -------------------- ------------------------------ ------------------------------ EVT_FT_FIXUP bootmeth_vbe_ft_fixup .*boot/vbe_request.c:.*
test/py/tests/test_fit.py +31 -32
141 lines not on this page · raw message
test/py/tests/test_fit_auto_signed.py +13 -14
@@ -26,22 +26,22 @@ from Cryptodome.Signature import pkcs1_15 class SignedFitHelper(object): """Helper to manipulate a FIT with signed/hashed images/configs.""" - def __init__(self, cons, file_name): + def __init__(self, ubman, file_name): self.fit = file_name - self.cons = cons + self.ubman = ubman self.images_nodes = set() self.confgs_nodes = set() def __fdt_list(self, path): - return utils.run_and_log(self.cons, + return utils.run_and_log(self.ubman, f'fdtget -l {self.fit} {path}') def __fdt_get_string(self, node, prop): - return utils.run_and_log(self.cons, + return utils.run_and_log(self.ubman, f'fdtget -ts {self.fit} {node} {prop}') def __fdt_get_binary(self, node, prop): - numbers = utils.run_and_log(self.cons, + numbers = utils.run_and_log(self.ubman, f'fdtget -tbi {self.fit} {node} {prop}') bignum = bytearray()
@@ -133,9 +133,8 @@ def test_fit_auto_signed(ubman): The test does not run the sandbox. It only checks the host tool mkimage. """ - cons = ubman - mkimage = cons.config.build_dir + '/tools/mkimage' - tempdir = os.path.join(cons.config.result_dir, 'auto_fit') + mkimage = ubman.config.build_dir + '/tools/mkimage' + tempdir = os.path.join(ubman.config.result_dir, 'auto_fit') os.makedirs(tempdir, exist_ok=True) kernel_file = f'{tempdir}/vmlinuz' dt1_file = f'{tempdir}/dt-1.dtb'
@@ -166,29 +165,29 @@ def test_fit_auto_signed(ubman): s_args = " -k" + tempdir + " -g" + key_name + " -o" + sign_algo # 1 - Create auto FIT with images crc32 checksum, and verify it - utils.run_and_log(cons, mkimage + ' -fauto' + b_args + " " + fit_file) + utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + " " + fit_file) - fit = SignedFitHelper(cons, fit_file) + fit = SignedFitHelper(ubman, fit_file) if fit.build_nodes_sets() == 0: raise ValueError('FIT-1 has no "/image" nor "/configuration" nodes') fit.check_fit_crc32_images() # 2 - Create auto FIT with signed images, and verify it - utils.run_and_log(cons, mkimage + ' -fauto' + b_args + s_args + " " + + utils.run_and_log(ubman, mkimage + ' -fauto' + b_args + s_args + " " + fit_file) - fit = SignedFitHelper(cons, fit_file) + fit = SignedFitHelper(ubman, fit_file) if fit.build_nodes_sets() == 0: raise ValueError('FIT-2 has no "/image" nor "/configuration" nodes') fit.check_fit_signed_images(key_name, sign_algo, verifier) # 3 - Create auto FIT with signed configs and hashed images, and verify it - utils.run_and_log(cons, mkimage + ' -fauto-conf' + b_args + s_args + " " + + utils.run_and_log(ubman, mkimage + ' -fauto-conf' + b_args + s_args + " " + fit_file) - fit = SignedFitHelper(cons, fit_file) + fit = SignedFitHelper(ubman, fit_file) if fit.build_nodes_sets() == 0: raise ValueError('FIT-3 has no "/image" nor "/configuration" nodes')
test/py/tests/test_fit_ecdsa.py +12 -13
@@ -19,21 +19,21 @@ from Cryptodome.Signature import DSS class SignableFitImage(object): """ Helper to manipulate a FIT image on disk """ - def __init__(self, cons, file_name): + def __init__(self, ubman, file_name): self.fit = file_name - self.cons = cons + self.ubman = ubman self.signable_nodes = set() def __fdt_list(self, path): - return utils.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') + return utils.run_and_log(self.ubman, f'fdtget -l {self.fit} {path}') def __fdt_set(self, node, **prop_value): for prop, value in prop_value.items(): - utils.run_and_log(self.cons, + utils.run_and_log(self.ubman, f'fdtput -ts {self.fit} {node} {prop} {value}') def __fdt_get_binary(self, node, prop): - numbers = utils.run_and_log(self.cons, + numbers = utils.run_and_log(self.ubman, f'fdtget -tbi {self.fit} {node} {prop}') bignum = bytearray()
@@ -55,7 +55,7 @@ class SignableFitImage(object): self.__fdt_set(f'{image}/signature', algo='sha256,ecdsa256') def sign(self, mkimage, key_file): - utils.run_and_log(self.cons, [mkimage, '-F', self.fit, f'-G{key_file}']) + utils.run_and_log(self.ubman, [mkimage, '-F', self.fit, f'-G{key_file}']) def check_signatures(self, key): for image in self.signable_nodes:
@@ -78,16 +78,15 @@ def test_fit_ecdsa(ubman): def assemble_fit_image(dest_fit, its, destdir): dtc_args = f'-I dts -O dtb -i {destdir}' - utils.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) + utils.run_and_log(ubman, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) def dtc(dts): dtb = dts.replace('.dts', '.dtb') - utils.run_and_log(cons, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') + utils.run_and_log(ubman, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') - cons = ubman - mkimage = cons.config.build_dir + '/tools/mkimage' - datadir = cons.config.source_dir + '/test/py/tests/vboot/' - tempdir = os.path.join(cons.config.result_dir, 'ecdsa') + mkimage = ubman.config.build_dir + '/tools/mkimage' + datadir = ubman.config.source_dir + '/test/py/tests/vboot/' + tempdir = os.path.join(ubman.config.result_dir, 'ecdsa') os.makedirs(tempdir, exist_ok=True) key_file = f'{tempdir}/ecdsa-test-key.pem' fit_file = f'{tempdir}/test.fit'
@@ -105,7 +104,7 @@ def test_fit_ecdsa(ubman): assemble_fit_image(fit_file, f'{datadir}/sign-images-sha256.its', tempdir) - fit = SignableFitImage(cons, fit_file) + fit = SignableFitImage(ubman, fit_file) nodes = fit.find_signable_image_nodes() if len(nodes) == 0: raise ValueError('FIT image has no "/image" nodes with "signature"')
test/py/tests/test_fit_hashes.py +11 -12
@@ -26,20 +26,20 @@ kernel_hashes = { class ReadonlyFitImage(object): """ Helper to manipulate a FIT image on disk """ - def __init__(self, cons, file_name): + def __init__(self, ubman, file_name): self.fit = file_name - self.cons = cons + self.ubman = ubman self.hashable_nodes = set() def __fdt_list(self, path): - return utils.run_and_log(self.cons, f'fdtget -l {self.fit} {path}') + return utils.run_and_log(self.ubman, f'fdtget -l {self.fit} {path}') def __fdt_get(self, node, prop): - val = utils.run_and_log(self.cons, f'fdtget {self.fit} {node} {prop}') + val = utils.run_and_log(self.ubman, f'fdtget {self.fit} {node} {prop}') return val.rstrip('\n') def __fdt_get_sexadecimal(self, node, prop): - numbers = utils.run_and_log(self.cons, + numbers = utils.run_and_log(self.ubman, f'fdtget -tbx {self.fit} {node} {prop}') sexadecimal = ''
@@ -86,17 +86,16 @@ def test_mkimage_hashes(ubman): def assemble_fit_image(dest_fit, its, destdir): dtc_args = f'-I dts -O dtb -i {destdir}' - utils.run_and_log(cons, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) + utils.run_and_log(ubman, [mkimage, '-D', dtc_args, '-f', its, dest_fit]) def dtc(dts): dtb = dts.replace('.dts', '.dtb') - utils.run_and_log(cons, + utils.run_and_log(ubman, f'dtc {datadir}/{dts} -O dtb -o {tempdir}/{dtb}') - cons = ubman - mkimage = cons.config.build_dir + '/tools/mkimage' - datadir = cons.config.source_dir + '/test/py/tests/vboot/' - tempdir = os.path.join(cons.config.result_dir, 'hashes') + mkimage = ubman.config.build_dir + '/tools/mkimage' + datadir = ubman.config.source_dir + '/test/py/tests/vboot/' + tempdir = os.path.join(ubman.config.result_dir, 'hashes') os.makedirs(tempdir, exist_ok=True) fit_file = f'{tempdir}/test.fit'
@@ -108,7 +107,7 @@ def test_mkimage_hashes(ubman): assemble_fit_image(fit_file, f'{datadir}/hash-images.its', tempdir) - fit = ReadonlyFitImage(cons, fit_file) + fit = ReadonlyFitImage(ubman, fit_file) nodes = fit.find_hashable_image_nodes() if len(nodes) == 0: raise ValueError('FIT image has no "/image" nodes with "hash-..."')
test/py/tests/test_handoff.py +1 -2
@@ -10,6 +10,5 @@ TEST_HANDOFF_MAGIC = 0x14f93c7b @pytest.mark.buildconfigspec('spl') def test_handoff(ubman): """Test that of-platdata can be generated and used in sandbox""" - cons = ubman - response = cons.run_command('sb handoff') + response = ubman.run_command('sb handoff') assert ('SPL handoff magic %x' % TEST_HANDOFF_MAGIC) in response
test/py/tests/test_help.py +6 -8
@@ -16,10 +16,9 @@ def test_help(ubman): @pytest.mark.boardspec('sandbox') def test_help_no_devicetree(ubman): try: - cons = ubman - cons.restart_uboot_with_flags([], use_dtb=False) - cons.run_command('help') - output = cons.get_spawn_output().replace('\r', '') + ubman.restart_uboot_with_flags([], use_dtb=False) + ubman.run_command('help') + output = ubman.get_spawn_output().replace('\r', '') assert 'print command description/usage' in output finally: # Restart afterward to get the normal device tree back
@@ -28,10 +27,9 @@ def test_help_no_devicetree(ubman): @pytest.mark.boardspec('sandbox_vpl') def test_vpl_help(ubman): try: - cons = ubman - cons.restart_uboot() - cons.run_command('help') - output = cons.get_spawn_output().replace('\r', '') + ubman.restart_uboot() + ubman.run_command('help') + output = ubman.get_spawn_output().replace('\r', '') assert 'print command description/usage' in output finally: # Restart afterward to get the normal device tree back
test/py/tests/test_kconfig.py +2 -4
@@ -13,11 +13,10 @@ TMPDIR = '/tmp/test_kconfig' @pytest.mark.boardspec('sandbox') def test_kconfig(ubman): """Test build failures when IF_ENABLED_INT() option is not enabled""" - cons = ubman # This detects build errors in test/lib/kconfig.c out = utils.run_and_log( - cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', + ubman, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True) assert 'invalid_use_of_IF_ENABLED_INT' in out assert 'invalid_use_of_CONFIG_IF_ENABLED_INT' in out
@@ -26,11 +25,10 @@ def test_kconfig(ubman): @pytest.mark.boardspec('sandbox_spl') def test_kconfig_spl(ubman): """Test build failures when IF_ENABLED_INT() option is not enabled""" - cons = ubman # This detects build errors in test/lib/kconfig_spl.c out = utils.run_and_log( - cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox_spl', + ubman, ['./tools/buildman/buildman', '-m', '--board', 'sandbox_spl', '-a', 'TEST_KCONFIG', '-o', TMPDIR], ignore_errors=True) assert 'invalid_use_of_IF_ENABLED_INT' in out
test/py/tests/test_log.py +6 -8
@@ -20,18 +20,17 @@ def test_log_format(ubman): fmt: Format to use for 'log format' expected_output: Expected output from the 'log rec' command """ - output = cons.run_command('log format %s' % fmt) + output = ubman.run_command('log format %s' % fmt) assert output == '' - output = cons.run_command('log rec arch notice file.c 123 func msg') + output = ubman.run_command('log rec arch notice file.c 123 func msg') assert output == expected_output - cons = ubman - with cons.log.section('format'): + with ubman.log.section('format'): pad = int(ubman.config.buildconfig.get('config_logf_func_pad')) padding = ' ' * (pad - len('func')) run_with_format('all', f'NOTICE.arch,file.c:123-{padding}func() msg') - output = cons.run_command('log format') + output = ubman.run_command('log format') assert output == 'Log format: clFLfm' run_with_format('fm', f'{padding}func() msg')
@@ -45,7 +44,6 @@ def test_log_format(ubman): def test_log_dropped(ubman): """Test dropped 'log' message when debug_uart is activated""" - cons = ubman - cons.restart_uboot() - output = cons.get_spawn_output().replace('\r', '') + ubman.restart_uboot() + output = ubman.get_spawn_output().replace('\r', '') assert (not 'debug: main' in output)
test/py/tests/test_mmc.py +4 -4
@@ -32,19 +32,19 @@ devices = {} mmc_modes_name = [] mmc_modes = [] -def setup_mmc_modes(cons): +def setup_mmc_modes(ubman): global mmc_modes, mmc_modes_name - f = cons.config.env.get('env__mmc_device', None) + f = ubman.config.env.get('env__mmc_device', None) if f: mmc_modes_name = f.get('mmc_modes', None) # Set mmc mode to default mode (legacy), if speed mode config isn't enabled - if cons.config.buildconfig.get('config_mmc_speed_mode_set', 'n') != 'y': + if ubman.config.buildconfig.get('config_mmc_speed_mode_set', 'n') != 'y': mmc_modes = [0] return if mmc_modes_name: - mmc_help = cons.run_command('mmc -help') + mmc_help = ubman.run_command('mmc -help') m = re.search(r"\[MMC_LEGACY(.*\n.+])", mmc_help) modes = [ x.strip()
test/py/tests/test_of_migrate.py +12 -15
@@ -14,11 +14,11 @@ TMPDIR1 = '/tmp/test_no_migrate' TMPDIR2 = '/tmp/test_no_migrate_spl' TMPDIR3 = '/tmp/test_migrate' -def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): +def build_for_migrate(ubman, replace_pair, board, tmpdir, disable_migrate=True): """Build an updated U-Boot with a slightly modified device tree Args: - cons (ConsoleBase): U-Boot console + ubman (ConsoleBase): U-Boot console replace_pair (tuple): String to find String to replace it with
@@ -26,14 +26,14 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): tmpdir (str): Temporary directory to use disable_migrate (bool): True to disable CONFIG_OF_TAG_MIGRATE in build """ - srcdir = cons.config.source_dir - build_dir = cons.config.build_dir + srcdir = ubman.config.source_dir + build_dir = ubman.config.build_dir # Get the source for the existing dts dt_dir = os.path.join(build_dir, 'arch', 'sandbox', 'dts') orig_fname = os.path.join(dt_dir, 'sandbox.dtb') out_dts = os.path.join(dt_dir, 'sandbox_out.dts') - utils.run_and_log(cons, ['dtc', orig_fname, '-I', 'dtb', '-O', 'dts', + utils.run_and_log(ubman, ['dtc', orig_fname, '-I', 'dtb', '-O', 'dts', '-o', out_dts]) # Update it to use an old tag
@@ -45,7 +45,7 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): with open(dts_fname, 'w') as outf: print(data, file=outf) dtb_fname = os.path.join(dt_dir, 'sandbox_oldtag.dtb') - utils.run_and_log(cons, ['dtc', dts_fname, '-o', dtb_fname]) + utils.run_and_log(ubman, ['dtc', dts_fname, '-o', dtb_fname]) migrate = ['-a', '~CONFIG_OF_TAG_MIGRATE'] if disable_migrate else []
@@ -55,7 +55,7 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): env['DEVICE_TREE'] = 'sandbox_new' env['NO_LTO'] = '1' # Speed up build out = utils.run_and_log( - cons, ['./tools/buildman/buildman', '-m', '--board', board, + ubman, ['./tools/buildman/buildman', '-m', '--board', board, *migrate, '-w', '-o', tmpdir], ignore_errors=True, env=env) return out
@@ -63,15 +63,14 @@ def build_for_migrate(cons, replace_pair, board, tmpdir, disable_migrate=True): @pytest.mark.boardspec('sandbox') def test_of_no_migrate(ubman): """Test sandbox with old boot phase tags like u-boot,dm-pre-proper""" - cons = ubman - build_for_migrate(cons, ['bootph-some-ram', 'u-boot,dm-pre-proper'], + build_for_migrate(ubman, ['bootph-some-ram', 'u-boot,dm-pre-proper'], 'sandbox', TMPDIR1) # It should fail to run, since the lcd device will not be bound before # relocation. so won't get its frame-buffer memory out = utils.run_and_log( - cons, [os.path.join(TMPDIR1, 'u-boot'), '-D', '-c', 'help'], + ubman, [os.path.join(TMPDIR1, 'u-boot'), '-D', '-c', 'help'], ignore_errors=True) assert "Video device 'lcd' cannot allocate frame buffer memory" in out
@@ -82,9 +81,8 @@ def test_of_no_migrate(ubman): @pytest.mark.boardspec('!sandbox_tpl') def test_of_no_migrate_spl(ubman): """Test sandbox with old boot phase tags like u-boot,dm-spl""" - cons = ubman - out = build_for_migrate(cons, ['bootph-pre-ram', 'u-boot,dm-spl'], + out = build_for_migrate(ubman, ['bootph-pre-ram', 'u-boot,dm-spl'], 'sandbox_spl', TMPDIR2) # It should fail to build, since the SPL DT will not include 'spl-test'
@@ -96,13 +94,12 @@ def test_of_no_migrate_spl(ubman): @pytest.mark.boardspec('sandbox') def test_of_migrate(ubman): """Test sandbox shows a message when tags were migrated""" - cons = ubman - build_for_migrate(cons, ['bootph-some-ram', 'u-boot,dm-pre-proper'], + build_for_migrate(ubman, ['bootph-some-ram', 'u-boot,dm-pre-proper'], 'sandbox', TMPDIR3, disable_migrate=False) # It should show a migration message out = utils.run_and_log( - cons, [os.path.join(TMPDIR3, 'u-boot'), '-D', '-c', 'help'], + ubman, [os.path.join(TMPDIR3, 'u-boot'), '-D', '-c', 'help'], ignore_errors=True) assert "Warning: Device tree includes old 'u-boot,dm-' tags" in out
test/py/tests/test_ofplatdata.py +3 -4
@@ -8,10 +8,9 @@ import utils @pytest.mark.buildconfigspec('spl_of_platdata') def test_spl_devicetree(ubman): """Test content of spl device-tree""" - cons = ubman - dtb = cons.config.build_dir + '/spl/u-boot-spl.dtb' - fdtgrep = cons.config.build_dir + '/tools/fdtgrep' - output = utils.run_and_log(cons, [fdtgrep, '-l', dtb]) + dtb = ubman.config.build_dir + '/spl/u-boot-spl.dtb' + fdtgrep = ubman.config.build_dir + '/tools/fdtgrep' + output = utils.run_and_log(ubman, [fdtgrep, '-l', dtb]) assert "bootph-all" not in output assert "bootph-some-ram" not in output
test/py/tests/test_sandbox_opts.py +2 -4
@@ -13,18 +13,16 @@ TMPDIR = '/tmp/test_cmdline' @pytest.mark.boardspec('sandbox') def test_sandbox_cmdline(ubman): """Test building sandbox without CONFIG_CMDLINE""" - cons = ubman utils.run_and_log( - cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', + ubman, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', '~CMDLINE', '-o', TMPDIR]) @pytest.mark.slow @pytest.mark.boardspec('sandbox') def test_sandbox_lto(ubman): """Test building sandbox without CONFIG_LTO""" - cons = ubman utils.run_and_log( - cons, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', + ubman, ['./tools/buildman/buildman', '-m', '--board', 'sandbox', '-a', '~LTO', '-o', TMPDIR])
test/py/tests/test_source.py +20 -21
47 lines not on this page · raw message
test/py/tests/test_spl.py +2 -3
@@ -33,9 +33,8 @@ def test_spl(ubman, ut_spl_subtest): ut_subtest (str): SPL test to be executed (e.g. 'dm platdata_phandle') """ try: - cons = ubman - cons.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]]) - output = cons.get_spawn_output().replace('\r', '') + ubman.restart_uboot_with_flags(['-u', '-k', ut_spl_subtest.split()[1]]) + output = ubman.get_spawn_output().replace('\r', '') assert 'failures: 0' in output finally: # Restart afterward in case a non-SPL test is run next. This should not
test/py/tests/test_suite.py +34 -34
158 lines not on this page · raw message
test/py/tests/test_tpm2.py +2 -2
@@ -50,9 +50,9 @@ def force_init(ubman, force=False): ubman.run_command('tpm2 clear TPM2_RH_PLATFORM') ubman.run_command('echo --- end of init ---') -def is_sandbox(cons): +def is_sandbox(ubman): # Array slice removes leading/trailing quotes. - sys_arch = cons.config.buildconfig.get('config_sys_arch', '"sandbox"')[1:-1] + sys_arch = ubman.config.buildconfig.get('config_sys_arch', '"sandbox"')[1:-1] return sys_arch == 'sandbox' @pytest.mark.buildconfigspec('cmd_tpm_v2')
test/py/tests/test_trace.py +28 -29
178 lines not on this page · raw message
test/py/tests/test_upl.py +5 -6
@@ -19,20 +19,19 @@ def test_upl_handoff(ubman): The entire FIT is loaded into memory in SPL (in upl_load_from_image()) so that it can be inpected in upl_test_info_norun """ - cons = ubman - ram = os.path.join(cons.config.build_dir, 'ram.bin') - fdt = os.path.join(cons.config.build_dir, 'u-boot.dtb') + ram = os.path.join(ubman.config.build_dir, 'ram.bin') + fdt = os.path.join(ubman.config.build_dir, 'u-boot.dtb') # Remove any existing RAM file, so we don't have old data present if os.path.exists(ram): os.remove(ram) flags = ['-m', ram, '-d', fdt, '--upl'] - cons.restart_uboot_with_flags(flags, use_dtb=False) + ubman.restart_uboot_with_flags(flags, use_dtb=False) # Make sure that Universal Payload is detected in U-Boot proper - output = cons.run_command('upl info') + output = ubman.run_command('upl info') assert 'UPL state: active' == output # Check the FIT offsets look correct - output = cons.run_command('ut upl -f upl_test_info_norun') + output = ubman.run_command('ut upl -f upl_test_info_norun') assert 'failures: 0' in output
test/py/tests/test_ut.py +79 -79
361 lines not on this page · raw message
test/py/tests/test_vbe.py +7 -8
@@ -91,10 +91,9 @@ ut bootstd -f vbe_test_fixup_norun @pytest.mark.boardspec('sandbox_flattree') @pytest.mark.requiredtool('dtc') def test_vbe(ubman): - cons = ubman - kernel = fit_util.make_kernel(cons, 'vbe-kernel.bin', 'kernel') - fdt = fit_util.make_dtb(cons, base_fdt, 'vbe-fdt') - fdt_out = fit_util.make_fname(cons, 'fdt-out.dtb') + kernel = fit_util.make_kernel(ubman, 'vbe-kernel.bin', 'kernel') + fdt = fit_util.make_dtb(ubman, base_fdt, 'vbe-fdt') + fdt_out = fit_util.make_fname(ubman, 'fdt-out.dtb') params = { 'fit_addr' : 0x1000,
@@ -108,13 +107,13 @@ def test_vbe(ubman): 'compression' : 'none', } - mkimage = cons.config.build_dir + '/tools/mkimage' - fit = fit_util.make_fit(cons, mkimage, base_its, params, 'test-vbe.fit', + mkimage = ubman.config.build_dir + '/tools/mkimage' + fit = fit_util.make_fit(ubman, mkimage, base_its, params, 'test-vbe.fit', base_fdt) params['fit'] = fit cmd = base_script % params - with cons.log.section('Kernel load'): - output = cons.run_command_list(cmd.splitlines()) + with ubman.log.section('Kernel load'): + output = ubman.run_command_list(cmd.splitlines()) assert 'failures: 0' in output[-1]
test/py/tests/test_vbe_vpl.py +10 -11
@@ -11,30 +11,29 @@ import utils @pytest.mark.boardspec('sandbox_vpl') @pytest.mark.requiredtool('dtc') def test_vbe_vpl(ubman): - cons = ubman - #cmd = [cons.config.build_dir + fname, '-v'] - ram = os.path.join(cons.config.build_dir, 'ram.bin') - fdt = os.path.join(cons.config.build_dir, 'arch/sandbox/dts/test.dtb') - image_fname = os.path.join(cons.config.build_dir, 'image.bin') + #cmd = [ubman.config.build_dir + fname, '-v'] + ram = os.path.join(ubman.config.build_dir, 'ram.bin') + fdt = os.path.join(ubman.config.build_dir, 'arch/sandbox/dts/test.dtb') + image_fname = os.path.join(ubman.config.build_dir, 'image.bin') # Enable firmware1 and the mmc that it uses. These are needed for the full # VBE flow. utils.run_and_log( - cons, f'fdtput -t s {fdt} /bootstd/firmware0 status disabled') + ubman, f'fdtput -t s {fdt} /bootstd/firmware0 status disabled') utils.run_and_log( - cons, f'fdtput -t s {fdt} /bootstd/firmware1 status okay') + ubman, f'fdtput -t s {fdt} /bootstd/firmware1 status okay') utils.run_and_log( - cons, f'fdtput -t s {fdt} /mmc3 status okay') + ubman, f'fdtput -t s {fdt} /mmc3 status okay') utils.run_and_log( - cons, f'fdtput -t s {fdt} /mmc3 filename {image_fname}') + ubman, f'fdtput -t s {fdt} /mmc3 filename {image_fname}') # Remove any existing RAM file, so we don't have old data present if os.path.exists(ram): os.remove(ram) flags = ['-p', image_fname, '-w', '-s', 'state.dtb'] - cons.restart_uboot_with_flags(flags) + ubman.restart_uboot_with_flags(flags) # Make sure that VBE was used in both VPL (to load SPL) and SPL (to load # U-Boot - output = cons.run_command('vbe state') + output = ubman.run_command('vbe state') assert output == 'Phases: VPL SPL'
test/py/tests/test_vboot.py +72 -74
391 lines not on this page · raw message
test/py/tests/test_vpl.py +2 -3
@@ -23,9 +23,8 @@ def test_vpl(ubman, ut_vpl_subtest): ut_subtest (str): VPL test to be executed (e.g. 'dm platdata_phandle') """ try: - cons = ubman - cons.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]]) - output = cons.get_spawn_output().replace('\r', '') + ubman.restart_uboot_with_flags(['-u', '-k', ut_vpl_subtest.split()[1]]) + output = ubman.get_spawn_output().replace('\r', '') assert 'failures: 0' in output finally: # Restart afterward in case a non-VPL test is run next. This should not
Signature · 1 line
2.43.0
PATCH v2 5/6 test/py: Show info about module-loading
In reply to Simon GlassIt 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.
---
(no changes since v1)
test/py/conftest.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)
test/py/conftest.py +20 -13
@@ -289,19 +289,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
Re: [PATCH v2 5/6] test/py: Show info about module-loading
Quoted 46 lines · Simon Glass
It is sometimes tricky to figure out what modules
test.pyis 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.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/py/conftest.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)test/py/conftest.py +10
-13@@ -289,19 +289,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:
test/py/conftest.py def pytest_configure(config): · line 311
Quoted 10 lines
test/py/conftest.py +10
-0+ 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)}")
Since no platform contains all of those files this is too verbose.
Signature · 1 line
Tom
Re: [PATCH v2 5/6] test/py: Show info about module-loading
Hi Tom,
Quoted 53 lines · Tom Rini
Quoted 50 lines · Simon Glass
It is sometimes tricky to figure out what modules
test.pyis 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.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/py/conftest.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)test/py/conftest.py +14
-13@@ -289,19 +289,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)
Quoted 8 lines
test/py/conftest.py def pytest_configure(config): · line 311
Quoted 6 lines
test/py/conftest.py +6
-0+ 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)}")Since no platform contains all of those files this is too verbose.
So perhaps only show the message if all files are missing?
Regards,
Simon
Re: [PATCH v2 5/6] test/py: Show info about module-loading
Quoted 65 lines · Simon Glass
Hi Tom,
Quoted 53 lines · Tom Rini
Quoted 50 lines · Simon Glass
It is sometimes tricky to figure out what modules
test.pyis 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.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/py/conftest.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)test/py/conftest.py +14
-13@@ -289,19 +289,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)Quoted 8 lines
test/py/conftest.py def pytest_configure(config): · line 311
Quoted 6 lines
test/py/conftest.py +6
-0+ 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)}")Since no platform contains all of those files this is too verbose.
Quoted 1 line
So perhaps only show the message if all files are missing?
Sure. Or a log.debug maybe?
Signature · 1 line
Tom
Re: [PATCH v2 5/6] test/py: Show info about module-loading
Hi Tom,
Quoted 67 lines · Tom Rini
Quoted 65 lines · Simon Glass
Hi Tom,
Quoted 61 lines · Tom Rini
Quoted 46 lines · Simon Glass
It is sometimes tricky to figure out what modules
test.pyis 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.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/py/conftest.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)test/py/conftest.py +10
-13@@ -289,19 +289,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:test/py/conftest.py def pytest_configure(config): · line 311
Quoted 10 lines
test/py/conftest.py +10
-0+ 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)}")Since no platform contains all of those files this is too verbose.
Quoted 3 lines
Quoted 1 line
So perhaps only show the message if all files are missing?
Sure. Or a log.debug maybe?
The log.debug() doesn't show up though and people wouldn't know where to look. So if you are OK with having the message only if there is nothing, I will do that.
Regards,
SImon
Quoted 3 lines
--
Tom
Re: [PATCH v2 5/6] test/py: Show info about module-loading
Quoted 70 lines · Simon Glass
Hi Tom,
Quoted 67 lines · Tom Rini
Quoted 65 lines · Simon Glass
Hi Tom,
Quoted 61 lines · Tom Rini
Quoted 46 lines · Simon Glass
It is sometimes tricky to figure out what modules
test.pyis 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.
Signed-off-by Simon Glass <[email protected]>---
(no changes since v1)
test/py/conftest.py | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-)test/py/conftest.py +10
-13@@ -289,19 +289,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:test/py/conftest.py def pytest_configure(config): · line 311
Quoted 10 lines
test/py/conftest.py +10
-0+ 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)}")Since no platform contains all of those files this is too verbose.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
So perhaps only show the message if all files are missing?
Sure. Or a log.debug maybe?
The
log.debug()doesn't show up though and people wouldn't know where to look. So if you are OK with having the message only if there is nothing, I will do that.
Sure.
Signature · 1 line
Tom
PATCH v2 6/6 test: Make net tests depend on CONFIG_CMD_NET
In reply to Simon GlassThis 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
(no changes since v1)
test/py/tests/test_net.py | 2 ++ 1 file changed, 2 insertions(+)
test/py/tests/test_net.py +2 -0
@@ -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(ubman): """Execute any commands required to enable network hardware.
Signature · 1 line
2.43.0
Quoted 9 lines · Simon Glass
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_tplThis series is based on the previous 'test' series[1]
[1] https://patchwork.ozlabs.org/project/uboot/list/?series=441124
Please note that while the prerequisite series is applied, this does not apply to u-boot/next and needs to be rebased, thanks.
Signature · 1 line
Tom