summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorTom Rini <trini@konsulko.com>2022-05-04 12:08:40 -0400
committerTom Rini <trini@konsulko.com>2022-05-04 12:08:40 -0400
commit1739a6db5403d187902dcebca548de0644c8078f (patch)
tree62e9a921915bbd79cec42f528b6c454e8488f862 /test
parentc3d451d5e6b7c2ea6d83397d5b6c986ff6ab4ee3 (diff)
parent2158b0da220ccbe969bc18668263141d9a89f13e (diff)
downloadu-boot-1739a6db5403d187902dcebca548de0644c8078f.tar.gz
u-boot-1739a6db5403d187902dcebca548de0644c8078f.tar.bz2
u-boot-1739a6db5403d187902dcebca548de0644c8078f.zip
Merge tag 'efi-2022-07-rc2-2' of https://source.denx.de/u-boot/custodians/u-boot-efi
Pull request for efi-2022-07-rc2-2 * Test Unit test for 'bootmenu' command * UEFI Preparatory patches for implementing a UEFI boot options based menu
Diffstat (limited to 'test')
-rw-r--r--test/Kconfig1
-rw-r--r--test/py/tests/test_bootmenu.py46
-rw-r--r--test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py42
-rw-r--r--test/unicode_ut.c50
4 files changed, 117 insertions, 22 deletions
diff --git a/test/Kconfig b/test/Kconfig
index e15ba239eb..7f3447ae5a 100644
--- a/test/Kconfig
+++ b/test/Kconfig
@@ -91,6 +91,7 @@ config UT_UNICODE
bool "Unit tests for Unicode functions"
depends on UNIT_TEST
default y
+ select CHARSET
help
Enables the 'ut unicode' command which tests that the functions for
manipulating Unicode strings work correctly.
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'):
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index f2f63d5367..d104bd5997 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -758,6 +758,56 @@ static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
UNICODE_TEST(unicode_test_efi_create_indexed_name);
#endif
+static int unicode_test_u16_strlcat(struct unit_test_state *uts)
+{
+ u16 buf[40];
+ u16 dest[] = {0x3053, 0x3093, 0x306b, 0x3061, 0x306f, 0};
+ u16 src[] = {0x03B1, 0x2172, 0x6F5C, 0x8247, 0};
+ u16 concat_str[] = {0x3053, 0x3093, 0x306b, 0x3061, 0x306f,
+ 0x03B1, 0x2172, 0x6F5C, 0x8247, 0};
+ u16 null_src = u'\0';
+ size_t ret, expected;
+ int i;
+
+ /* dest and src are empty string */
+ memset(buf, 0, sizeof(buf));
+ ret = u16_strlcat(buf, &null_src, sizeof(buf));
+ ut_asserteq(1, ret);
+
+ /* dest is empty string */
+ memset(buf, 0, sizeof(buf));
+ ret = u16_strlcat(buf, src, sizeof(buf));
+ ut_asserteq(5, ret);
+ ut_assert(!unicode_test_u16_strcmp(buf, src, 40));
+
+ /* src is empty string */
+ memset(buf, 0xCD, (sizeof(buf) - sizeof(u16)));
+ buf[39] = 0;
+ memcpy(buf, dest, sizeof(dest));
+ ret = u16_strlcat(buf, &null_src, sizeof(buf));
+ ut_asserteq(6, ret);
+ ut_assert(!unicode_test_u16_strcmp(buf, dest, 40));
+
+ for (i = 0; i <= 40; i++) {
+ memset(buf, 0xCD, (sizeof(buf) - sizeof(u16)));
+ buf[39] = 0;
+ memcpy(buf, dest, sizeof(dest));
+ expected = 10;
+ ret = u16_strlcat(buf, src, i);
+ ut_asserteq(expected, ret);
+ if (i <= 6) {
+ ut_assert(!unicode_test_u16_strcmp(buf, dest, 40));
+ } else if (i < 10) {
+ ut_assert(!unicode_test_u16_strcmp(buf, concat_str, i - 1));
+ } else {
+ ut_assert(!unicode_test_u16_strcmp(buf, concat_str, 40));
+ }
+ }
+
+ return 0;
+}
+UNICODE_TEST(unicode_test_u16_strlcat);
+
int do_ut_unicode(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
{
struct unit_test *tests = UNIT_TEST_SUITE_START(unicode_test);