All of lore.kernel.org
 help / color / mirror / Atom feed
From: Masahisa Kojima <masahisa.kojima@linaro.org>
To: u-boot@lists.denx.de
Cc: Heinrich Schuchardt <xypron.glpk@gmx.de>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Simon Glass <sjg@chromium.org>,
	Takahiro Akashi <takahiro.akashi@linaro.org>,
	Masahisa Kojima <masahisa.kojima@linaro.org>
Subject: [PATCH v4 7/7] test/py: eficonfig: use direct menu entry access mode
Date: Mon, 24 Oct 2022 13:48:04 +0900	[thread overview]
Message-ID: <20221024044804.3351-8-masahisa.kojima@linaro.org> (raw)
In-Reply-To: <20221024044804.3351-1-masahisa.kojima@linaro.org>

To select the menu entry, use direct access mode instead of
UP/DOWN key operation.

Signed-off-by: Masahisa Kojima <masahisa.kojima@linaro.org>
---
Newly added in v4

 .../py/tests/test_eficonfig/test_eficonfig.py | 177 +++++++-----------
 1 file changed, 70 insertions(+), 107 deletions(-)

diff --git a/test/py/tests/test_eficonfig/test_eficonfig.py b/test/py/tests/test_eficonfig/test_eficonfig.py
index 102bfd7541..dc08a35216 100644
--- a/test/py/tests/test_eficonfig/test_eficonfig.py
+++ b/test/py/tests/test_eficonfig/test_eficonfig.py
@@ -11,7 +11,7 @@ import time
 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
+        time.sleep(0.3) # 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,
@@ -20,20 +20,13 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
             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,
+    def select_entry_and_wait(name, expect_str):
+        u_boot_console.run_command(cmd='&', 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,
+        u_boot_console.run_command(cmd=name, 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)
-        # wait expected output
         if expect_str is not None:
             for i in expect_str:
                 u_boot_console.p.expect([i])
@@ -76,11 +69,12 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
         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)
+
+        select_entry_and_wait('Add Boot', None)
         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
@@ -95,55 +89,43 @@ def test_efi_eficonfig(u_boot_console, 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])
+        select_entry_and_wait('Change Boot', 'Quit')
         # disable auto generated boot option for succeeding test
+        select_entry_and_wait('host 0:1', None)
         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)
+        select_entry_and_wait('Save', 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
+        # Set Description
+        select_entry_and_wait('Add Boot', 'Quit')
+        select_entry_and_wait('Description', 'enter description:')
         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')
+        select_entry_and_wait('File:', 'Quit')
+        select_entry_and_wait('Select File', 'Quit')
+        select_entry_and_wait('host 0:1', 'Quit')
+        select_entry_and_wait('initrddump.efi', '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')
+        select_entry_and_wait('Initrd File:', 'Quit')
+        select_entry_and_wait('Select File', 'Quit')
+        select_entry_and_wait('host 0:1', 'Quit')
+        select_entry_and_wait('initrd-1.img', 'Quit')
 
         # Set optional_data
-        press_up_down_enter_and_wait(0, 3, True, 'Optional Data:')
-        # Send Description user input, press ENTER key to complete
+        select_entry_and_wait('Optional Data:', 'Optional 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])
 
-        # Save the Boot Option
-        press_up_down_enter_and_wait(0, 4, True, None)
+        select_entry_and_wait('Save', None)
         check_current_is_maintenance_menu()
 
         # Check the newly added Boot Option is handled correctly
@@ -159,51 +141,42 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
         #
         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
+        # Set Description
+        select_entry_and_wait('Add Boot', 'Quit')
+        select_entry_and_wait('Description', 'enter description:')
         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')
+        select_entry_and_wait('File:', 'Quit')
+        select_entry_and_wait('Select File', 'Quit')
+        select_entry_and_wait('host 0:1', 'Quit')
+        select_entry_and_wait('initrddump.efi', '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')
+        select_entry_and_wait('Initrd File:', 'Quit')
+        select_entry_and_wait('Select File', 'Quit')
+        select_entry_and_wait('host 0:1', 'Quit')
+        select_entry_and_wait('initrd-2.img', 'Quit')
 
         # Set optional_data
-        press_up_down_enter_and_wait(0, 3, True, 'Optional Data:')
-        # Send Description user input, press ENTER key to complete
+        select_entry_and_wait('Optional Data:', 'Optional 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])
 
-        # Save the Boot Option
-        press_up_down_enter_and_wait(0, 4, True, 'Quit')
+        select_entry_and_wait('Save', None)
+        check_current_is_maintenance_menu()
 
-        # 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
+        select_entry_and_wait('Change Boot', 'Quit')
+        # move 'test 2' to the first entry
+        select_entry_and_wait('test 2', 'Quit')
         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)
+
+        select_entry_and_wait('Save', None)
         check_current_is_maintenance_menu()
 
         # Check the newly added Boot Option is handled correctly
@@ -219,18 +192,18 @@ def test_efi_eficonfig(u_boot_console, 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, None)
+        select_entry_and_wait('Change Boot', 'Quit')
         # 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
+        select_entry_and_wait('test 2', 'Quit')
         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)
+
+        select_entry_and_wait('Save', 'Quit')
         check_current_is_maintenance_menu()
 
         # Return to U-Boot console
@@ -245,14 +218,13 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
         #
         u_boot_console.run_command('eficonfig', wait_for_prompt=False)
 
-        # Select 'Delete Boot Option'
-        press_up_down_enter_and_wait(0, 3, True, None)
+        select_entry_and_wait('Delete Boot', 'Quit')
         # 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)
+        select_entry_and_wait('test 2', 'Quit')
         for i in ('test 1', 'Quit'):
             u_boot_console.p.expect([i])
         press_escape_key(False)
@@ -264,47 +236,40 @@ 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)
-        # Select 'Edit Boot Option'
-        press_up_down_enter_and_wait(0, 1, True, None)
+
+        select_entry_and_wait('Edit Boot', 'Quit')
         # 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)
