aboutsummaryrefslogtreecommitdiff
path: root/test/py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py')
-rw-r--r--test/py/conftest.py104
-rw-r--r--test/py/pytest.ini1
-rw-r--r--test/py/requirements.txt2
-rw-r--r--test/py/tests/test_bind.py1
-rw-r--r--test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py1
-rw-r--r--test/py/tests/test_eficonfig/conftest.py40
-rw-r--r--test/py/tests/test_eficonfig/test_eficonfig.py354
-rw-r--r--test/py/tests/test_fit_ecdsa.py4
-rw-r--r--test/py/tests/test_fit_hashes.py5
-rw-r--r--test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py1
-rw-r--r--test/py/tests/test_gpio.py1
-rw-r--r--test/py/tests/test_gpt.py3
-rw-r--r--test/py/tests/test_pinmux.py1
-rw-r--r--test/py/tests/test_ut.py9
-rw-r--r--test/py/tests/test_vboot.py6
15 files changed, 503 insertions, 30 deletions
diff --git a/test/py/conftest.py b/test/py/conftest.py
index 2ba34479e0..304e93164a 100644
--- a/test/py/conftest.py
+++ b/test/py/conftest.py
@@ -15,9 +15,11 @@
import atexit
import configparser
import errno
+import filelock
import io
import os
import os.path
+from pathlib import Path
import pytest
import re
from _pytest.runner import runtestprotocol
@@ -27,6 +29,8 @@ import sys
log = None
console = None
+TEST_PY_DIR = os.path.dirname(os.path.abspath(__file__))
+
def mkdir_p(path):
"""Create a directory path.
@@ -76,6 +80,53 @@ def pytest_addoption(parser):
help='Run sandbox under gdbserver. The argument is the channel '+
'over which gdbserver should communicate, e.g. localhost:1234')
+def run_build(config, source_dir, build_dir, board_type, log):
+ """run_build: Build U-Boot
+
+ Args:
+ config: The pytest configuration.
+ soruce_dir (str): Directory containing source code
+ build_dir (str): Directory to build in
+ board_type (str): board_type parameter (e.g. 'sandbox')
+ log (Logfile): Log file to use
+ """
+ if config.getoption('buildman'):
+ if build_dir != source_dir:
+ dest_args = ['-o', build_dir, '-w']
+ else:
+ dest_args = ['-i']
+ cmds = (['buildman', '--board', board_type] + dest_args,)
+ name = 'buildman'
+ else:
+ if build_dir != source_dir:
+ o_opt = 'O=%s' % build_dir
+ else:
+ o_opt = ''
+ cmds = (
+ ['make', o_opt, '-s', board_type + '_defconfig'],
+ ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())],
+ )
+ name = 'make'
+
+ with log.section(name):
+ runner = log.get_runner(name, sys.stdout)
+ for cmd in cmds:
+ runner.run(cmd, cwd=source_dir)
+ runner.close()
+ log.status_pass('OK')
+
+def pytest_xdist_setupnodes(config, specs):
+ """Clear out any 'done' file from a previous build"""
+ global build_done_file
+ build_dir = config.getoption('build_dir')
+ board_type = config.getoption('board_type')
+ source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
+ if not build_dir:
+ build_dir = source_dir + '/build-' + board_type
+ build_done_file = Path(build_dir) / 'build.done'
+ if build_done_file.exists():
+ os.remove(build_done_file)
+
def pytest_configure(config):
"""pytest hook: Perform custom initialization at startup time.
@@ -110,8 +161,7 @@ def pytest_configure(config):
global console
global ubconfig
- test_py_dir = os.path.dirname(os.path.abspath(__file__))
- source_dir = os.path.dirname(os.path.dirname(test_py_dir))
+ source_dir = os.path.dirname(os.path.dirname(TEST_PY_DIR))
board_type = config.getoption('board_type')
board_type_filename = board_type.replace('-', '_')
@@ -142,30 +192,13 @@ def pytest_configure(config):
log = multiplexed_log.Logfile(result_dir + '/test-log.html')
if config.getoption('build'):
- if config.getoption('buildman'):
- if build_dir != source_dir:
- dest_args = ['-o', build_dir, '-w']
- else:
- dest_args = ['-i']
- cmds = (['buildman', '--board', board_type] + dest_args,)
- name = 'buildman'
- else:
- if build_dir != source_dir:
- o_opt = 'O=%s' % build_dir
- else:
- o_opt = ''
- cmds = (
- ['make', o_opt, '-s', board_type + '_defconfig'],
- ['make', o_opt, '-s', '-j{}'.format(os.cpu_count())],
- )
- name = 'make'
-
- with log.section(name):
- runner = log.get_runner(name, sys.stdout)
- for cmd in cmds:
- runner.run(cmd, cwd=source_dir)
- runner.close()
- log.status_pass('OK')
+ worker_id = os.environ.get("PYTEST_XDIST_WORKER")
+ with filelock.FileLock(os.path.join(build_dir, 'build.lock')):
+ build_done_file = Path(build_dir) / 'build.done'
+ if (not worker_id or worker_id == 'master' or
+ not build_done_file.exists()):
+ run_build(config, source_dir, build_dir, board_type, log)
+ build_done_file.touch()
class ArbitraryAttributeContainer(object):
pass
@@ -197,7 +230,7 @@ def pytest_configure(config):
else:
parse_config('include/autoconf.mk')
- ubconfig.test_py_dir = test_py_dir
+ ubconfig.test_py_dir = TEST_PY_DIR
ubconfig.source_dir = source_dir
ubconfig.build_dir = build_dir
ubconfig.result_dir = result_dir
@@ -521,6 +554,22 @@ def setup_requiredtool(item):
if not tool_is_in_path(tool):
pytest.skip('tool "%s" not in $PATH' % tool)
+def setup_singlethread(item):
+ """Process any 'singlethread' marker for a test.
+
+ Skip this test if running in parallel.
+
+ Args:
+ item: The pytest test item.
+
+ Returns:
+ Nothing.
+ """
+ for single in item.iter_markers('singlethread'):
+ worker_id = os.environ.get("PYTEST_XDIST_WORKER")
+ if worker_id and worker_id != 'master':
+ pytest.skip('must run single-threaded')
+
def start_test_section(item):
anchors[item.name] = log.start_section(item.name)
@@ -541,6 +590,7 @@ def pytest_runtest_setup(item):
setup_boardspec(item)
setup_buildconfigspec(item)
setup_requiredtool(item)
+ setup_singlethread(item)
def pytest_runtest_protocol(item, nextitem):
"""pytest hook: Called to execute a test.
diff --git a/test/py/pytest.ini b/test/py/pytest.ini
index e93d010f1f..26d83f83e0 100644
--- a/test/py/pytest.ini
+++ b/test/py/pytest.ini
@@ -11,3 +11,4 @@ markers =
notbuildconfigspec: U-Boot: Describes required disabled Kconfig options.
requiredtool: U-Boot: Required host tools for a test.
slow: U-Boot: Specific test will run slowly.
+ singlethread: Cannot run in parallel
diff --git a/test/py/requirements.txt b/test/py/requirements.txt
index ead92ed8b4..1bf77b59d8 100644
--- a/test/py/requirements.txt
+++ b/test/py/requirements.txt
@@ -2,6 +2,7 @@ atomicwrites==1.4.1
attrs==19.3.0
coverage==4.5.4
extras==1.0.0
+filelock==3.0.12
fixtures==3.0.0
importlib-metadata==0.23
linecache2==1.0.0
@@ -15,6 +16,7 @@ pyelftools==0.27
pygit2==1.9.2
pyparsing==2.4.2
pytest==6.2.5
+pytest-xdist==2.5.0
python-mimeparse==1.6.0
python-subunit==1.3.0
requests==2.25.1
diff --git a/test/py/tests/test_bind.py b/test/py/tests/test_bind.py
index c90c54d266..1376ab5ed2 100644
--- a/test/py/tests/test_bind.py
+++ b/test/py/tests/test_bind.py
@@ -119,6 +119,7 @@ def get_next_line(tree, name):
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_bind')
+@pytest.mark.singlethread
def test_bind_unbind_with_uclass(u_boot_console):
#bind /bind-test
response = u_boot_console.run_command('bind /bind-test simple_bus')
diff --git a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py
index 75a6e7c962..1bb59d8fcf 100644
--- a/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py
+++ b/test/py/tests/test_efi_bootmgr/test_efi_bootmgr.py
@@ -7,6 +7,7 @@ import pytest
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('cmd_efidebug')
@pytest.mark.buildconfigspec('cmd_bootefi_bootmgr')
+@pytest.mark.singlethread
def test_efi_bootmgr(u_boot_console, efi_bootmgr_data):
""" Unit test for UEFI bootmanager
The efidebug command is used to set up UEFI load options.
diff --git a/test/py/tests/test_eficonfig/conftest.py b/test/py/tests/test_eficonfig/conftest.py
new file mode 100644
index 0000000000..f289df0362
--- /dev/null
+++ b/test/py/tests/test_eficonfig/conftest.py
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: GPL-2.0+
+
+"""Fixture for UEFI eficonfig test
+"""
+
+import os
+import shutil
+from subprocess import check_call
+import pytest
+
+@pytest.fixture(scope='session')
+def efi_eficonfig_data(u_boot_config):
+ """Set up a file system to be used in UEFI "eficonfig" command
+ tests
+
+ Args:
+ u_boot_config -- U-boot configuration.
+
+ Return:
+ A path to disk image to be used for testing
+ """
+ mnt_point = u_boot_config.persistent_data_dir + '/test_efi_eficonfig'
+ image_path = u_boot_config.persistent_data_dir + '/efi_eficonfig.img'
+
+ shutil.rmtree(mnt_point, ignore_errors=True)
+ os.mkdir(mnt_point, mode = 0o755)
+
+ with open(mnt_point + '/initrd-1.img', 'w', encoding = 'ascii') as file:
+ file.write("initrd 1")
+
+ with open(mnt_point + '/initrd-2.img', 'w', encoding = 'ascii') as file:
+ file.write("initrd 2")
+
+ shutil.copyfile(u_boot_config.build_dir + '/lib/efi_loader/initrddump.efi',
+ mnt_point + '/initrddump.efi')
+
+ check_call(f'virt-make-fs --partition=gpt --size=+1M --type=vfat {mnt_point} {image_path}',
+ shell=True)
+
+ return image_path
diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py b/test/py/tests/test_eficonfig/test_eficonfig.py
new file mode 100644
index 0000000000..99606d9c4b
--- /dev/null
+++ b/test/py/tests/test_eficonfig/test_eficonfig.py
@@ -0,0 +1,354 @@
+# SPDX-License-Identifier: GPL-2.0+
+""" Unit test for UEFI menu-driven configuration
+"""
+
+import pytest
+import time
+
+@pytest.mark.boardspec('sandbox')
+@pytest.mark.buildconfigspec('cmd_eficonfig')
+@pytest.mark.buildconfigspec('cmd_bootefi_bootmgr')
+def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
+
+ def send_user_input_and_wait(user_str, expect_str):
+ time.sleep(0.1) # TODO: does not work correctly without sleep
+ u_boot_console.run_command(cmd=user_str, wait_for_prompt=False,
+ wait_for_echo=True, send_nl=False)
+ u_boot_console.run_command(cmd='\x0d', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ if expect_str is not None:
+ for i in expect_str:
+ u_boot_console.p.expect([i])
+
+ def press_up_down_enter_and_wait(up_count, down_count, enter, expect_str):
+ # press UP key
+ for i in range(up_count):
+ u_boot_console.run_command(cmd='\x1b\x5b\x41', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ # press DOWN key
+ for i in range(down_count):
+ u_boot_console.run_command(cmd='\x1b\x5b\x42', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ # press ENTER if requested
+ if enter:
+ u_boot_console.run_command(cmd='\x0d', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ # wait expected output
+ if expect_str is not None:
+ for i in expect_str:
+ u_boot_console.p.expect([i])
+
+ def press_escape_key(wait_prompt):
+ u_boot_console.run_command(cmd='\x1b', wait_for_prompt=wait_prompt, wait_for_echo=False, send_nl=False)
+
+ def press_enter_key(wait_prompt):
+ u_boot_console.run_command(cmd='\x0d', wait_for_prompt=wait_prompt,
+ wait_for_echo=False, send_nl=False)
+
+ def check_current_is_maintenance_menu():
+ for i in ('UEFI Maintenance Menu', 'Add Boot Option', 'Edit Boot Option',
+ 'Change Boot Order', 'Delete Boot Option', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ """ Unit test for "eficonfig" command
+ The menu-driven interface 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
+ efi__data -- Path to the disk image used for testing.
+ Test disk image has following files.
+ initrd-1.img
+ initrd-2.img
+ initrddump.efi
+
+ """
+
+ # Restart the system to clean the previous state
+ u_boot_console.restart_uboot()
+
+ with u_boot_console.temporary_timeout(500):
+ #
+ # Test Case 1: Check the menu is displayed
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+ for i in ('UEFI Maintenance Menu', 'Add Boot Option', 'Edit Boot Option',
+ 'Change Boot Order', 'Delete Boot Option', 'Quit'):
+ u_boot_console.p.expect([i])
+ # Select "Add Boot Option"
+ press_enter_key(False)
+ for i in ('Add Boot Option', 'Description:', 'File', 'Initrd File', 'Optional Data',
+ 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+ press_escape_key(False)
+ check_current_is_maintenance_menu()
+ # return to U-Boot console
+ press_escape_key(True)
+
+ #
+ # Test Case 2: check auto generated media device entry
+ #
+
+ # bind the test disk image for succeeding tests
+ u_boot_console.run_command(cmd = f'host bind 0 {efi_eficonfig_data}')
+
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+
+ # Change the Boot Order
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+ for i in ('host 0:1', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+ # disable auto generated boot option for succeeding test
+ u_boot_console.run_command(cmd=' ', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ # Save the BootOrder
+ press_up_down_enter_and_wait(0, 1, True, None)
+ check_current_is_maintenance_menu()
+
+ #
+ # Test Case 3: Add first Boot Option and load it
+ #
+
+ # Select 'Add Boot Option'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+
+ # Press the enter key to select 'Description:' entry, then enter Description
+ press_up_down_enter_and_wait(0, 0, True, 'enter description:')
+ # Send Description user input, press ENTER key to complete
+ send_user_input_and_wait('test 1', 'Quit')
+
+ # Set EFI image(initrddump.efi)
+ press_up_down_enter_and_wait(0, 1, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'host 0:1')
+ # Select 'host 0:1'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ # Press down key to select "initrddump.efi" entry followed by the enter key
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+
+ # Set Initrd file(initrd-1.img)
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'host 0:1')
+ # Select 'host 0:1'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ # Press down key to select "initrd-1.img" entry followed by the enter key
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+
+ # Set optional_data
+ press_up_down_enter_and_wait(0, 3, True, 'Optional Data:')
+ # Send Description user input, press ENTER key to complete
+ send_user_input_and_wait('nocolor', None)
+ for i in ('Description: test 1', 'File: host 0:1/initrddump.efi',
+ 'Initrd File: host 0:1/initrd-1.img', 'Optional Data: nocolor', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ # Save the Boot Option
+ press_up_down_enter_and_wait(0, 4, True, None)
+ check_current_is_maintenance_menu()
+
+ # Check the newly added Boot Option is handled correctly
+ # Return to U-Boot console
+ press_escape_key(True)
+ u_boot_console.run_command(cmd = 'bootefi bootmgr')
+ response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False)
+ assert 'crc32: 0x181464af' in response
+ u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+
+ #
+ # Test Case 4: Add second Boot Option and load it
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+
+ # Select 'Add Boot Option'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+
+ # Press the enter key to select 'Description:' entry, then enter Description
+ press_up_down_enter_and_wait(0, 0, True, 'enter description:')
+ # Send Description user input, press ENTER key to complete
+ send_user_input_and_wait('test 2', 'Quit')
+
+ # Set EFI image(initrddump.efi)
+ press_up_down_enter_and_wait(0, 1, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'host 0:1')
+ # Select 'host 0:1'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ # Press down key to select "initrddump.efi" entry followed by the enter key
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+
+ # Set Initrd file(initrd-2.img)
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'host 0:1')
+ # Select 'host 0:1'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ # Press down key to select "initrd-2.img" entry followed by the enter key
+ press_up_down_enter_and_wait(0, 1, True, 'Quit')
+
+ # Set optional_data
+ press_up_down_enter_and_wait(0, 3, True, 'Optional Data:')
+ # Send Description user input, press ENTER key to complete
+ send_user_input_and_wait('nocolor', None)
+ for i in ('Description: test 2', 'File: host 0:1/initrddump.efi',
+ 'Initrd File: host 0:1/initrd-2.img', 'Optional Data: nocolor', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ # Save the Boot Option
+ press_up_down_enter_and_wait(0, 4, True, 'Quit')
+
+ # Change the Boot Order
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+ press_up_down_enter_and_wait(0, 1, False, 'Quit')
+ # move 'test 1' to the second entry
+ u_boot_console.run_command(cmd='+', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ for i in ('test 2', 'test 1', 'host 0:1', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+ # Save the BootOrder
+ press_up_down_enter_and_wait(0, 3, True, None)
+ check_current_is_maintenance_menu()
+
+ # Check the newly added Boot Option is handled correctly
+ # Return to U-Boot console
+ press_escape_key(True)
+ u_boot_console.run_command(cmd = 'bootefi bootmgr')
+ response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False)
+ assert 'crc32: 0x811d3515' in response
+ u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+
+ #
+ # Test Case 5: Change BootOrder and load it
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+
+ # Change the Boot Order
+ press_up_down_enter_and_wait(0, 2, True, None)
+ # Check the curren BootOrder
+ for i in ('test 2', 'test 1', 'host 0:1', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+ # move 'test 2' to the second entry
+ u_boot_console.run_command(cmd='-', wait_for_prompt=False,
+ wait_for_echo=False, send_nl=False)
+ for i in ('test 1', 'test 2', 'host 0:1', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+ # Save the BootOrder
+ press_up_down_enter_and_wait(0, 2, True, None)
+ check_current_is_maintenance_menu()
+
+ # Return to U-Boot console
+ press_escape_key(True)
+ u_boot_console.run_command(cmd = 'bootefi bootmgr')
+ response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False)
+ assert 'crc32: 0x181464af' in response
+ u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+
+ #
+ # Test Case 6: Delete Boot Option(label:test 2)
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+
+ # Select 'Delete Boot Option'
+ press_up_down_enter_and_wait(0, 3, True, None)
+ # Check the current BootOrder
+ for i in ('test 1', 'test 2', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ # Delete 'test 2'
+ press_up_down_enter_and_wait(0, 1, True, None)
+ for i in ('test 1', 'Quit'):
+ u_boot_console.p.expect([i])
+ press_escape_key(False)
+ check_current_is_maintenance_menu()
+ # Return to U-Boot console
+ press_escape_key(True)
+
+ #
+ # Test Case 7: Edit Boot Option
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+ # Select 'Edit Boot Option'
+ press_up_down_enter_and_wait(0, 1, True, None)
+ # Check the curren BootOrder
+ for i in ('test 1', 'Quit'):
+ u_boot_console.p.expect([i])
+ press_up_down_enter_and_wait(0, 0, True, None)
+ for i in ('Description: test 1', 'File: host 0:1/initrddump.efi',
+ 'Initrd File: host 0:1/initrd-1.img', 'Optional Data: nocolor', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ # Press the enter key to select 'Description:' entry, then enter Description
+ press_up_down_enter_and_wait(0, 0, True, 'enter description:')
+ # Send Description user input, press ENTER key to complete
+ send_user_input_and_wait('test 3', 'Quit')
+
+ # Set EFI image(initrddump.efi)
+ press_up_down_enter_and_wait(0, 1, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'host 0:1')
+ # Select 'host 0:1'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ # Press down key to select "initrddump.efi" entry followed by the enter key
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+
+ # Set Initrd file(initrd-2.img)
+ press_up_down_enter_and_wait(0, 2, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'host 0:1')
+ # Select 'host 0:1'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ # Press down key to select "initrd-1.img" entry followed by the enter key
+ press_up_down_enter_and_wait(0, 1, True, 'Quit')
+
+ # Set optional_data
+ press_up_down_enter_and_wait(0, 3, True, 'Optional Data:')
+ # Send Description user input, press ENTER key to complete
+ send_user_input_and_wait('', None)
+ for i in ('Description: test 3', 'File: host 0:1/initrddump.efi',
+ 'Initrd File: host 0:1/initrd-2.img', 'Optional Data:', 'Save', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ # Save the Boot Option
+ press_up_down_enter_and_wait(0, 4, True, 'Quit')
+ press_escape_key(False)
+ check_current_is_maintenance_menu()
+
+ # Check the updated Boot Option is handled correctly
+ # Return to U-Boot console
+ press_escape_key(True)
+ u_boot_console.run_command(cmd = 'bootefi bootmgr')
+ response = u_boot_console.run_command(cmd = 'load', wait_for_echo=False)
+ assert 'crc32: 0x811d3515' in response
+ u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+
+ #
+ # Test Case 8: Delete Boot Option(label:test 3)
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+
+ # Select 'Delete Boot Option'
+ press_up_down_enter_and_wait(0, 3, True, None)
+ # Check the curren BootOrder
+ for i in ('test 3', 'Quit'):
+ u_boot_console.p.expect([i])
+
+ # Delete 'test 3'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+ press_escape_key(False)
+ check_current_is_maintenance_menu()
+ # Return to U-Boot console
+ press_escape_key(True)
+
+ # remove the host device
+ u_boot_console.run_command(cmd = f'host bind -r 0')
+
+ #
+ # Test Case 9: No block device found
+ #
+ u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+
+ # Select 'Add Boot Option'
+ press_up_down_enter_and_wait(0, 0, True, 'Quit')
+
+ # Set EFI image
+ press_up_down_enter_and_wait(0, 1, True, 'Quit')
+ press_up_down_enter_and_wait(0, 0, True, 'No block device found!')
+ press_escape_key(False)
+ check_current_is_maintenance_menu()
+ # Return to U-Boot console
+ press_escape_key(True)
diff --git a/test/py/tests/test_fit_ecdsa.py b/test/py/tests/test_fit_ecdsa.py
index 87b6081222..cc6c0c4dc4 100644
--- a/test/py/tests/test_fit_ecdsa.py
+++ b/test/py/tests/test_fit_ecdsa.py
@@ -10,6 +10,7 @@ signature is then extracted, and verified against pyCryptodome.
This test doesn't run the sandbox. It only checks the host tool 'mkimage'
"""
+import os
import pytest
import u_boot_utils as util
from Cryptodome.Hash import SHA256
@@ -84,7 +85,8 @@ def test_fit_ecdsa(u_boot_console):
cons = u_boot_console
mkimage = cons.config.build_dir + '/tools/mkimage'
datadir = cons.config.source_dir + '/test/py/tests/vboot/'
- tempdir = cons.config.result_dir
+ tempdir = os.path.join(cons.config.result_dir, 'ecdsa')
+ os.makedirs(tempdir, exist_ok=True)
key_file = f'{tempdir}/ecdsa-test-key.pem'
fit_file = f'{tempdir}/test.fit'
dtc('sandbox-kernel.dts')
diff --git a/test/py/tests/test_fit_hashes.py b/test/py/tests/test_fit_hashes.py
index e228ea96d3..4891e77ca2 100644
--- a/test/py/tests/test_fit_hashes.py
+++ b/test/py/tests/test_fit_hashes.py
@@ -10,6 +10,7 @@ output of a fixed data block with known good hashes.
This test doesn't run the sandbox. It only checks the host tool 'mkimage'
"""
+import os
import pytest
import u_boot_utils as util
@@ -93,7 +94,9 @@ def test_mkimage_hashes(u_boot_console):
cons = u_boot_console
mkimage = cons.config.build_dir + '/tools/mkimage'
datadir = cons.config.source_dir + '/test/py/tests/vboot/'
- tempdir = cons.config.result_dir
+ tempdir = os.path.join(cons.config.result_dir, 'hashes')
+ os.makedirs(tempdir, exist_ok=True)
+
fit_file = f'{tempdir}/test.fit'
dtc('sandbox-kernel.dts')
diff --git a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
index 9eb00d6888..527a556ed8 100644
--- a/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
+++ b/test/py/tests/test_fs/test_squashfs/test_sqfs_ls.py
@@ -105,6 +105,7 @@ def sqfs_run_all_ls_tests(u_boot_console):
@pytest.mark.buildconfigspec('cmd_squashfs')
@pytest.mark.buildconfigspec('fs_squashfs')
@pytest.mark.requiredtool('mksquashfs')
+@pytest.mark.singlethread
def test_sqfs_ls(u_boot_console):
""" Executes the sqfsls test suite.
diff --git a/test/py/tests/test_gpio.py b/test/py/tests/test_gpio.py
index fa0af5f82b..0af186f236 100644
--- a/test/py/tests/test_gpio.py
+++ b/test/py/tests/test_gpio.py
@@ -51,6 +51,7 @@ def test_gpio_exit_statuses(u_boot_console):
def test_gpio_read(u_boot_console):
"""Test that gpio read correctly sets the variable to the value of a gpio pin."""
+ u_boot_console.run_command('gpio clear 0')
response = u_boot_console.run_command('gpio read var 0; echo val:$var,rc:$?')
expected_response = 'val:0,rc:0'
assert(expected_response in response)
diff --git a/test/py/tests/test_gpt.py b/test/py/tests/test_gpt.py
index f707d9f253..cb44e1d789 100644
--- a/test/py/tests/test_gpt.py
+++ b/test/py/tests/test_gpt.py
@@ -13,6 +13,9 @@ These tests rely on a 4 MB disk image, which is automatically created by
the test.
"""
+# Mark all tests here as slow
+pytestmark = pytest.mark.slow
+
class GptTestDiskImage(object):
"""Disk Image used by the GPT tests."""
diff --git a/test/py/tests/test_pinmux.py b/test/py/tests/test_pinmux.py
index b3ae2ab024..794994e12d 100644
--- a/test/py/tests/test_pinmux.py
+++ b/test/py/tests/test_pinmux.py
@@ -68,6 +68,7 @@ def test_pinmux_dev(u_boot_console):
def test_pinmux_status(u_boot_console):
"""Test that 'pinmux status' displays selected pincontroller's pin
muxing descriptions."""
+ u_boot_console.run_command('pinmux dev pinctrl')
output = u_boot_console.run_command('pinmux status')
assert (not 'pinctrl-gpio:' in output)
diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py
index 35fb393c1f..9d42390373 100644
--- a/test/py/tests/test_ut.py
+++ b/test/py/tests/test_ut.py
@@ -114,6 +114,15 @@ def test_ut_dm_init(u_boot_console):
with open(fn, 'wb') as fh:
fh.write(data)
+ # Create a file with a single partition
+ fn = u_boot_console.config.source_dir + '/scsi.img'
+ if not os.path.exists(fn):
+ data = b'\x00' * (2 * 1024 * 1024)
+ with open(fn, 'wb') as fh:
+ fh.write(data)
+ u_boot_utils.run_and_log(
+ u_boot_console, f'sfdisk {fn}', stdin=b'type=83')
+
@pytest.mark.buildconfigspec('cmd_bootflow')
def test_ut_dm_init_bootstd(u_boot_console):
"""Initialise data for bootflow tests"""
diff --git a/test/py/tests/test_vboot.py b/test/py/tests/test_vboot.py
index 040147d88b..e3e7ca4b21 100644
--- a/test/py/tests/test_vboot.py
+++ b/test/py/tests/test_vboot.py
@@ -42,7 +42,7 @@ import vboot_evil
# Only run the full suite on a few combinations, since it doesn't add any more
# test coverage.
-TESTDATA = [
+TESTDATA_IN = [
['sha1-basic', 'sha1', '', None, False, True, False, False],
['sha1-pad', 'sha1', '', '-E -p 0x10000', False, False, False, False],
['sha1-pss', 'sha1', '-pss', None, False, False, False, False],
@@ -60,6 +60,10 @@ TESTDATA = [
['sha256-global-sign-pss', 'sha256', '-pss', '', False, False, False, True],
]
+# Mark all but the first test as slow, so they are not run with '-k not slow'
+TESTDATA = [TESTDATA_IN[0]]
+TESTDATA += [pytest.param(*v, marks=pytest.mark.slow) for v in TESTDATA_IN[1:]]
+
@pytest.mark.boardspec('sandbox')
@pytest.mark.buildconfigspec('fit_signature')
@pytest.mark.requiredtool('dtc')