diff options
Diffstat (limited to 'test/py')
-rw-r--r-- | test/py/tests/test_bootmenu.py | 46 | ||||
-rw-r--r-- | test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py | 42 |
2 files changed, 66 insertions, 22 deletions
diff --git a/test/py/tests/test_bootmenu.py b/test/py/tests/test_bootmenu.py new file mode 100644 index 0000000000..b4baa534aa --- /dev/null +++ b/test/py/tests/test_bootmenu.py @@ -0,0 +1,46 @@ +# SPDX-License-Identifier: GPL-2.0+ + +"""Test bootmenu""" + +import pytest + +@pytest.mark.buildconfigspec('cmd_bootmenu') +def test_bootmenu(u_boot_console): + """Test bootmenu + + u_boot_console -- U-Boot console + """ + + u_boot_console.p.timeout = 500 + u_boot_console.run_command('setenv bootmenu_default 1') + u_boot_console.run_command('setenv bootmenu_0 test 1=echo ok 1') + u_boot_console.run_command('setenv bootmenu_1 test 2=echo ok 2') + u_boot_console.run_command('setenv bootmenu_2 test 3=echo ok 3') + u_boot_console.run_command('bootmenu 2', wait_for_prompt=False) + for i in ('U-Boot Boot Menu', 'test 1', 'test 2', 'test 3', 'autoboot'): + u_boot_console.p.expect([i]) + # Press enter key to execute default entry + response = u_boot_console.run_command(cmd='\x0d', wait_for_echo=False, send_nl=False) + assert 'ok 2' in response + u_boot_console.run_command('bootmenu 2', wait_for_prompt=False) + u_boot_console.p.expect(['autoboot']) + # Press up key to select prior entry followed by the enter key + response = u_boot_console.run_command(cmd='\x1b\x5b\x41\x0d', wait_for_echo=False, + send_nl=False) + assert 'ok 1' in response + u_boot_console.run_command('bootmenu 2', wait_for_prompt=False) + u_boot_console.p.expect(['autoboot']) + # Press down key to select next entry followed by the enter key + response = u_boot_console.run_command(cmd='\x1b\x5b\x42\x0d', wait_for_echo=False, + send_nl=False) + assert 'ok 3' in response + u_boot_console.run_command('bootmenu 2; echo rc:$?', wait_for_prompt=False) + u_boot_console.p.expect(['autoboot']) + # Press the escape key + response = u_boot_console.run_command(cmd='\x1b', wait_for_echo=False, send_nl=False) + assert 'ok' not in response + assert 'rc:0' in response + u_boot_console.run_command('setenv bootmenu_default') + u_boot_console.run_command('setenv bootmenu_0') + u_boot_console.run_command('setenv bootmenu_1') + u_boot_console.run_command('setenv bootmenu_2') diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py index ae99f080ff..c8c647d0b1 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py @@ -1,17 +1,13 @@ # SPDX-License-Identifier: GPL-2.0+ # Copyright (c) 2020, Linaro Limited # Author: AKASHI Takahiro <takahiro.akashi@linaro.org> -# -# U-Boot UEFI: Firmware Update Test -""" +""" U-Boot UEFI: Firmware Update Test This test verifies capsule-on-disk firmware update for raw images """ -from subprocess import check_call, check_output, CalledProcessError import pytest -from capsule_defs import * - +from capsule_defs import CAPSULE_DATA_DIR, CAPSULE_INSTALL_DIR @pytest.mark.boardspec('sandbox') @pytest.mark.buildconfigspec('efi_capsule_firmware_raw') @@ -24,15 +20,18 @@ from capsule_defs import * @pytest.mark.buildconfigspec('cmd_nvedit_efi') @pytest.mark.buildconfigspec('cmd_sf') @pytest.mark.slow -class TestEfiCapsuleFirmwareRaw(object): +class TestEfiCapsuleFirmwareRaw: + """ Tests verifying capsule-on-disk firmware update for raw images + """ + def test_efi_capsule_fw1( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 1 - Update U-Boot and U-Boot environment on SPI Flash - but with an incorrect GUID value in the capsule - No update should happen - 0x100000-0x150000: U-Boot binary (but dummy) - 0x150000-0x200000: U-Boot environment (but dummy) + """ Test Case 1 + Update U-Boot and U-Boot environment on SPI Flash + but with an incorrect GUID value in the capsule + No update should happen + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) """ # other tests might have run and the @@ -106,12 +105,11 @@ class TestEfiCapsuleFirmwareRaw(object): def test_efi_capsule_fw2( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 2 - Update U-Boot and U-Boot environment on SPI Flash - but with OsIndications unset - No update should happen - 0x100000-0x150000: U-Boot binary (but dummy) - 0x150000-0x200000: U-Boot environment (but dummy) + """ Test Case 2 + Update U-Boot and U-Boot environment on SPI Flash but with OsIndications unset + No update should happen + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 2-a, before reboot'): @@ -191,9 +189,9 @@ class TestEfiCapsuleFirmwareRaw(object): def test_efi_capsule_fw3( self, u_boot_config, u_boot_console, efi_capsule_data): - """ - Test Case 3 - Update U-Boot on SPI Flash, raw image format - 0x100000-0x150000: U-Boot binary (but dummy) + """ Test Case 3 + Update U-Boot on SPI Flash, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) """ disk_img = efi_capsule_data with u_boot_console.log.section('Test Case 3-a, before reboot'): |