+        select_entry_and_wait('test 1', 'Quit')
         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
+        # Set Description
+        select_entry_and_wait('Description', 'enter description:')
         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')
+        select_entry_and_wait('File:', 'Quit')
+        select_entry_and_wait('Select File', 'Quit')
+        select_entry_and_wait('host 0:1', 'Quit')
+        select_entry_and_wait('initrddump.efi', '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')
+        select_entry_and_wait('Initrd File:', 'Quit')
+        select_entry_and_wait('Select File', 'Quit')
+        select_entry_and_wait('host 0:1', 'Quit')
+        select_entry_and_wait('initrd-2.img', 'Quit')
 
         # Set optional_data
-        press_up_down_enter_and_wait(0, 3, True, 'Optional Data:')
-        # Send Description user input, press ENTER key to complete
+        select_entry_and_wait('Optional Data:', 'Optional 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])
 
-        # Save the Boot Option
-        press_up_down_enter_and_wait(0, 4, True, 'Quit')
+        select_entry_and_wait('Save', None)
         press_escape_key(False)
         check_current_is_maintenance_menu()
 
@@ -321,14 +286,13 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
         #
         u_boot_console.run_command('eficonfig', wait_for_prompt=False)
 
-        # Select 'Delete Boot Option'
-        press_up_down_enter_and_wait(0, 3, True, None)
+        select_entry_and_wait('Delete Boot', 'Quit')
         # 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')
+        select_entry_and_wait('test 3', 'Quit')
         press_escape_key(False)
         check_current_is_maintenance_menu()
         # Return to U-Boot console
@@ -342,12 +306,11 @@ def test_efi_eficonfig(u_boot_console, efi_eficonfig_data):
         #
         u_boot_console.run_command('eficonfig', wait_for_prompt=False)
 
-        # Select 'Add Boot Option'
-        press_up_down_enter_and_wait(0, 0, True, 'Quit')
+        select_entry_and_wait('Add Boot', '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!')
+        select_entry_and_wait('File:', 'Quit')
+        select_entry_and_wait('Select File', 'No block device found!')
         press_escape_key(False)
         press_escape_key(False)
         check_current_is_maintenance_menu()
-- 
2.17.1


      parent reply	other threads:[~2022-10-24  4:49 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  4:47 [PATCH v4 0/7] eficonfig: add UEFI Secure Boot key maintenance interface Masahisa Kojima
2022-10-24  4:47 ` [PATCH v4 1/7] eficonfig: refactor eficonfig_select_file_handler() Masahisa Kojima
2022-10-24  4:47 ` [PATCH v4 2/7] eficonfig: expose append entry function Masahisa Kojima
2022-10-24  4:48 ` [PATCH v4 3/7] eficonfig: add direct menu entry access mode Masahisa Kojima
2022-10-24  5:40   ` Heinrich Schuchardt
2022-10-24  6:34     ` Masahisa Kojima
2022-10-25  2:53       ` Masahisa Kojima
2022-10-24  4:48 ` [PATCH v4 4/7] eficonfig: add direct menu entry access in change boot order Masahisa Kojima
2022-10-24  4:48 ` [PATCH v4 5/7] eficonfig: add UEFI Secure Boot Key enrollment interface Masahisa Kojima
2022-10-24  4:48 ` [PATCH v4 6/7] eficonfig: add "Show/Delete Signature Database" menu entry Masahisa Kojima
2022-10-24  4:48 ` Masahisa Kojima [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221024044804.3351-8-masahisa.kojima@linaro.org \
    --to=masahisa.kojima@linaro.org \
    --cc=ilias.apalodimas@linaro.org \
    --cc=sjg@chromium.org \
    --cc=takahiro.akashi@linaro.org \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.