[PATCH 0/2] test: unit test for bootmenu

* enable the bootmenu command in the sandbox * provide a unit test for the bootmenu command
Heinrich Schuchardt (2): sandbox: enable bootmenu command test: unit test for bootmenu
configs/sandbox_defconfig | 1 + scripts/pylint.base | 1 + test/py/tests/test_bootmenu.py | 49 ++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+) create mode 100644 test/py/tests/test_bootmenu.py

Provide the bootmenu command on the sandbox for testing.
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- configs/sandbox_defconfig | 1 + 1 file changed, 1 insertion(+)
diff --git a/configs/sandbox_defconfig b/configs/sandbox_defconfig index fe8ea4626d..c509a924e6 100644 --- a/configs/sandbox_defconfig +++ b/configs/sandbox_defconfig @@ -39,6 +39,7 @@ CONFIG_CMD_LICENSE=y CONFIG_CMD_BOOTM_PRE_LOAD=y CONFIG_CMD_BOOTZ=y CONFIG_CMD_BOOTEFI_HELLO=y +CONFIG_CMD_BOOTMENU=y CONFIG_CMD_ABOOTIMG=y # CONFIG_CMD_ELF is not set CONFIG_CMD_ASKENV=y

Provide a unit test for the bootmenu command
Signed-off-by: Heinrich Schuchardt heinrich.schuchardt@canonical.com --- scripts/pylint.base | 1 + test/py/tests/test_bootmenu.py | 48 ++++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/py/tests/test_bootmenu.py
diff --git a/scripts/pylint.base b/scripts/pylint.base index 50e9989e87..9ebebf47ab 100644 --- a/scripts/pylint.base +++ b/scripts/pylint.base @@ -6,6 +6,7 @@ test_tests_test_android_test_ab.py 6.50 test_tests_test_android_test_abootimg.py 6.09 test_tests_test_android_test_avb.py 5.52 test_tests_test_bind.py -2.99 +test_tests_test_bootmenu.py 10.00 test_tests_test_button.py 3.33 test_tests_test_dfu.py 5.45 test_tests_test_dm.py 9.52 diff --git a/test/py/tests/test_bootmenu.py b/test/py/tests/test_bootmenu.py new file mode 100644 index 0000000000..fb03fa417b --- /dev/null +++ b/test/py/tests/test_bootmenu.py @@ -0,0 +1,48 @@ +# 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') + # Without bootmenu_0 no menu should be shown. + u_boot_console.run_command('bootmenu 2') + u_boot_console.run_command('setenv bootmenu_1') + u_boot_console.run_command('setenv bootmenu_2')
participants (1)
-
Heinrich Schuchardt