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'.

Signed-off-by: Simon Glass <sjg@chromium.org>
Link: https://lore.kernel.org/u-boot/CAFLszTgPa4aT_J9h9pqeTtLCVn4x2JvLWRcWRD8NaN3uoSAtyA@mail.gmail.com/
This commit is contained in:
Simon Glass
2025-02-09 09:07:14 -07:00
parent 00dfb7038e
commit 752c376987
105 changed files with 2676 additions and 2676 deletions

View File

@@ -113,13 +113,13 @@ first_usb_dev_port = None
@pytest.mark.buildconfigspec('cmd_dfu')
@pytest.mark.requiredtool('dfu-util')
def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
def test_dfu(ubman, env__usb_dev_port, env__dfu_config):
"""Test the "dfu" command; the host system must be able to enumerate a USB
device when "dfu" is running, various DFU transfers are tested, and the
USB device must disappear when "dfu" is aborted.
Args:
u_boot_console: A U-Boot console connection.
ubman: A U-Boot console connection.
env__usb_dev_port: The single USB device-mode port specification on
which to run the test. See the file-level comment above for
details of the format.
@@ -151,7 +151,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
fh.close()
raise Exception('USB device present before dfu command invoked')
u_boot_console.log.action(
ubman.log.action(
'Starting long-running U-Boot dfu shell command')
dfu_alt_info_env = env__dfu_config.get('alt_info_env_name', \
@@ -159,11 +159,11 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
cmd = 'setenv "%s" "%s"' % (dfu_alt_info_env,
env__dfu_config['alt_info'])
u_boot_console.run_command(cmd)
ubman.run_command(cmd)
cmd = 'dfu 0 ' + env__dfu_config['cmd_params']
u_boot_console.run_command(cmd, wait_for_prompt=False)
u_boot_console.log.action('Waiting for DFU USB device to appear')
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(
env__usb_dev_port['host_usb_dev_node'])
fh.close()
@@ -185,10 +185,10 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
"""
try:
u_boot_console.log.action(
ubman.log.action(
'Stopping long-running U-Boot dfu shell command')
u_boot_console.ctrlc()
u_boot_console.log.action(
ubman.ctrlc()
ubman.log.action(
'Waiting for DFU USB device to disappear')
u_boot_utils.wait_until_file_open_fails(
env__usb_dev_port['host_usb_dev_node'], ignore_errors)
@@ -213,8 +213,8 @@ def test_dfu(u_boot_console, 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(u_boot_console, cmd)
u_boot_console.wait_for('Ctrl+C to exit ...')
u_boot_utils.run_and_log(ubman, cmd)
ubman.wait_for('Ctrl+C to exit ...')
def dfu_write(alt_setting, fn):
"""Write a file to the target board using DFU.
@@ -261,23 +261,23 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
Nothing.
"""
test_f = u_boot_utils.PersistentRandomFile(u_boot_console,
test_f = u_boot_utils.PersistentRandomFile(ubman,
'dfu_%d.bin' % size, size)
readback_fn = u_boot_console.config.result_dir + '/dfu_readback.bin'
readback_fn = ubman.config.result_dir + '/dfu_readback.bin'
u_boot_console.log.action('Writing test data to DFU primary ' +
ubman.log.action('Writing test data to DFU primary ' +
'altsetting')
dfu_write(alt_setting_test_file, test_f.abs_fn)
u_boot_console.log.action('Writing dummy data to DFU secondary ' +
ubman.log.action('Writing dummy data to DFU secondary ' +
'altsetting to clear DFU buffers')
dfu_write(alt_setting_dummy_file, dummy_f.abs_fn)
u_boot_console.log.action('Reading DFU primary altsetting for ' +
ubman.log.action('Reading DFU primary altsetting for ' +
'comparison')
dfu_read(alt_setting_test_file, readback_fn)
u_boot_console.log.action('Comparing written and read data')
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)
assert(written_hash == read_back_hash)
@@ -295,7 +295,7 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
else:
sizes = []
dummy_f = u_boot_utils.PersistentRandomFile(u_boot_console,
dummy_f = u_boot_utils.PersistentRandomFile(ubman,
'dfu_dummy.bin', 1024)
alt_setting_test_file = env__dfu_config.get('alt_id_test_file', '0')
@@ -305,16 +305,16 @@ def test_dfu(u_boot_console, env__usb_dev_port, env__dfu_config):
try:
start_dfu()
u_boot_console.log.action(
ubman.log.action(
'Overwriting DFU primary altsetting with dummy data')
dfu_write(alt_setting_test_file, dummy_f.abs_fn)
for size in sizes:
with u_boot_console.log.section('Data size %d' % size):
with ubman.log.section('Data size %d' % size):
dfu_write_read_check(size)
# Make the status of each sub-test obvious. If the test didn't
# pass, an exception was thrown so this code isn't executed.
u_boot_console.log.status_pass('OK')
ubman.log.status_pass('OK')
ignore_cleanup_errors = False
finally:
stop_dfu(ignore_cleanup_errors)