test/py: Drop u_boot_ prefix on test files

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 <sjg@chromium.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@baylibre.com> # test_android / test_dfu
This commit is contained in:
Simon Glass 2025-02-09 09:07:15 -07:00
parent 752c376987
commit d9ed4b75ad
52 changed files with 215 additions and 216 deletions

View file

@ -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:: 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') c = os.read(self.fd, 1024).decode(errors='replace')
E ValueError: U-Boot exited with signal 11 (Signals.SIGSEGV) 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 validation or interpretation of the command output. This function validates
that certain strings are not seen on the U-Boot console. These include shell 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 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 "bad" strings. Some test scenarios are expected to trigger these strings. Use
`ubman.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. strings. See `test_unknown_cmd.py` for an example.

View file

@ -120,7 +120,7 @@ in Python::
"""Test that md reads memory as expected, and that memory can be modified """Test that md reads memory as expected, and that memory can be modified
using the mw command.""" using the mw command."""
ram_base = u_boot_utils.find_ram_base(ubman) ram_base = utils.find_ram_base(ubman)
addr = '%08x' % ram_base addr = '%08x' % ram_base
val = 'a5f09876' val = 'a5f09876'
expected_response = addr + ': ' + val expected_response = addr + ': ' + val

View file

@ -7,7 +7,7 @@
# test, at shutdown etc. These hooks perform functions such as: # test, at shutdown etc. These hooks perform functions such as:
# - Parsing custom command-line options. # - Parsing custom command-line options.
# - Pullilng in user-specified board configuration. # - Pullilng in user-specified board configuration.
# - Creating the U-Boot console test fixture. # - Creating the ubman test fixture.
# - Creating the HTML log file. # - Creating the HTML log file.
# - Monitoring each test's results. # - Monitoring each test's results.
# - Implementing custom pytest markers. # - Implementing custom pytest markers.
@ -25,12 +25,12 @@ import re
from _pytest.runner import runtestprotocol from _pytest.runner import runtestprotocol
import subprocess import subprocess
import sys import sys
from spawn import BootFail, Timeout, Unexpected, handle_exception
import time import time
from u_boot_spawn import BootFail, Timeout, Unexpected, handle_exception
# Globals: The HTML log file, and the connection to the U-Boot console. # Globals: The HTML log file, and the top-level fixture
log = None log = None
console = None ubman_fix = None
TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__)) TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__))
@ -247,7 +247,7 @@ def pytest_configure(config):
ubconfig.buildconfig.update(parser.items('root')) ubconfig.buildconfig.update(parser.items('root'))
global log global log
global console global ubman_fix
global ubconfig global ubconfig
(board_type, board_type_extra, board_identity, build_dir, build_dir_extra, (board_type, board_type_extra, board_identity, build_dir, build_dir_extra,
@ -343,11 +343,11 @@ def pytest_configure(config):
os.environ['U_BOOT_' + v.upper()] = getattr(ubconfig, v) os.environ['U_BOOT_' + v.upper()] = getattr(ubconfig, v)
if board_type.startswith('sandbox'): if board_type.startswith('sandbox'):
import u_boot_console_sandbox import console_sandbox
console = u_boot_console_sandbox.ConsoleSandbox(log, ubconfig) ubman_fix = console_sandbox.ConsoleSandbox(log, ubconfig)
else: else:
import u_boot_console_exec_attach import console_board
console = u_boot_console_exec_attach.ConsoleExecAttach(log, ubconfig) ubman_fix = console_board.ConsoleExecAttach(log, ubconfig)
def generate_ut_subtest(metafunc, fixture_name, sym_path): def generate_ut_subtest(metafunc, fixture_name, sym_path):
@ -366,7 +366,7 @@ def generate_ut_subtest(metafunc, fixture_name, sym_path):
Returns: Returns:
Nothing. Nothing.
""" """
fn = console.config.build_dir + sym_path fn = ubman_fix.config.build_dir + sym_path
try: try:
with open(fn, 'rt') as f: with open(fn, 'rt') as f:
lines = f.readlines() lines = f.readlines()
@ -407,8 +407,8 @@ def generate_config(metafunc, fixture_name):
""" """
subconfigs = { subconfigs = {
'brd': console.config.brd, 'brd': ubman_fix.config.brd,
'env': console.config.env, 'env': ubman_fix.config.env,
} }
parts = fixture_name.split('__') parts = fixture_name.split('__')
if len(parts) < 2: if len(parts) < 2:
@ -470,7 +470,7 @@ def u_boot_log(request):
The fixture value. The fixture value.
""" """
return console.log return ubman_fix.log
@pytest.fixture(scope='session') @pytest.fixture(scope='session')
def u_boot_config(request): def u_boot_config(request):
@ -483,7 +483,7 @@ def u_boot_config(request):
The fixture value. The fixture value.
""" """
return console.config return ubman_fix.config
@pytest.fixture(scope='function') @pytest.fixture(scope='function')
def ubman(request): def ubman(request):
@ -499,18 +499,18 @@ def ubman(request):
pytest.skip('Cannot get target connection') pytest.skip('Cannot get target connection')
return None return None
try: try:
console.ensure_spawned() ubman_fix.ensure_spawned()
except OSError as err: except OSError as err:
handle_exception(ubconfig, console, log, err, 'Lab failure', True) handle_exception(ubconfig, ubman_fix, log, err, 'Lab failure', True)
except Timeout as err: except Timeout as err:
handle_exception(ubconfig, console, log, err, 'Lab timeout', True) handle_exception(ubconfig, ubman_fix, log, err, 'Lab timeout', True)
except BootFail as err: except BootFail as err:
handle_exception(ubconfig, console, log, err, 'Boot fail', True, handle_exception(ubconfig, ubman_fix, log, err, 'Boot fail', True,
console.get_spawn_output()) ubman.get_spawn_output())
except Unexpected: except Unexpected:
handle_exception(ubconfig, console, log, err, 'Unexpected test output', handle_exception(ubconfig, ubman_fix, log, err, 'Unexpected test output',
False) False)
return console return ubman_fix
anchors = {} anchors = {}
tests_not_run = [] tests_not_run = []
@ -623,8 +623,8 @@ def cleanup():
Nothing. Nothing.
""" """
if console: if ubman_fix:
console.close() ubman_fix.close()
if log: if log:
with log.section('Status Report', 'status_report'): with log.section('Status Report', 'status_report'):
log.status_pass('%d passed' % len(tests_passed)) log.status_pass('%d passed' % len(tests_passed))
@ -845,7 +845,7 @@ def pytest_runtest_protocol(item, nextitem):
test_durations[item.name] = duration test_durations[item.name] = duration
if failure_cleanup: if failure_cleanup:
console.drain_console() ubman_fix.drain_console()
test_list.append(item.name) test_list.append(item.name)
tests_not_run.remove(item.name) tests_not_run.remove(item.name)
@ -855,7 +855,7 @@ def pytest_runtest_protocol(item, nextitem):
except: except:
# If something went wrong with logging, it's better to let the test # If something went wrong with logging, it's better to let the test
# process continue, which may report other exceptions that triggered # process continue, which may report other exceptions that triggered
# the logging issue (e.g. console.log wasn't created). Hence, just # the logging issue (e.g. ubman_fix.log wasn't created). Hence, just
# squash the exception. If the test setup failed due to e.g. syntax # squash the exception. If the test setup failed due to e.g. syntax
# error somewhere else, this won't be seen. However, once that issue # error somewhere else, this won't be seen. However, once that issue
# is fixed, if this exception still exists, it will then be logged as # is fixed, if this exception still exists, it will then be logged as
@ -868,6 +868,6 @@ def pytest_runtest_protocol(item, nextitem):
log.end_section(item.name) log.end_section(item.name)
if failure_cleanup: if failure_cleanup:
console.cleanup_spawn() ubman_fix.cleanup_spawn()
return True return True

View file

@ -13,8 +13,8 @@ import os
import pytest import pytest
import re import re
import sys import sys
import u_boot_spawn import spawn
from u_boot_spawn import BootFail, Timeout, Unexpected, handle_exception from spawn import BootFail, Timeout, Unexpected, handle_exception
# Regexes for text we expect U-Boot to send to the console. # 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]*\\))') 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): def get_spawn(self):
# This is not called, ssubclass must define this. # This is not called, ssubclass must define this.
# Return a value to avoid: # 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) # call, where the function returns None (assignment-from-none)
return u_boot_spawn.Spawn([]) return spawn.Spawn([])
def eval_bad_patterns(self): def eval_bad_patterns(self):

View file

@ -8,8 +8,8 @@ physical serial port.
""" """
import sys import sys
from u_boot_spawn import Spawn from spawn import Spawn
from u_boot_console_base import ConsoleBase from console_base import ConsoleBase
class ConsoleExecAttach(ConsoleBase): class ConsoleExecAttach(ConsoleBase):
"""Represents a physical connection to a U-Boot console, typically via a """Represents a physical connection to a U-Boot console, typically via a
@ -53,7 +53,7 @@ class ConsoleExecAttach(ConsoleBase):
None. None.
Returns: 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] args = [self.config.board_type, self.config.board_identity]

View file

@ -7,8 +7,8 @@ Logic to interact with the sandbox port of U-Boot, running as a sub-process.
""" """
import time import time
from u_boot_spawn import Spawn from spawn import Spawn
from u_boot_console_base import ConsoleBase from console_base import ConsoleBase
class ConsoleSandbox(ConsoleBase): class ConsoleSandbox(ConsoleBase):
"""Represents a connection to a sandbox U-Boot console, executed as a sub- """Represents a connection to a sandbox U-Boot console, executed as a sub-
@ -39,7 +39,7 @@ class ConsoleSandbox(ConsoleBase):
None. None.
Returns: 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 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 use_dtb: True to use a device tree file, False to run without one
Returns: Returns:
A u_boot_spawn.Spawn object that is attached to U-Boot. A spawn.Spawn object that is attached to U-Boot.
""" """
try: try:

View file

@ -5,7 +5,7 @@
import os import os
import pytest import pytest
import u_boot_utils import utils
class ABTestDiskImage(object): class ABTestDiskImage(object):
"""Disk Image used by the A/B tests.""" """Disk Image used by the A/B tests."""
@ -25,7 +25,7 @@ class ABTestDiskImage(object):
persistent = ubman.config.persistent_data_dir + '/' + filename persistent = ubman.config.persistent_data_dir + '/' + filename
self.path = ubman.config.result_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): if os.path.exists(persistent):
ubman.log.action('Disk image file ' + persistent + ubman.log.action('Disk image file ' + persistent +
' already exists') ' already exists')
@ -35,16 +35,16 @@ class ABTestDiskImage(object):
os.ftruncate(fd, 524288) os.ftruncate(fd, 524288)
os.close(fd) os.close(fd)
cmd = ('sgdisk', persistent) 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', cmd = ('sgdisk', '--new=1:64:512', '--change-name=1:misc',
persistent) persistent)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
cmd = ('sgdisk', '--load-backup=' + persistent) cmd = ('sgdisk', '--load-backup=' + persistent)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
cmd = ('cp', persistent, self.path) cmd = ('cp', persistent, self.path)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
di = None di = None
@pytest.fixture(scope='function') @pytest.fixture(scope='function')

View file

@ -6,7 +6,7 @@
import os import os
import pytest import pytest
import u_boot_utils import utils
""" """
These tests rely on disk image (boot.img), which is automatically created by 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 persistent = ubman.config.persistent_data_dir + '/' + filename
self.path = ubman.config.result_dir + '/' + filename self.path = ubman.config.result_dir + '/' + filename
ubman.log.action('persistent is ' + persistent) 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): if os.path.exists(persistent):
ubman.log.action('Disk image file ' + persistent + ubman.log.action('Disk image file ' + persistent +
' already exists') ' already exists')
@ -133,12 +133,12 @@ class AbootimgTestDiskImage(object):
f.write(hex_img) f.write(hex_img)
f.close() f.close()
cmd = ('xxd', '-r', '-p', gz_hex, gz) 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) cmd = ('gunzip', '-9', gz)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
cmd = ('cp', persistent, self.path) cmd = ('cp', persistent, self.path)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
gtdi1 = None gtdi1 = None
@pytest.fixture(scope='function') @pytest.fixture(scope='function')

View file

@ -15,7 +15,7 @@ For configuration verification:
""" """
import pytest import pytest
import u_boot_utils as util import utils as util
# defauld mmc id # defauld mmc id
mmc_dev = 1 mmc_dev = 1

View file

@ -9,7 +9,7 @@
import os import os
import os.path import os.path
import pytest import pytest
import u_boot_utils import utils
""" """
Note: This test relies on: Note: This test relies on:
@ -143,9 +143,9 @@ def test_dfu(ubman, env__usb_dev_port, env__dfu_config):
Nothing. Nothing.
""" """
u_boot_utils.wait_until_file_open_fails( utils.wait_until_file_open_fails(
env__usb_dev_port['host_usb_dev_node'], True) 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']) env__usb_dev_port['host_usb_dev_node'])
if fh: if fh:
fh.close() 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'] cmd = 'dfu 0 ' + env__dfu_config['cmd_params']
ubman.run_command(cmd, wait_for_prompt=False) ubman.run_command(cmd, wait_for_prompt=False)
ubman.log.action('Waiting for DFU USB device to appear') 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']) env__usb_dev_port['host_usb_dev_node'])
fh.close() fh.close()
@ -190,7 +190,7 @@ def test_dfu(ubman, env__usb_dev_port, env__dfu_config):
ubman.ctrlc() ubman.ctrlc()
ubman.log.action( ubman.log.action(
'Waiting for DFU USB device to disappear') '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) env__usb_dev_port['host_usb_dev_node'], ignore_errors)
except: except:
if not ignore_errors: 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] cmd = ['dfu-util', '-a', alt_setting, up_dn_load_arg, fn]
if 'host_usb_port_path' in env__usb_dev_port: if 'host_usb_port_path' in env__usb_dev_port:
cmd += ['-p', env__usb_dev_port['host_usb_port_path']] 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 ...') ubman.wait_for('Ctrl+C to exit ...')
def dfu_write(alt_setting, fn): def dfu_write(alt_setting, fn):
@ -261,7 +261,7 @@ def test_dfu(ubman, env__usb_dev_port, env__dfu_config):
Nothing. Nothing.
""" """
test_f = u_boot_utils.PersistentRandomFile(ubman, test_f = utils.PersistentRandomFile(ubman,
'dfu_%d.bin' % size, size) 'dfu_%d.bin' % size, size)
readback_fn = ubman.config.result_dir + '/dfu_readback.bin' 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') ubman.log.action('Comparing written and read data')
written_hash = test_f.content_hash 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) assert(written_hash == read_back_hash)
# This test may be executed against multiple USB ports. The test takes a # 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: else:
sizes = [] sizes = []
dummy_f = u_boot_utils.PersistentRandomFile(ubman, dummy_f = utils.PersistentRandomFile(ubman,
'dfu_dummy.bin', 1024) 'dfu_dummy.bin', 1024)
alt_setting_test_file = env__dfu_config.get('alt_id_test_file', '0') alt_setting_test_file = env__dfu_config.get('alt_id_test_file', '0')

View file

@ -55,7 +55,7 @@ env__efi_fit_tftp_file = {
import os.path import os.path
import pytest import pytest
import u_boot_utils as util import utils as util
# Define the parametrized ITS data to be used for FIT images generation. # Define the parametrized ITS data to be used for FIT images generation.
ITS_DATA = ''' ITS_DATA = '''

View file

@ -53,7 +53,7 @@ env__efi_helloworld_net_http_test_skip = True
""" """
import pytest import pytest
import u_boot_utils import utils
PROTO_TFTP, PROTO_HTTP = range(0, 2) PROTO_TFTP, PROTO_HTTP = range(0, 2)
@ -132,7 +132,7 @@ def fetch_file(ubman, env_conf, proto):
addr = f.get('addr', None) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
fn = f['fn'] fn = f['fn']
if proto == PROTO_TFTP: if proto == PROTO_TFTP:

View file

@ -13,7 +13,7 @@ from subprocess import call, CalledProcessError
import tempfile import tempfile
import pytest import pytest
import u_boot_utils import utils
# FIXME: This might be useful for other tests; # FIXME: This might be useful for other tests;
# perhaps refactor it into ConsoleBase or some other state object? # perhaps refactor it into ConsoleBase or some other state object?
@ -187,7 +187,7 @@ def test_env_initial_env_file(ubman):
except: except:
pass 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) assert os.path.exists(envfile)
@ -278,7 +278,7 @@ def test_env_import_checksum_no_size(state_test_env):
env import function. env import function.
""" """
c = state_test_env.ubman 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 addr = '%08x' % ram_base
with c.disable_check('error_notification'): 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. env import function when variables are passed as parameters.
""" """
c = state_test_env.ubman 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 addr = '%08x' % ram_base
with c.disable_check('error_notification'): 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): def test_env_import_whitelist(state_test_env):
"""Test importing only a handful of env variables from an environment.""" """Test importing only a handful of env variables from an environment."""
c = state_test_env.ubman 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 addr = '%08x' % ram_base
set_var(state_test_env, 'foo1', 'bar1') set_var(state_test_env, 'foo1', 'bar1')
@ -340,7 +340,7 @@ def test_env_import_whitelist_delete(state_test_env):
environment to be imported. environment to be imported.
""" """
c = state_test_env.ubman 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 addr = '%08x' % ram_base
set_var(state_test_env, 'foo1', 'bar1') 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 # Some distributions do not add /sbin to the default PATH, where mkfs.ext4 lives
os.environ["PATH"] += os.pathsep + '/sbin' os.environ["PATH"] += os.pathsep + '/sbin'
try: try:
u_boot_utils.run_and_log(c, 'dd if=/dev/zero of=%s bs=1M count=16' % persistent) 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) utils.run_and_log(c, 'mkfs.ext4 %s' % persistent)
sb_content = u_boot_utils.run_and_log(c, 'tune2fs -l %s' % persistent) sb_content = utils.run_and_log(c, 'tune2fs -l %s' % persistent)
if 'metadata_csum' in sb_content: 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: except CalledProcessError:
call('rm -f %s' % persistent, shell=True) call('rm -f %s' % persistent, shell=True)
raise 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 return fs_img
@pytest.mark.boardspec('sandbox') @pytest.mark.boardspec('sandbox')
@ -560,7 +560,7 @@ def test_env_text(ubman):
fname = os.path.join(path, 'infile') fname = os.path.join(path, 'infile')
with open(fname, 'w') as inf: with open(fname, 'w') as inf:
print(intext, file=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: if expect_val is not None:
expect = '#define CONFIG_EXTRA_ENV_TEXT "%s"\n' % expect_val expect = '#define CONFIG_EXTRA_ENV_TEXT "%s"\n' % expect_val
assert result == expect assert result == expect

View file

@ -4,7 +4,7 @@
import pytest import pytest
import re 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 # This is only a partial test - coverting 64-bit sandbox. It does not test
# big-endian images, nor 32-bit images # big-endian images, nor 32-bit images

View file

@ -6,7 +6,7 @@
import os import os
import pytest import pytest
import u_boot_utils import utils
overlay_addr = 0x1000 overlay_addr = 0x1000

View file

@ -6,7 +6,7 @@
import os import os
import pytest import pytest
import struct import struct
import u_boot_utils as util import utils as util
import fit_util import fit_util
# Define a base ITS which we can adjust using % and a dictionary # Define a base ITS which we can adjust using % and a dictionary

View file

@ -17,7 +17,7 @@ The test does not run the sandbox. It only checks the host tool mkimage.
import os import os
import pytest import pytest
import u_boot_utils as util import utils as util
import binascii import binascii
from Cryptodome.Hash import SHA1 from Cryptodome.Hash import SHA1
from Cryptodome.Hash import SHA256 from Cryptodome.Hash import SHA256

View file

@ -12,7 +12,7 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage'
import os import os
import pytest import pytest
import u_boot_utils as util import utils as util
from Cryptodome.Hash import SHA256 from Cryptodome.Hash import SHA256
from Cryptodome.PublicKey import ECC from Cryptodome.PublicKey import ECC
from Cryptodome.Signature import DSS from Cryptodome.Signature import DSS

View file

@ -12,7 +12,7 @@ This test doesn't run the sandbox. It only checks the host tool 'mkimage'
import os import os
import pytest import pytest
import u_boot_utils as util import utils as util
kernel_hashes = { kernel_hashes = {
"sha512" : "f18c1486a2c29f56360301576cdfce4dfd8e8e932d0ed8e239a1f314b8ae1d77b2a58cd7fe32e4075e69448e623ce53b0b6aa6ce5626d2c189a5beae29a68d93", "sha512" : "f18c1486a2c29f56360301576cdfce4dfd8e8e932d0ed8e239a1f314b8ae1d77b2a58cd7fe32e4075e69448e623ce53b0b6aa6ce5626d2c189a5beae29a68d93",

View file

@ -8,7 +8,7 @@
import pytest import pytest
import re import re
import random import random
import u_boot_utils import utils
""" """
Note: This test relies on boardenv_* containing configuration values to define 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) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['fn'] fn = f['fn']
@ -546,7 +546,7 @@ def test_fpga_secure_bit_img_auth_kup(ubman):
keyaddr = f.get('keyaddr', None) keyaddr = f.get('keyaddr', None)
if not keyaddr: if not keyaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
keyfn = f['keyfn'] keyfn = f['keyfn']
output = ubman.run_command('tftpboot %x %s' % (keyaddr, 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) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['enckupfn'] fn = f['enckupfn']
output = ubman.run_command('tftpboot %x %s' % (addr, fn)) output = ubman.run_command('tftpboot %x %s' % (addr, fn))

View file

@ -8,7 +8,7 @@ import pytest
import re import re
from subprocess import call, check_call, check_output, CalledProcessError from subprocess import call, check_call, check_output, CalledProcessError
from fstest_defs import * from fstest_defs import *
import u_boot_utils as util import utils as util
# pylint: disable=E0611 # pylint: disable=E0611
from tests import fs_helper from tests import fs_helper

View file

@ -5,7 +5,7 @@
import pytest import pytest
import time import time
import u_boot_utils import utils
""" """
test_gpio_input is intended to test the fix 4dbc107f4683. test_gpio_input is intended to test the fix 4dbc107f4683.

View file

@ -6,7 +6,7 @@
import os import os
import pytest import pytest
import u_boot_utils import utils
""" """
These tests rely on a 4 MB disk image, which is automatically created by 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 persistent = ubman.config.persistent_data_dir + '/' + filename
self.path = ubman.config.result_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): if os.path.exists(persistent):
ubman.log.action('Disk image file ' + persistent + ubman.log.action('Disk image file ' + persistent +
' already exists') ' already exists')
@ -75,23 +75,23 @@ class GptTestDiskImage(object):
cmd = ('sgdisk', cmd = ('sgdisk',
'--disk-guid=375a56f7-d6c9-4e81-b5f0-09d41ca89efe', '--disk-guid=375a56f7-d6c9-4e81-b5f0-09d41ca89efe',
persistent) persistent)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
# part1 offset 1MB size 1MB # part1 offset 1MB size 1MB
cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1', cmd = ('sgdisk', '--new=1:2048:4095', '--change-name=1:part1',
'--partition-guid=1:33194895-67f6-4561-8457-6fdeed4f50a3', '--partition-guid=1:33194895-67f6-4561-8457-6fdeed4f50a3',
'-A 1:set:2', '-A 1:set:2',
persistent) persistent)
# part2 offset 2MB size 1.5MB # 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', cmd = ('sgdisk', '--new=2:4096:7167', '--change-name=2:part2',
'--partition-guid=2:cc9c6e4a-6551-4cb5-87be-3210f96c86fb', '--partition-guid=2:cc9c6e4a-6551-4cb5-87be-3210f96c86fb',
persistent) persistent)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
cmd = ('sgdisk', '--load-backup=' + persistent) cmd = ('sgdisk', '--load-backup=' + persistent)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
cmd = ('cp', persistent, self.path) cmd = ('cp', persistent, self.path)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
@pytest.fixture(scope='function') @pytest.fixture(scope='function')
def state_disk_image(ubman): def state_disk_image(ubman):

View file

@ -4,7 +4,7 @@
import pytest import pytest
import u_boot_utils as util import utils as util
# This is needed for Azure, since the default '..' directory is not writeable # This is needed for Azure, since the default '..' directory is not writeable
TMPDIR = '/tmp/test_kconfig' TMPDIR = '/tmp/test_kconfig'

View file

@ -3,14 +3,14 @@
# Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved. # Copyright (c) 2015-2016, NVIDIA CORPORATION. All rights reserved.
import pytest import pytest
import u_boot_utils import utils
@pytest.mark.buildconfigspec('cmd_memory') @pytest.mark.buildconfigspec('cmd_memory')
def test_md(ubman): def test_md(ubman):
"""Test that md reads memory as expected, and that memory can be modified """Test that md reads memory as expected, and that memory can be modified
using the mw command.""" using the mw command."""
ram_base = u_boot_utils.find_ram_base(ubman) ram_base = utils.find_ram_base(ubman)
addr = '%08x' % ram_base addr = '%08x' % ram_base
val = 'a5f09876' val = 'a5f09876'
expected_response = addr + ': ' + val expected_response = addr + ': ' + val
@ -26,7 +26,7 @@ def test_md_repeat(ubman):
"""Test command repeat (via executing an empty command) operates correctly """Test command repeat (via executing an empty command) operates correctly
for "md"; the command must repeat and dump an incrementing address.""" 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 addr_base = '%08x' % ram_base
words = 0x10 words = 0x10
addr_repeat = '%08x' % (ram_base + (words * 4)) addr_repeat = '%08x' % (ram_base + (words * 4))

View file

@ -4,7 +4,7 @@
import pytest import pytest
import random import random
import re import re
import u_boot_utils import utils
""" """
Note: This test doesn't rely on boardenv_* configuration values but it can 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: for y in mmc_modes:
ubman.run_command('mmc dev %d %d %d' % x, part, y) ubman.run_command('mmc dev %d %d %d' % x, part, y)
part_detect = 1 part_detect = 1
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
devices[x]['addr_%d' % part] = addr devices[x]['addr_%d' % part] = addr
size = random.randint(4, 1 * 1024 * 1024) size = random.randint(4, 1 * 1024 * 1024)
devices[x]['size_%d' % part] = size devices[x]['size_%d' % part] = size
@ -394,7 +394,7 @@ def test_mmc_ext4load_ext4write(ubman):
for y in mmc_modes: for y in mmc_modes:
ubman.run_command('mmc dev %d %d %d' % x, part, y) ubman.run_command('mmc dev %d %d %d' % x, part, y)
part_detect = 1 part_detect = 1
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
devices[x]['addr_%d' % part] = addr devices[x]['addr_%d' % part] = addr
size = random.randint(4, 1 * 1024 * 1024) size = random.randint(4, 1 * 1024 * 1024)
devices[x]['size_%d' % part] = size devices[x]['size_%d' % part] = size
@ -658,7 +658,7 @@ def test_mmc_fat_read_write_files(ubman):
for y in mmc_modes: for y in mmc_modes:
ubman.run_command('mmc dev %d %d %d' % x, part, y) ubman.run_command('mmc dev %d %d %d' % x, part, y)
part_detect = 1 part_detect = 1
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
count_f = 0 count_f = 0
addr_l = [] addr_l = []
size_l = [] size_l = []

View file

@ -7,7 +7,7 @@
import pytest import pytest
import time import time
import u_boot_utils import utils
""" """
This test relies on boardenv_* to containing configuration values to define 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 bcfg = ubman.config.buildconfig
has_cmd_memory = bcfg.get('config_cmd_memory', 'n') == 'y' has_cmd_memory = bcfg.get('config_cmd_memory', 'n') == 'y'
has_cmd_crc32 = bcfg.get('config_cmd_crc32', '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 addr = '0x%08x' % ram_base
# Select MMC device # Select MMC device

View file

@ -6,7 +6,7 @@
# to the eMMC or SD card, then reads it back and performs a comparison. # to the eMMC or SD card, then reads it back and performs a comparison.
import pytest import pytest
import u_boot_utils import utils
""" """
This test relies on boardenv_* to containing configuration values to define 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 count_bytes = count_sectors * 512
bcfg = ubman.config.buildconfig 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 src_addr = '0x%08x' % ram_base
dst_addr = '0x%08x' % (ram_base + count_bytes) dst_addr = '0x%08x' % (ram_base + count_bytes)

View file

@ -5,7 +5,7 @@
# tftpboot commands. # tftpboot commands.
import pytest import pytest
import u_boot_utils import utils
import uuid import uuid
import datetime import datetime
import re import re
@ -315,7 +315,7 @@ def test_net_nfs(ubman):
addr = f.get('addr', None) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
fn = f['fn'] fn = f['fn']
output = ubman.run_command('nfs %x %s' % (addr, fn)) output = ubman.run_command('nfs %x %s' % (addr, fn))
@ -411,7 +411,7 @@ def test_net_tftpput(ubman):
addr = f.get("addr", None) addr = f.get("addr", None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
sz = f.get("size", None) sz = f.get("size", None)
timeout = f.get("timeout", ubman.p.timeout) timeout = f.get("timeout", ubman.p.timeout)

View file

@ -2,7 +2,7 @@
# (C) Copyright 2023, Advanced Micro Devices, Inc. # (C) Copyright 2023, Advanced Micro Devices, Inc.
import pytest import pytest
import u_boot_utils import utils
import test_net import test_net
import re import re
@ -130,7 +130,7 @@ def setup_tftpboot_boot(ubman):
setup_networking(ubman) setup_networking(ubman)
addr = f.get('addr', None) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
fn = f['fn'] fn = f['fn']
timeout = f.get('timeout', 50000) timeout = f.get('timeout', 50000)

View file

@ -7,7 +7,7 @@
import os import os
import pytest import pytest
import u_boot_utils as util import utils as util
# This is needed for Azure, since the default '..' directory is not writeable # This is needed for Azure, since the default '..' directory is not writeable
TMPDIR1 = '/tmp/test_no_migrate' TMPDIR1 = '/tmp/test_no_migrate'

View file

@ -2,7 +2,7 @@
# Copyright (c) 2016 Google, Inc # Copyright (c) 2016 Google, Inc
import pytest import pytest
import u_boot_utils as util import utils as util
@pytest.mark.boardspec('sandbox_spl') @pytest.mark.boardspec('sandbox_spl')
@pytest.mark.buildconfigspec('spl_of_platdata') @pytest.mark.buildconfigspec('spl_of_platdata')

View file

@ -7,7 +7,7 @@ This tests optee_rpmb cmd in U-Boot
""" """
import pytest import pytest
import u_boot_utils as util import utils as util
@pytest.mark.buildconfigspec('cmd_optee_rpmb') @pytest.mark.buildconfigspec('cmd_optee_rpmb')
def test_optee_rpmb_read_write(ubman): def test_optee_rpmb_read_write(ubman):

View file

@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
import pytest import pytest
import u_boot_utils import utils
@pytest.mark.buildconfigspec('cmd_pinmux') @pytest.mark.buildconfigspec('cmd_pinmux')
def test_pinmux_usage_1(ubman): def test_pinmux_usage_1(ubman):

View file

@ -3,7 +3,7 @@
# Author: Frédéric Danis <frederic.danis@collabora.com> # Author: Frédéric Danis <frederic.danis@collabora.com>
import pytest import pytest
import u_boot_utils import utils
import os import os
import tempfile import tempfile
import shutil import shutil

View file

@ -4,7 +4,7 @@
import pytest import pytest
import u_boot_utils as util import utils as util
# This is needed for Azure, since the default '..' directory is not writeable # This is needed for Azure, since the default '..' directory is not writeable
TMPDIR = '/tmp/test_cmdline' TMPDIR = '/tmp/test_cmdline'

View file

@ -11,7 +11,7 @@ For additional details check doc/usage/scp03.rst
""" """
import pytest import pytest
import u_boot_utils as util import utils as util
@pytest.mark.buildconfigspec('cmd_scp03') @pytest.mark.buildconfigspec('cmd_scp03')
def test_scp03(ubman): def test_scp03(ubman):

View file

@ -5,7 +5,7 @@
import re import re
import pytest import pytest
import random import random
import u_boot_utils import utils
""" """
Note: This test relies on boardenv_* containing configuration values to define 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 = {}
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) probe_id = env__sf_config.get('id', 0)
speed = env__sf_config.get('speed', 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) cmd = 'mw.b %08x %02x %x' % (addr, pattern, count)
ubman.run_command(cmd) ubman.run_command(cmd)
crc_pattern = u_boot_utils.crc32(ubman, addr, count) crc_pattern = utils.crc32(ubman, addr, count)
if crc_expected: if crc_expected:
assert crc_pattern != crc_expected assert crc_pattern != crc_expected
cmd = 'sf read %08x %08x %x' % (addr, offset, count) cmd = 'sf read %08x %08x %x' % (addr, offset, count)
response = ubman.run_command(cmd) response = ubman.run_command(cmd)
assert 'Read: OK' in response, 'Read operation failed' 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.' assert crc_pattern != crc_readback, 'sf read did not update RAM content.'
if crc_expected: if crc_expected:
assert crc_readback == 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) cmd = 'mw.b %08x %02x %x' % (addr, pattern, count)
ubman.run_command(cmd) 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) cmd = 'sf update %08x %08x %x' % (addr, offset, count)
ubman.run_command(cmd) ubman.run_command(cmd)
@ -201,7 +201,7 @@ def test_sf_erase(ubman, env__sf_config):
cmd = 'mw.b %08x ff %x' % (addr, count) cmd = 'mw.b %08x ff %x' % (addr, count)
ubman.run_command(cmd) 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) crc_read = sf_read(ubman, env__sf_config, sf_params)
assert crc_ffs == crc_read, 'Unexpected CRC32 after erase operation.' assert crc_ffs == crc_read, 'Unexpected CRC32 after erase operation.'

View file

@ -3,7 +3,7 @@
import os import os
import pytest import pytest
import u_boot_utils as util import utils as util
@pytest.mark.boardspec('sandbox') @pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_echo') @pytest.mark.buildconfigspec('cmd_echo')

View file

@ -51,7 +51,7 @@ env__spi_lock_unlock = {
import random import random
import re import re
import pytest import pytest
import u_boot_utils import utils
SPI_DATA = {} SPI_DATA = {}
EXPECTED_ERASE = 'Erased: OK' EXPECTED_ERASE = 'Erased: OK'
@ -198,7 +198,7 @@ def test_spi_erase_block(ubman):
def spi_write_twice(ubman, page_size, erase_size, total_size, timeout): def spi_write_twice(ubman, page_size, erase_size, total_size, timeout):
''' Random write till page size, random till size and full size ''' ''' 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 old_size = 0
for size in ( for size in (
@ -271,7 +271,7 @@ def test_spi_write_twice(ubman):
def spi_write_continues(ubman, page_size, erase_size, total_size, timeout): def spi_write_continues(ubman, page_size, erase_size, total_size, timeout):
''' Write with random size of data to continue SPI write case ''' ''' Write with random size of data to continue SPI write case '''
spi_erase_block(ubman, erase_size, total_size) 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)}') output = ubman.run_command(f'crc32 {hex(addr + 0x10000)} {hex(total_size)}')
m = re.search('==> (.+?)$', output) m = re.search('==> (.+?)$', output)
@ -327,7 +327,7 @@ def spi_read_twice(ubman, page_size, total_size, timeout):
''' Read the whole SPI flash twice, random_size till full flash size, ''' Read the whole SPI flash twice, random_size till full flash size,
random till page size ''' random till page size '''
for size in random.randint(4, page_size), random.randint(4, total_size), total_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 size = size & ~3
with ubman.temporary_timeout(timeout): with ubman.temporary_timeout(timeout):
output = ubman.run_command( output = ubman.run_command(
@ -451,13 +451,13 @@ def protect_ops(ubman, lock_addr, lock_size, ops="unlock"):
def erase_write_ops(ubman, start, size): def erase_write_ops(ubman, start, size):
''' Basic erase and write operation for flash ''' ''' 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, 'erase', start, size, 0, 0, EXPECTED_ERASE)
flash_ops(ubman, 'write', start, size, addr, 0, EXPECTED_WRITE) flash_ops(ubman, 'write', start, size, addr, 0, EXPECTED_WRITE)
def spi_lock_unlock(ubman, lock_addr, lock_size): def spi_lock_unlock(ubman, lock_addr, lock_size):
''' Lock unlock operations for SPI family flash ''' ''' 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() erase_size = get_erase_size()
# Find the protected/un-protected region # Find the protected/un-protected region
@ -612,7 +612,7 @@ def test_spi_negative(ubman):
total_size = get_total_size() total_size = get_total_size()
erase_size = get_erase_size() erase_size = get_erase_size()
page_size = get_page_size() page_size = get_page_size()
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
i = 0 i = 0
while i < loop: while i < loop:
# Erase negative test # Erase negative test

View file

@ -4,7 +4,7 @@
import os.path import os.path
import pytest import pytest
import u_boot_utils import utils
import re import re
import time import time
@ -197,7 +197,7 @@ def test_tpm2_get_capability(ubman):
tpm2_sandbox_init(ubman) tpm2_sandbox_init(ubman)
force_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) read_cap = ubman.run_command('tpm2 get_capability 0x6 0x20e 0x200 1') #0x%x 1' % ram)
output = ubman.run_command('echo $?') output = ubman.run_command('echo $?')
@ -220,7 +220,7 @@ def test_tpm2_dam_parameters(ubman):
if is_sandbox(ubman): if is_sandbox(ubman):
tpm2_sandbox_init(ubman) tpm2_sandbox_init(ubman)
force_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 # Set the DAM parameters to known values
ubman.run_command('tpm2 dam_parameters 3 10 0') ubman.run_command('tpm2 dam_parameters 3 10 0')
@ -245,7 +245,7 @@ def test_tpm2_pcr_read(ubman):
tpm2_sandbox_init(ubman) tpm2_sandbox_init(ubman)
force_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) read_pcr = ubman.run_command('tpm2 pcr_read 10 0x%x' % ram)
output = ubman.run_command('echo $?') output = ubman.run_command('echo $?')
@ -273,7 +273,7 @@ def test_tpm2_pcr_extend(ubman):
if is_sandbox(ubman): if is_sandbox(ubman):
tpm2_sandbox_init(ubman) tpm2_sandbox_init(ubman)
force_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)) read_pcr = ubman.run_command('tpm2 pcr_read 10 0x%x' % (ram + 0x20))
output = ubman.run_command('echo $?') output = ubman.run_command('echo $?')

View file

@ -6,7 +6,7 @@ import os
import pytest import pytest
import re import re
import u_boot_utils as util import utils as util
# This is needed for Azure, since the default '..' directory is not writeable # This is needed for Azure, since the default '..' directory is not writeable
TMPDIR = '/tmp/test_trace' TMPDIR = '/tmp/test_trace'

View file

@ -11,7 +11,7 @@ import os.path
import pytest import pytest
import re import re
import time import time
import u_boot_utils import utils
""" """
Note: This test relies on: Note: This test relies on:
@ -113,8 +113,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs):
mount_subdir = env__block_devs[0]['writable_fs_subdir'] mount_subdir = env__block_devs[0]['writable_fs_subdir']
part_num = env__block_devs[0]['writable_fs_partition'] part_num = env__block_devs[0]['writable_fs_partition']
host_ums_part_node = '%s-part%d' % (host_ums_dev_node, part_num) host_ums_part_node = '%s-part%d' % (host_ums_dev_node, part_num)
test_f = u_boot_utils.PersistentRandomFile(ubman, 'ums.bin', test_f = utils.PersistentRandomFile(ubman, 'ums.bin', 1024 * 1024);
1024 * 1024);
mounted_test_fn = mount_point + '/' + mount_subdir + test_f.fn mounted_test_fn = mount_point + '/' + mount_subdir + test_f.fn
else: else:
host_ums_part_node = host_ums_dev_node host_ums_part_node = host_ums_dev_node
@ -136,7 +135,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) cmd = 'ums %s %s %s' % (tgt_usb_ctlr, tgt_dev_type, tgt_dev_id)
ubman.run_command(cmd, wait_for_prompt=False) ubman.run_command(cmd, wait_for_prompt=False)
ubman.wait_for(re.compile('UMS: LUN.*[\r\n]')) 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') ubman.log.action('Reading raw data from UMS device')
fh.read(4096) fh.read(4096)
fh.close() fh.close()
@ -153,7 +152,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs):
ubman.log.action('Mounting exported UMS device') ubman.log.action('Mounting exported UMS device')
cmd = ('/bin/mount', host_ums_part_node) 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): def umount(ignore_errors):
"""Unmount the block device that U-Boot exports. """Unmount the block device that U-Boot exports.
@ -170,7 +169,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs):
ubman.log.action('Unmounting UMS device') ubman.log.action('Unmounting UMS device')
cmd = ('/bin/umount', host_ums_part_node) 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): def stop_ums(ignore_errors):
"""Stop U-Boot's ums shell command from executing. """Stop U-Boot's ums shell command from executing.
@ -191,7 +190,7 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs):
ubman.log.action( ubman.log.action(
'Stopping long-running U-Boot ums shell command') 'Stopping long-running U-Boot ums shell command')
ubman.ctrlc() 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_errors)
ignore_cleanup_errors = True ignore_cleanup_errors = True
@ -202,11 +201,11 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs):
mount() mount()
ubman.log.action('Writing test file via UMS') ubman.log.action('Writing test file via UMS')
cmd = ('rm', '-f', mounted_test_fn) 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): if os.path.exists(mounted_test_fn):
raise Exception('Could not rm target UMS test file') raise Exception('Could not rm target UMS test file')
cmd = ('cp', test_f.abs_fn, mounted_test_fn) 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 ignore_cleanup_errors = False
finally: finally:
umount(ignore_errors=ignore_cleanup_errors) umount(ignore_errors=ignore_cleanup_errors)
@ -219,9 +218,9 @@ def test_ums(ubman, env__usb_dev_port, env__block_devs):
try: try:
mount() mount()
ubman.log.action('Reading test file back via UMS') 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) cmd = ('rm', '-f', mounted_test_fn)
u_boot_utils.run_and_log(ubman, cmd) utils.run_and_log(ubman, cmd)
ignore_cleanup_errors = False ignore_cleanup_errors = False
finally: finally:
umount(ignore_errors=ignore_cleanup_errors) umount(ignore_errors=ignore_cleanup_errors)

View file

@ -6,7 +6,7 @@
import os import os
import pytest import pytest
import u_boot_utils import utils
@pytest.mark.boardspec('sandbox_vpl') @pytest.mark.boardspec('sandbox_vpl')
def test_upl_handoff(ubman): def test_upl_handoff(ubman):

View file

@ -4,7 +4,7 @@
import pytest import pytest
import random import random
import re import re
import u_boot_utils import utils
""" """
Note: This test doesn't rely on boardenv_* configuration values but it can 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()) pytest.skip('No %s partition detected' % fs.upper())
def usb_fatload_fatwrite(ubman, fs, x, part): 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) size = random.randint(4, 1 * 1024 * 1024)
output = ubman.run_command('crc32 %x %x' % (addr, size)) output = ubman.run_command('crc32 %x %x' % (addr, size))
m = re.search('==> (.+?)', output) m = re.search('==> (.+?)', output)
@ -391,7 +391,7 @@ def test_usb_ext4ls(ubman):
pytest.skip('No %s partition detected' % fs.upper()) pytest.skip('No %s partition detected' % fs.upper())
def usb_ext4load_ext4write(ubman, fs, x, part): 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) size = random.randint(4, 1 * 1024 * 1024)
output = ubman.run_command('crc32 %x %x' % (addr, size)) output = ubman.run_command('crc32 %x %x' % (addr, size))
m = re.search('==> (.+?)', output) m = re.search('==> (.+?)', output)
@ -505,7 +505,7 @@ def test_usb_ext2load(ubman):
part_detect = 1 part_detect = 1
file, size, expected_crc32 = \ file, size, expected_crc32 = \
usb_ext4load_ext4write(ubman, fs, x, part) 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) offset = random.randrange(128, 1024, 128)
output = ubman.run_command( output = ubman.run_command(
@ -572,7 +572,7 @@ def test_usb_load(ubman):
for part in partitions: for part in partitions:
part_detect = 1 part_detect = 1
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
if fs == 'fat': if fs == 'fat':
file, size, expected_crc32 = \ file, size, expected_crc32 = \
@ -618,7 +618,7 @@ def test_usb_save(ubman):
for part in partitions: for part in partitions:
part_detect = 1 part_detect = 1
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
size = random.randint(4, 1 * 1024 * 1024) size = random.randint(4, 1 * 1024 * 1024)
file = '%s_%d' % ('uboot_test', size) file = '%s_%d' % ('uboot_test', size)

View file

@ -13,7 +13,7 @@ import os
import os.path import os.path
import pytest import pytest
import u_boot_utils import utils
# pylint: disable=E0611 # pylint: disable=E0611
from tests import fs_helper from tests import fs_helper
from test_android import test_abootimg from test_android import test_abootimg
@ -52,8 +52,8 @@ def setup_image(cons, devnum, part_type, img_size=20, second_part=False,
if second_part: if second_part:
spec += '\ntype=c' spec += '\ntype=c'
u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') utils.run_and_log(cons, f'qemu-img create {fname} 20M')
u_boot_utils.run_and_log(cons, f'sfdisk {fname}', utils.run_and_log(cons, f'sfdisk {fname}',
stdin=spec.encode('utf-8')) stdin=spec.encode('utf-8'))
return fname, mnt return fname, mnt
@ -149,12 +149,12 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
infname = os.path.join(cons.config.source_dir, infname = os.path.join(cons.config.source_dir,
'test/py/tests/bootstd/armbian.bmp.xz') 'test/py/tests/bootstd/armbian.bmp.xz')
bmp_file = os.path.join(bootdir, 'boot.bmp') bmp_file = os.path.join(bootdir, 'boot.bmp')
u_boot_utils.run_and_log( utils.run_and_log(
cons, cons,
['sh', '-c', f'xz -dc {infname} >{bmp_file}']) ['sh', '-c', f'xz -dc {infname} >{bmp_file}'])
mkimage = cons.config.build_dir + '/tools/mkimage' mkimage = cons.config.build_dir + '/tools/mkimage'
u_boot_utils.run_and_log( utils.run_and_log(
cons, f'{mkimage} -C none -A arm -T script -d {cmd_fname} {scr_fname}') cons, f'{mkimage} -C none -A arm -T script -d {cmd_fname} {scr_fname}')
kernel = 'vmlinuz-5.15.63-rockchip64' kernel = 'vmlinuz-5.15.63-rockchip64'
@ -165,16 +165,16 @@ booti ${kernel_addr_r} ${ramdisk_addr_r} ${fdt_addr_r}
symlink = os.path.join(bootdir, 'Image') symlink = os.path.join(bootdir, 'Image')
if os.path.exists(symlink): if os.path.exists(symlink):
os.remove(symlink) os.remove(symlink)
u_boot_utils.run_and_log( utils.run_and_log(
cons, f'echo here {kernel} {symlink}') cons, f'echo here {kernel} {symlink}')
os.symlink(kernel, symlink) os.symlink(kernel, symlink)
fsfile = 'ext18M.img' fsfile = 'ext18M.img'
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}') utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
u_boot_utils.run_and_log(cons, f'mkfs.ext4 {fsfile} -d {mnt}') utils.run_and_log(cons, f'mkfs.ext4 {fsfile} -d {mnt}')
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1') utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}') utils.run_and_log(cons, f'rm -rf {mnt}')
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}') utils.run_and_log(cons, f'rm -f {fsfile}')
def setup_bootflow_image(cons): def setup_bootflow_image(cons):
"""Create a 20MB disk image with a single FAT partition""" """Create a 20MB disk image with a single FAT partition"""
@ -208,7 +208,7 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
with open(inf, 'wb') as fd: with open(inf, 'wb') as fd:
fd.write(gzip.compress(b'vmlinux')) fd.write(gzip.compress(b'vmlinux'))
mkimage = cons.config.build_dir + '/tools/mkimage' mkimage = cons.config.build_dir + '/tools/mkimage'
u_boot_utils.run_and_log( utils.run_and_log(
cons, f'{mkimage} -f auto -d {inf} {os.path.join(mnt, vmlinux)}') cons, f'{mkimage} -f auto -d {inf} {os.path.join(mnt, vmlinux)}')
with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd: with open(os.path.join(mnt, initrd), 'w', encoding='ascii') as fd:
@ -217,16 +217,16 @@ label Fedora-Workstation-armhfp-31-1.9 (5.3.7-301.fc31.armv7hl)
mkdir_cond(os.path.join(mnt, dtbdir)) mkdir_cond(os.path.join(mnt, dtbdir))
dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb') dtb_file = os.path.join(mnt, f'{dtbdir}/sandbox.dtb')
u_boot_utils.run_and_log( utils.run_and_log(
cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};') cons, f'dtc -o {dtb_file}', stdin=b'/dts-v1/; / {};')
fsfile = 'vfat18M.img' fsfile = 'vfat18M.img'
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}') utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}') utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/']) utils.run_and_log(cons, ['sh', '-c', f'mcopy -i {fsfile} {mnt}/* ::/'])
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1') utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}') utils.run_and_log(cons, f'rm -rf {mnt}')
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}') utils.run_and_log(cons, f'rm -f {fsfile}')
def setup_cros_image(cons): def setup_cros_image(cons):
"""Create a 20MB disk image with ChromiumOS partitions""" """Create a 20MB disk image with ChromiumOS partitions"""
@ -248,7 +248,7 @@ def setup_cros_image(cons):
""" """
kern_part = os.path.join(cons.config.result_dir, kern_part = os.path.join(cons.config.result_dir,
f'kern-part-{arch}.bin') f'kern-part-{arch}.bin')
u_boot_utils.run_and_log( utils.run_and_log(
cons, cons,
f'futility vbutil_kernel --pack {kern_part} ' f'futility vbutil_kernel --pack {kern_part} '
'--keyblock doc/chromium/files/devkeys/kernel.keyblock ' '--keyblock doc/chromium/files/devkeys/kernel.keyblock '
@ -276,8 +276,8 @@ def setup_cros_image(cons):
mmc_dev = 5 mmc_dev = 5
fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') utils.run_and_log(cons, f'qemu-img create {fname} 20M')
u_boot_utils.run_and_log(cons, f'cgpt create {fname}') utils.run_and_log(cons, f'cgpt create {fname}')
uuid_state = 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7' uuid_state = 'ebd0a0a2-b9e5-4433-87c0-68b6b72699c7'
uuid_kern = 'fe3a2a5d-4f32-41a7-b725-accc3285a309' uuid_kern = 'fe3a2a5d-4f32-41a7-b725-accc3285a309'
@ -316,13 +316,13 @@ def setup_cros_image(cons):
size = int(size_str[:-1]) * sect_1mb size = int(size_str[:-1]) * sect_1mb
else: else:
size = int(size_str) size = int(size_str)
u_boot_utils.run_and_log( utils.run_and_log(
cons, cons,
f"cgpt add -i {part['num']} -b {ptr} -s {size} -t {part['type']} {fname}") f"cgpt add -i {part['num']} -b {ptr} -s {size} -t {part['type']} {fname}")
ptr += size ptr += size
u_boot_utils.run_and_log(cons, f'cgpt boot -p {fname}') utils.run_and_log(cons, f'cgpt boot -p {fname}')
out = u_boot_utils.run_and_log(cons, f'cgpt show -q {fname}') out = utils.run_and_log(cons, f'cgpt show -q {fname}')
# We expect something like this: # We expect something like this:
# 8239 2048 1 Basic data # 8239 2048 1 Basic data
@ -389,8 +389,8 @@ def setup_android_image(cons):
mmc_dev = 7 mmc_dev = 7
fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') utils.run_and_log(cons, f'qemu-img create {fname} 20M')
u_boot_utils.run_and_log(cons, f'cgpt create {fname}') utils.run_and_log(cons, f'cgpt create {fname}')
ptr = 40 ptr = 40
@ -412,13 +412,13 @@ def setup_android_image(cons):
size = int(size_str[:-1]) * sect_1mb size = int(size_str[:-1]) * sect_1mb
else: else:
size = int(size_str) size = int(size_str)
u_boot_utils.run_and_log( utils.run_and_log(
cons, cons,
f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}") f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}")
ptr += size ptr += size
u_boot_utils.run_and_log(cons, f'cgpt boot -p {fname}') utils.run_and_log(cons, f'cgpt boot -p {fname}')
out = u_boot_utils.run_and_log(cons, f'cgpt show -q {fname}') out = utils.run_and_log(cons, f'cgpt show -q {fname}')
# Create a dict (indexed by partition number) containing the above info # Create a dict (indexed by partition number) containing the above info
for line in out.splitlines(): for line in out.splitlines():
@ -445,8 +445,8 @@ def setup_android_image(cons):
mmc_dev = 8 mmc_dev = 8
fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img')
u_boot_utils.run_and_log(cons, f'qemu-img create {fname} 20M') utils.run_and_log(cons, f'qemu-img create {fname} 20M')
u_boot_utils.run_and_log(cons, f'cgpt create {fname}') utils.run_and_log(cons, f'cgpt create {fname}')
ptr = 40 ptr = 40
@ -466,13 +466,13 @@ def setup_android_image(cons):
size = int(size_str[:-1]) * sect_1mb size = int(size_str[:-1]) * sect_1mb
else: else:
size = int(size_str) size = int(size_str)
u_boot_utils.run_and_log( utils.run_and_log(
cons, cons,
f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}") f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}")
ptr += size ptr += size
u_boot_utils.run_and_log(cons, f'cgpt boot -p {fname}') utils.run_and_log(cons, f'cgpt boot -p {fname}')
out = u_boot_utils.run_and_log(cons, f'cgpt show -q {fname}') out = utils.run_and_log(cons, f'cgpt show -q {fname}')
# Create a dict (indexed by partition number) containing the above info # Create a dict (indexed by partition number) containing the above info
for line in out.splitlines(): for line in out.splitlines():
@ -502,7 +502,7 @@ def setup_cedit_file(cons):
'test/boot/files/expo_ids.h') 'test/boot/files/expo_ids.h')
expo_tool = os.path.join(cons.config.source_dir, 'tools/expo.py') expo_tool = os.path.join(cons.config.source_dir, 'tools/expo.py')
outfname = 'cedit.dtb' outfname = 'cedit.dtb'
u_boot_utils.run_and_log( utils.run_and_log(
cons, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}') cons, f'{expo_tool} -e {inhname} -l {infname} -o {outfname}')
@pytest.mark.buildconfigspec('ut_dm') @pytest.mark.buildconfigspec('ut_dm')
@ -528,7 +528,7 @@ def test_ut_dm_init(ubman):
data = b'\x00' * (2 * 1024 * 1024) data = b'\x00' * (2 * 1024 * 1024)
with open(fn, 'wb') as fh: with open(fn, 'wb') as fh:
fh.write(data) fh.write(data)
u_boot_utils.run_and_log( utils.run_and_log(
ubman, f'sfdisk {fn}', stdin=b'type=83') ubman, f'sfdisk {fn}', stdin=b'type=83')
fs_helper.mk_fs(ubman.config, 'ext2', 0x200000, '2MB', None) fs_helper.mk_fs(ubman.config, 'ext2', 0x200000, '2MB', None)
@ -559,12 +559,12 @@ def setup_efi_image(cons):
with open(efi_dst, 'wb') as outf: with open(efi_dst, 'wb') as outf:
outf.write(inf.read()) outf.write(inf.read())
fsfile = 'vfat18M.img' fsfile = 'vfat18M.img'
u_boot_utils.run_and_log(cons, f'fallocate -l 18M {fsfile}') utils.run_and_log(cons, f'fallocate -l 18M {fsfile}')
u_boot_utils.run_and_log(cons, f'mkfs.vfat {fsfile}') utils.run_and_log(cons, f'mkfs.vfat {fsfile}')
u_boot_utils.run_and_log(cons, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/']) utils.run_and_log(cons, ['sh', '-c', f'mcopy -vs -i {fsfile} {mnt}/* ::/'])
u_boot_utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1') utils.run_and_log(cons, f'dd if={fsfile} of={fname} bs=1M seek=1')
u_boot_utils.run_and_log(cons, f'rm -rf {mnt}') utils.run_and_log(cons, f'rm -rf {mnt}')
u_boot_utils.run_and_log(cons, f'rm -f {fsfile}') utils.run_and_log(cons, f'rm -f {fsfile}')
@pytest.mark.buildconfigspec('cmd_bootflow') @pytest.mark.buildconfigspec('cmd_bootflow')
@pytest.mark.buildconfigspec('sandbox') @pytest.mark.buildconfigspec('sandbox')

View file

@ -6,7 +6,7 @@
import os import os
import pytest import pytest
import u_boot_utils import utils
@pytest.mark.boardspec('sandbox_vpl') @pytest.mark.boardspec('sandbox_vpl')
@pytest.mark.requiredtool('dtc') @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 # Enable firmware1 and the mmc that it uses. These are needed for the full
# VBE flow. # VBE flow.
u_boot_utils.run_and_log( utils.run_and_log(
cons, f'fdtput -t s {fdt} /bootstd/firmware0 status disabled') 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') 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') 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}') cons, f'fdtput -t s {fdt} /mmc3 filename {image_fname}')
# Remove any existing RAM file, so we don't have old data present # Remove any existing RAM file, so we don't have old data present

View file

@ -42,7 +42,7 @@ import os
import shutil import shutil
import struct import struct
import pytest import pytest
import u_boot_utils as util import utils as util
import vboot_forge import vboot_forge
import vboot_evil import vboot_evil

View file

@ -3,7 +3,7 @@
import pytest import pytest
import re import re
import u_boot_utils import utils
import test_net import test_net
""" """
@ -68,7 +68,7 @@ def test_zynq_aes_image(ubman):
srcaddr = f.get('srcaddr', None) srcaddr = f.get('srcaddr', None)
if not srcaddr: if not srcaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['fn'] fn = f['fn']
@ -96,7 +96,7 @@ def test_zynq_aes_bitstream(ubman):
srcaddr = f.get('srcaddr', None) srcaddr = f.get('srcaddr', None)
if not srcaddr: if not srcaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['fnbit'] fn = f['fnbit']
@ -124,7 +124,7 @@ def test_zynq_aes_partial_bitstream(ubman):
srcaddr = f.get('srcaddr', None) srcaddr = f.get('srcaddr', None)
if not srcaddr: if not srcaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['fnpbit'] fn = f['fnpbit']
@ -150,7 +150,7 @@ def test_zynq_rsa_image(ubman):
srcaddr = f.get('srcaddr', None) srcaddr = f.get('srcaddr', None)
if not srcaddr: if not srcaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['fn'] fn = f['fn']
@ -176,7 +176,7 @@ def test_zynq_rsa_image_invalid(ubman):
srcaddr = f.get('srcaddr', None) srcaddr = f.get('srcaddr', None)
if not srcaddr: if not srcaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fninvalid = f['fninvalid'] fninvalid = f['fninvalid']

View file

@ -3,7 +3,7 @@
import pytest import pytest
import re import re
import u_boot_utils import utils
import test_net import test_net
""" """
@ -45,7 +45,7 @@ def test_zynqmp_secure_boot_image(ubman):
addr = f.get('addr', None) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['fn'] fn = f['fn']
@ -78,7 +78,7 @@ def test_zynqmp_secure_boot_img_kup(ubman):
keyaddr = f.get('keyaddr', None) keyaddr = f.get('keyaddr', None)
if not keyaddr: if not keyaddr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
keyfn = f['keyfn'] keyfn = f['keyfn']
output = ubman.run_command('tftpboot %x %s' % (keyaddr, 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) addr = f.get('addr', None)
if not addr: if not addr:
addr = u_boot_utils.find_ram_base(ubman) addr = utils.find_ram_base(ubman)
expected_tftp = 'Bytes transferred = ' expected_tftp = 'Bytes transferred = '
fn = f['enckupfn'] fn = f['enckupfn']
output = ubman.run_command('tftpboot %x %s' % (addr, fn)) output = ubman.run_command('tftpboot %x %s' % (addr, fn))