summaryrefslogtreecommitdiff
path: root/test/py/tests/test_net_boot.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2025-02-09 09:07:14 -0700
committerSimon Glass <sjg@chromium.org>2025-03-15 10:38:38 +0000
commit752c3769874596d012cd8325099d2ae20123f989 (patch)
treeb50b3025ff2d124a96793b64d83b8a7d1cb2326c /test/py/tests/test_net_boot.py
parent00dfb7038ea4dfe9d9667143bfecd11c05cab6fa (diff)
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/
Diffstat (limited to 'test/py/tests/test_net_boot.py')
-rw-r--r--test/py/tests/test_net_boot.py142
1 files changed, 71 insertions, 71 deletions
diff --git a/test/py/tests/test_net_boot.py b/test/py/tests/test_net_boot.py
index d7d74356928..d0230808b9f 100644
--- a/test/py/tests/test_net_boot.py
+++ b/test/py/tests/test_net_boot.py
@@ -117,26 +117,26 @@ env__pxe_boot_test_skip = False
initrd rootfs.cpio.gz.u-boot
"""
-def setup_networking(u_boot_console):
- test_net.test_net_dhcp(u_boot_console)
+def setup_networking(ubman):
+ test_net.test_net_dhcp(ubman)
if not test_net.net_set_up:
- test_net.test_net_setup_static(u_boot_console)
+ test_net.test_net_setup_static(ubman)
-def setup_tftpboot_boot(u_boot_console):
- f = u_boot_console.config.env.get('env__net_tftp_bootable_file', None)
+def setup_tftpboot_boot(ubman):
+ f = ubman.config.env.get('env__net_tftp_bootable_file', None)
if not f:
pytest.skip('No TFTP bootable file to read')
- setup_networking(u_boot_console)
+ setup_networking(ubman)
addr = f.get('addr', None)
if not addr:
- addr = u_boot_utils.find_ram_base(u_boot_console)
+ addr = u_boot_utils.find_ram_base(ubman)
fn = f['fn']
timeout = f.get('timeout', 50000)
- with u_boot_console.temporary_timeout(timeout):
- output = u_boot_console.run_command('tftpboot %x %s' % (addr, fn))
+ with ubman.temporary_timeout(timeout):
+ output = ubman.run_command('tftpboot %x %s' % (addr, fn))
expected_text = 'Bytes transferred = '
sz = f.get('size', None)
@@ -145,7 +145,7 @@ def setup_tftpboot_boot(u_boot_console):
assert expected_text in output
expected_crc = f.get('crc32', None)
- output = u_boot_console.run_command('crc32 %x $filesize' % addr)
+ output = ubman.run_command('crc32 %x $filesize' % addr)
if expected_crc:
assert expected_crc in output
@@ -157,7 +157,7 @@ def setup_tftpboot_boot(u_boot_console):
return addr, timeout, pattern, chk_type, chk_pattern, config
@pytest.mark.buildconfigspec('cmd_tftpboot')
-def test_net_tftpboot_boot(u_boot_console):
+def test_net_tftpboot_boot(ubman):
"""Boot the loaded image
A boot file (fit image) is downloaded from the TFTP server and booted using
@@ -167,11 +167,11 @@ def test_net_tftpboot_boot(u_boot_console):
The details of the file to download are provided by the boardenv_* file;
see the comment at the beginning of this file.
"""
- if u_boot_console.config.env.get('env__tftp_boot_test_skip', True):
+ if ubman.config.env.get('env__tftp_boot_test_skip', True):
pytest.skip('TFTP boot test is not enabled!')
addr, timeout, pattern, chk_type, chk_pattern, imcfg = setup_tftpboot_boot(
- u_boot_console
+ ubman
)
if imcfg:
@@ -179,38 +179,38 @@ def test_net_tftpboot_boot(u_boot_console):
else:
bootcmd = 'bootm %x' % addr
- with u_boot_console.enable_check(
+ with ubman.enable_check(
chk_type, chk_pattern
- ), u_boot_console.temporary_timeout(timeout):
+ ), ubman.temporary_timeout(timeout):
try:
# wait_for_prompt=False makes the core code not wait for the U-Boot
# prompt code to be seen, since it won't be on a successful kernel
# boot
- u_boot_console.run_command(bootcmd, wait_for_prompt=False)
+ ubman.run_command(bootcmd, wait_for_prompt=False)
# Wait for boot log pattern
- u_boot_console.wait_for(pattern)
+ ubman.wait_for(pattern)
finally:
# This forces the console object to be shutdown, so any subsequent
# test will reset the board back into U-Boot. We want to force this
# no matter whether the kernel boot passed or failed.
- u_boot_console.drain_console()
- u_boot_console.cleanup_spawn()
+ ubman.drain_console()
+ ubman.cleanup_spawn()
-def setup_pxe_boot(u_boot_console):
- f = u_boot_console.config.env.get('env__net_pxe_bootable_file', None)
+def setup_pxe_boot(ubman):
+ f = ubman.config.env.get('env__net_pxe_bootable_file', None)
if not f:
pytest.skip('No PXE bootable file to read')
- setup_networking(u_boot_console)
- bootfile = u_boot_console.run_command('echo $bootfile')
+ setup_networking(ubman)
+ bootfile = ubman.run_command('echo $bootfile')
if not bootfile:
bootfile = '<NULL>'
return f, bootfile
@pytest.mark.buildconfigspec('cmd_pxe')
-def test_net_pxe_boot(u_boot_console):
+def test_net_pxe_boot(ubman):
"""Test the pxe boot command.
A pxe configuration file is downloaded from the TFTP server and interpreted
@@ -219,19 +219,19 @@ def test_net_pxe_boot(u_boot_console):
The details of the file to download are provided by the boardenv_* file;
see the comment at the beginning of this file.
"""
- if u_boot_console.config.env.get('env__pxe_boot_test_skip', True):
+ if ubman.config.env.get('env__pxe_boot_test_skip', True):
pytest.skip('PXE boot test is not enabled!')
- f, bootfile = setup_pxe_boot(u_boot_console)
+ f, bootfile = setup_pxe_boot(ubman)
addr = f.get('addr', None)
- timeout = f.get('timeout', u_boot_console.p.timeout)
+ timeout = f.get('timeout', ubman.p.timeout)
fn = f['fn']
if addr:
- u_boot_console.run_command('setenv pxefile_addr_r %x' % addr)
+ ubman.run_command('setenv pxefile_addr_r %x' % addr)
- with u_boot_console.temporary_timeout(timeout):
- output = u_boot_console.run_command('pxe get')
+ with ubman.temporary_timeout(timeout):
+ output = ubman.run_command('pxe get')
expected_text = 'Bytes transferred = '
sz = f.get('size', None)
@@ -250,18 +250,18 @@ def test_net_pxe_boot(u_boot_console):
else:
pxe_boot_cmd = 'pxe boot %x' % addr
- with u_boot_console.enable_check(
+ with ubman.enable_check(
chk_type, chk_pattern
- ), u_boot_console.temporary_timeout(timeout):
+ ), ubman.temporary_timeout(timeout):
try:
- u_boot_console.run_command(pxe_boot_cmd, wait_for_prompt=False)
- u_boot_console.wait_for(pattern)
+ ubman.run_command(pxe_boot_cmd, wait_for_prompt=False)
+ ubman.wait_for(pattern)
finally:
- u_boot_console.drain_console()
- u_boot_console.cleanup_spawn()
+ ubman.drain_console()
+ ubman.cleanup_spawn()
@pytest.mark.buildconfigspec('cmd_pxe')
-def test_net_pxe_boot_config(u_boot_console):
+def test_net_pxe_boot_config(ubman):
"""Test the pxe boot command by selecting different combination of labels
A pxe configuration file is downloaded from the TFTP server and interpreted
@@ -270,12 +270,12 @@ def test_net_pxe_boot_config(u_boot_console):
The details of the file to download are provided by the boardenv_* file;
see the comment at the beginning of this file.
"""
- if u_boot_console.config.env.get('env__pxe_boot_test_skip', True):
+ if ubman.config.env.get('env__pxe_boot_test_skip', True):
pytest.skip('PXE boot test is not enabled!')
- f, bootfile = setup_pxe_boot(u_boot_console)
+ f, bootfile = setup_pxe_boot(ubman)
addr = f.get('addr', None)
- timeout = f.get('timeout', u_boot_console.p.timeout)
+ timeout = f.get('timeout', ubman.p.timeout)
fn = f['fn']
local_label = f['local_label']
empty_label = f['empty_label']
@@ -283,10 +283,10 @@ def test_net_pxe_boot_config(u_boot_console):
exp_str_empty = f['exp_str_empty']
if addr:
- u_boot_console.run_command('setenv pxefile_addr_r %x' % addr)
+ ubman.run_command('setenv pxefile_addr_r %x' % addr)
- with u_boot_console.temporary_timeout(timeout):
- output = u_boot_console.run_command('pxe get')
+ with ubman.temporary_timeout(timeout):
+ output = ubman.run_command('pxe get')
expected_text = 'Bytes transferred = '
sz = f.get('size', None)
@@ -305,20 +305,20 @@ def test_net_pxe_boot_config(u_boot_console):
else:
pxe_boot_cmd = 'pxe boot %x' % addr
- with u_boot_console.enable_check(
+ with ubman.enable_check(
chk_type, chk_pattern
- ), u_boot_console.temporary_timeout(timeout):
+ ), ubman.temporary_timeout(timeout):
try:
- u_boot_console.run_command(pxe_boot_cmd, wait_for_prompt=False)
+ ubman.run_command(pxe_boot_cmd, wait_for_prompt=False)
# pxe config is loaded where multiple labels are there and need to
# select particular label to boot and check for expected string
# In this case, local label is selected and it should look for
# localcmd env variable and if that variable is not defined it
# should not boot it and come out to u-boot prompt
- u_boot_console.wait_for('Enter choice:')
- u_boot_console.run_command(local_label, wait_for_prompt=False)
- expected_str = u_boot_console.p.expect([exp_str_local])
+ ubman.wait_for('Enter choice:')
+ ubman.run_command(local_label, wait_for_prompt=False)
+ expected_str = ubman.p.expect([exp_str_local])
assert (
expected_str == 0
), f'Expected string: {exp_str_local} did not match!'
@@ -326,21 +326,21 @@ def test_net_pxe_boot_config(u_boot_console):
# In this case, empty label is selected and it should look for
# kernel image path and if it is not set it should fail it and load
# default label to boot
- u_boot_console.run_command(pxe_boot_cmd, wait_for_prompt=False)
- u_boot_console.wait_for('Enter choice:')
- u_boot_console.run_command(empty_label, wait_for_prompt=False)
- expected_str = u_boot_console.p.expect([exp_str_empty])
+ ubman.run_command(pxe_boot_cmd, wait_for_prompt=False)
+ ubman.wait_for('Enter choice:')
+ ubman.run_command(empty_label, wait_for_prompt=False)
+ expected_str = ubman.p.expect([exp_str_empty])
assert (
expected_str == 0
), f'Expected string: {exp_str_empty} did not match!'
- u_boot_console.wait_for(pattern)
+ ubman.wait_for(pattern)
finally:
- u_boot_console.drain_console()
- u_boot_console.cleanup_spawn()
+ ubman.drain_console()
+ ubman.cleanup_spawn()
@pytest.mark.buildconfigspec('cmd_pxe')
-def test_net_pxe_boot_config_invalid(u_boot_console):
+def test_net_pxe_boot_config_invalid(ubman):
"""Test the pxe boot command by selecting invalid label
A pxe configuration file is downloaded from the TFTP server and interpreted
@@ -349,21 +349,21 @@ def test_net_pxe_boot_config_invalid(u_boot_console):
The details of the file to download are provided by the boardenv_* file;
see the comment at the beginning of this file.
"""
- if u_boot_console.config.env.get('env__pxe_boot_test_skip', True):
+ if ubman.config.env.get('env__pxe_boot_test_skip', True):
pytest.skip('PXE boot test is not enabled!')
- f, bootfile = setup_pxe_boot(u_boot_console)
+ f, bootfile = setup_pxe_boot(ubman)
addr = f.get('addr', None)
- timeout = f.get('timeout', u_boot_console.p.timeout)
+ timeout = f.get('timeout', ubman.p.timeout)
fn = f['fn']
invalid_label = f['invalid_label']
exp_str_invalid = f['exp_str_invalid']
if addr:
- u_boot_console.run_command('setenv pxefile_addr_r %x' % addr)
+ ubman.run_command('setenv pxefile_addr_r %x' % addr)
- with u_boot_console.temporary_timeout(timeout):
- output = u_boot_console.run_command('pxe get')
+ with ubman.temporary_timeout(timeout):
+ output = ubman.run_command('pxe get')
expected_text = 'Bytes transferred = '
sz = f.get('size', None)
@@ -379,22 +379,22 @@ def test_net_pxe_boot_config_invalid(u_boot_console):
else:
pxe_boot_cmd = 'pxe boot %x' % addr
- with u_boot_console.temporary_timeout(timeout):
+ with ubman.temporary_timeout(timeout):
try:
- u_boot_console.run_command(pxe_boot_cmd, wait_for_prompt=False)
+ ubman.run_command(pxe_boot_cmd, wait_for_prompt=False)
# pxe config is loaded where multiple labels are there and need to
# select particular label to boot and check for expected string
# In this case invalid label is selected, it should load invalid
# label and if it fails it should load the default label to boot
- u_boot_console.wait_for('Enter choice:')
- u_boot_console.run_command(invalid_label, wait_for_prompt=False)
- expected_str = u_boot_console.p.expect([exp_str_invalid])
+ ubman.wait_for('Enter choice:')
+ ubman.run_command(invalid_label, wait_for_prompt=False)
+ expected_str = ubman.p.expect([exp_str_invalid])
assert (
expected_str == 0
), f'Expected string: {exp_str_invalid} did not match!'
- u_boot_console.wait_for(pattern)
+ ubman.wait_for(pattern)
finally:
- u_boot_console.drain_console()
- u_boot_console.cleanup_spawn()
+ ubman.drain_console()
+ ubman.cleanup_spawn()