summaryrefslogtreecommitdiff
path: root/test/py/tests/test_eficonfig/test_eficonfig.py
diff options
context:
space:
mode:
Diffstat (limited to 'test/py/tests/test_eficonfig/test_eficonfig.py')
-rw-r--r--test/py/tests/test_eficonfig/test_eficonfig.py106
1 files changed, 53 insertions, 53 deletions
diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py b/test/py/tests/test_eficonfig/test_eficonfig.py
index d98de5249df..3ca8e27c76b 100644
--- a/test/py/tests/test_eficonfig/test_eficonfig.py
+++ b/test/py/tests/test_eficonfig/test_eficonfig.py
@@ -8,47 +8,47 @@ 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 test_efi_eficonfig(ubman, 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,
+ ubman.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,
+ ubman.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])
+ ubman.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,
+ ubman.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,
+ ubman.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,
+ ubman.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])
+ ubman.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)
+ ubman.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,
+ ubman.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])
+ ubman.p.expect([i])
""" Unit test for "eficonfig" command
The menu-driven interface is used to set up UEFI load options.
@@ -56,7 +56,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
The crc32 of the loaded initrd.img is checked
Args:
- u_boot_console -- U-Boot console
+ ubman -- U-Boot console
efi__data -- Path to the disk image used for testing.
Test disk image has following files.
initrd-1.img
@@ -69,21 +69,21 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
return
# Restart the system to clean the previous state
- u_boot_console.restart_uboot()
+ ubman.restart_uboot()
- with u_boot_console.temporary_timeout(500):
+ with ubman.temporary_timeout(500):
#
# Test Case 1: Check the menu is displayed
#
- u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+ ubman.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])
+ ubman.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])
+ ubman.p.expect([i])
press_escape_key(False)
check_current_is_maintenance_menu()
# return to U-Boot console
@@ -94,16 +94,16 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
#
# bind the test disk image for succeeding tests
- u_boot_console.run_command(cmd = f'host bind 0 {efi_eficonfig_data}')
+ ubman.run_command(cmd = f'host bind 0 {efi_eficonfig_data}')
- u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+ ubman.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])
+ ubman.p.expect([i])
# disable auto generated boot option for succeeding test
- u_boot_console.run_command(cmd=' ', wait_for_prompt=False,
+ ubman.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)
@@ -143,7 +143,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
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])
+ ubman.p.expect([i])
# Save the Boot Option
press_up_down_enter_and_wait(0, 4, True, None)
@@ -152,15 +152,15 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
# 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)
+ ubman.run_command(cmd = 'bootefi bootmgr')
+ response = ubman.run_command(cmd = 'load', wait_for_echo=False)
assert 'crc32: 0x181464af' in response
- u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+ ubman.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)
+ ubman.run_command('eficonfig', wait_for_prompt=False)
# Select 'Add Boot Option'
press_up_down_enter_and_wait(0, 0, True, 'Quit')
@@ -192,7 +192,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
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])
+ ubman.p.expect([i])
# Save the Boot Option
press_up_down_enter_and_wait(0, 4, True, 'Quit')
@@ -201,10 +201,10 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
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,
+ ubman.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])
+ ubman.p.expect([i])
# Save the BootOrder
press_up_down_enter_and_wait(0, 3, True, None)
check_current_is_maintenance_menu()
@@ -212,52 +212,52 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
# 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)
+ ubman.run_command(cmd = 'bootefi bootmgr')
+ response = ubman.run_command(cmd = 'load', wait_for_echo=False)
assert 'crc32: 0x811d3515' in response
- u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+ ubman.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)
+ ubman.run_command('eficonfig', wait_for_prompt=False)
# Change the Boot Order
press_up_down_enter_and_wait(0, 2, True, None)
# Check the current BootOrder
for i in ('test 2', 'test 1', 'host 0:1', 'Save', 'Quit'):
- u_boot_console.p.expect([i])
+ ubman.p.expect([i])
# move 'test 2' to the second entry
- u_boot_console.run_command(cmd='-', wait_for_prompt=False,
+ ubman.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])
+ ubman.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)
+ ubman.run_command(cmd = 'bootefi bootmgr')
+ response = ubman.run_command(cmd = 'load', wait_for_echo=False)
assert 'crc32: 0x181464af' in response
- u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+ ubman.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)
+ ubman.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])
+ ubman.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])
+ ubman.p.expect([i])
press_escape_key(False)
check_current_is_maintenance_menu()
# Return to U-Boot console
@@ -266,16 +266,16 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
#
# Test Case 7: Edit Boot Option
#
- u_boot_console.run_command('eficonfig', wait_for_prompt=False)
+ ubman.run_command('eficonfig', wait_for_prompt=False)
# Select 'Edit Boot Option'
press_up_down_enter_and_wait(0, 1, True, None)
# Check the current BootOrder
for i in ('test 1', 'Quit'):
- u_boot_console.p.expect([i])
+ ubman.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])
+ ubman.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:')
@@ -304,7 +304,7 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
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])
+ ubman.p.expect([i])
# Save the Boot Option
press_up_down_enter_and_wait(0, 4, True, 'Quit')
@@ -314,21 +314,21 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
# 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)
+ ubman.run_command(cmd = 'bootefi bootmgr')
+ response = ubman.run_command(cmd = 'load', wait_for_echo=False)
assert 'crc32: 0x811d3515' in response
- u_boot_console.run_command(cmd = 'exit', wait_for_echo=False)
+ ubman.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)
+ ubman.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 3', 'Quit'):
- u_boot_console.p.expect([i])
+ ubman.p.expect([i])
# Delete 'test 3'
press_up_down_enter_and_wait(0, 0, True, 'Quit')
@@ -338,12 +338,12 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
press_escape_key(True)
# remove the host device
- u_boot_console.run_command(cmd = f'host bind -r 0')
+ ubman.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)
+ ubman.run_command('eficonfig', wait_for_prompt=False)
# Select 'Add Boot Option'
press_up_down_enter_and_wait(0, 0, True, 'Quit')