diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/boot/bootdev.c | 1 | ||||
-rw-r--r-- | test/boot/bootflow.c | 68 | ||||
-rw-r--r-- | test/cmd/setexpr.c | 1 | ||||
-rw-r--r-- | test/compression.c | 1 | ||||
-rw-r--r-- | test/dm/devres.c | 1 | ||||
-rw-r--r-- | test/dm/fwu_mdata.c | 1 | ||||
-rw-r--r-- | test/dm/remoteproc.c | 1 | ||||
-rw-r--r-- | test/dm/spmi.c | 1 | ||||
-rw-r--r-- | test/dm/usb.c | 1 | ||||
-rw-r--r-- | test/overlay/Makefile | 4 | ||||
-rw-r--r-- | test/overlay/cmd_ut_overlay.c | 8 | ||||
-rw-r--r-- | test/overlay/test-fdt-overlay-stacked.dtso (renamed from test/overlay/test-fdt-overlay-stacked.dts) | 0 | ||||
-rw-r--r-- | test/overlay/test-fdt-overlay.dtso (renamed from test/overlay/test-fdt-overlay.dts) | 0 | ||||
-rw-r--r-- | test/py/requirements.txt | 4 | ||||
-rw-r--r-- | test/py/tests/test_efi_capsule/conftest.py | 6 | ||||
-rw-r--r-- | test/py/tests/test_efi_capsule/test_capsule_firmware_raw.py | 21 | ||||
-rw-r--r-- | test/py/tests/test_efi_capsule/version.dtso (renamed from test/py/tests/test_efi_capsule/version.dts) | 0 | ||||
-rw-r--r-- | test/py/tests/test_ut.py | 79 |
18 files changed, 171 insertions, 27 deletions
diff --git a/test/boot/bootdev.c b/test/boot/bootdev.c index 6e940002f84..1bf5929c396 100644 --- a/test/boot/bootdev.c +++ b/test/boot/bootdev.c @@ -680,7 +680,6 @@ static int bootdev_test_next_label(struct unit_test_state *uts) BOOTSTD_TEST(bootdev_test_next_label, UT_TESTF_DM | UT_TESTF_SCAN_FDT | UT_TESTF_ETH_BOOTDEV | UT_TESTF_SF_BOOTDEV); - /* Check iterating to the next prioirty in a list */ static int bootdev_test_next_prio(struct unit_test_state *uts) { diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 4511cfa7f9b..8b46256fa48 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -27,6 +27,7 @@ DECLARE_GLOBAL_DATA_PTR; +extern U_BOOT_DRIVER(bootmeth_android); extern U_BOOT_DRIVER(bootmeth_cros); extern U_BOOT_DRIVER(bootmeth_2script); @@ -518,12 +519,12 @@ BOOTSTD_TEST(bootflow_cmd_boot, UT_TESTF_DM | UT_TESTF_SCAN_FDT); * @uts: Unit test state * @mmc_dev: MMC device to use, e.g. "mmc4". Note that this must remain valid * in the caller until - * @bind_cros: true to bind the ChromiumOS bootmeth + * @bind_cros: true to bind the ChromiumOS and Android bootmeths * @old_orderp: Returns the original bootdev order, which must be restored * Returns 0 on success, -ve on failure */ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev, - bool bind_cros, const char ***old_orderp) + bool bind_cros_android, const char ***old_orderp) { static const char *order[] = {"mmc2", "mmc1", NULL, NULL}; struct udevice *dev, *bootstd; @@ -545,12 +546,19 @@ static int prep_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev, "bootmeth_script", 0, ofnode_null(), &dev)); /* Enable the cros bootmeth if needed */ - if (IS_ENABLED(CONFIG_BOOTMETH_CROS) && bind_cros) { + if (IS_ENABLED(CONFIG_BOOTMETH_CROS) && bind_cros_android) { ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_cros), "cros", 0, ofnode_null(), &dev)); } + /* Enable the android bootmeths if needed */ + if (IS_ENABLED(CONFIG_BOOTMETH_ANDROID) && bind_cros_android) { + ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); + ut_assertok(device_bind(bootstd, DM_DRIVER_REF(bootmeth_android), + "android", 0, ofnode_null(), &dev)); + } + /* Change the order to include the device */ std = dev_get_priv(bootstd); old_order = std->bootdev_order; @@ -590,6 +598,37 @@ static int scan_mmc_bootdev(struct unit_test_state *uts, const char *mmc_dev, } /** + * scan_mmc_android_bootdev() - Set up an mmc bootdev so we can access other + * distros. Android bootflow might print "ANDROID:*" while scanning + * + * @uts: Unit test state + * @mmc_dev: MMC device to use, e.g. "mmc4" + * Returns 0 on success, -ve on failure + */ +static int scan_mmc_android_bootdev(struct unit_test_state *uts, const char *mmc_dev) +{ + struct bootstd_priv *std; + struct udevice *bootstd; + const char **old_order; + + ut_assertok(prep_mmc_bootdev(uts, mmc_dev, true, &old_order)); + + console_record_reset_enable(); + ut_assertok(run_command("bootflow scan", 0)); + /* Android bootflow might print one or two 'ANDROID:*' logs */ + ut_check_skipline(uts); + ut_check_skipline(uts); + ut_assert_console_end(); + + /* Restore the order used by the device tree */ + ut_assertok(uclass_first_device_err(UCLASS_BOOTSTD, &bootstd)); + std = dev_get_priv(bootstd); + std->bootdev_order = old_order; + + return 0; +} + +/** * scan_mmc4_bootdev() - Set up the mmc4 bootdev so we can access a fake Armbian * * @uts: Unit test state @@ -1160,3 +1199,26 @@ static int bootflow_cros(struct unit_test_state *uts) return 0; } BOOTSTD_TEST(bootflow_cros, 0); + +/* Test Android bootmeth */ +static int bootflow_android(struct unit_test_state *uts) +{ + if (!IS_ENABLED(CONFIG_BOOTMETH_ANDROID)) + return -EAGAIN; + + ut_assertok(scan_mmc_android_bootdev(uts, "mmc7")); + ut_assertok(run_command("bootflow list", 0)); + + ut_assert_nextlinen("Showing all"); + ut_assert_nextlinen("Seq"); + ut_assert_nextlinen("---"); + ut_assert_nextlinen(" 0 extlinux"); + ut_assert_nextlinen(" 1 android ready mmc 0 mmc7.bootdev.whole "); + ut_assert_nextlinen("---"); + ut_assert_skip_to_line("(2 bootflows, 2 valid)"); + + ut_assert_console_end(); + + return 0; +} +BOOTSTD_TEST(bootflow_android, 0); diff --git a/test/cmd/setexpr.c b/test/cmd/setexpr.c index d50ce5803c3..4c6cc3cf09e 100644 --- a/test/cmd/setexpr.c +++ b/test/cmd/setexpr.c @@ -329,7 +329,6 @@ static int setexpr_test_str(struct unit_test_state *uts) } SETEXPR_TEST(setexpr_test_str, UT_TESTF_CONSOLE_REC); - /* Test 'setexpr' command with concatenating strings */ static int setexpr_test_str_oper(struct unit_test_state *uts) { diff --git a/test/compression.c b/test/compression.c index aa1d38bb7bc..618a1936955 100644 --- a/test/compression.c +++ b/test/compression.c @@ -139,7 +139,6 @@ static const char zstd_compressed[] = "\x01\xe4\xf4\x6e\xfa"; static const unsigned long zstd_compressed_size = sizeof(zstd_compressed) - 1; - #define TEST_BUFFER_SIZE 512 typedef int (*mutate_func)(struct unit_test_state *uts, void *, unsigned long, diff --git a/test/dm/devres.c b/test/dm/devres.c index 95a470b9f1c..7a3a669ddd4 100644 --- a/test/dm/devres.c +++ b/test/dm/devres.c @@ -69,7 +69,6 @@ static int dm_test_devres_free(struct unit_test_state *uts) } DM_TEST(dm_test_devres_free, UT_TESTF_SCAN_PDATA); - /* Test that kzalloc() returns memory that is zeroed */ static int dm_test_devres_kzalloc(struct unit_test_state *uts) { diff --git a/test/dm/fwu_mdata.c b/test/dm/fwu_mdata.c index 0be7f4519e2..6154480ba83 100644 --- a/test/dm/fwu_mdata.c +++ b/test/dm/fwu_mdata.c @@ -129,7 +129,6 @@ static int dm_test_fwu_mdata_write(struct unit_test_state *uts) */ event_notify_null(EVT_MAIN_LOOP); - ut_assertok(uclass_first_device_err(UCLASS_FWU_MDATA, &dev)); ut_assertok(fwu_init()); diff --git a/test/dm/remoteproc.c b/test/dm/remoteproc.c index ef9e8e5a0df..444c4dce083 100644 --- a/test/dm/remoteproc.c +++ b/test/dm/remoteproc.c @@ -28,7 +28,6 @@ static int dm_test_remoteproc_base(struct unit_test_state *uts) /* Ensure we are initialized */ ut_asserteq(true, rproc_is_initialized()); - /* platform data device 1 */ ut_assertok(rproc_stop(0)); ut_assertok(rproc_reset(0)); diff --git a/test/dm/spmi.c b/test/dm/spmi.c index e10ae8db4d3..ee444f3b9b1 100644 --- a/test/dm/spmi.c +++ b/test/dm/spmi.c @@ -70,7 +70,6 @@ static int dm_test_spmi_access(struct unit_test_state *uts) } DM_TEST(dm_test_spmi_access, UT_TESTF_SCAN_FDT); - /* Test if it's possible to access GPIO that should be in pmic */ static int dm_test_spmi_access_peripheral(struct unit_test_state *uts) { diff --git a/test/dm/usb.c b/test/dm/usb.c index 9a571938b81..0bbea219ec9 100644 --- a/test/dm/usb.c +++ b/test/dm/usb.c @@ -423,7 +423,6 @@ static int dm_test_usb_keyb(struct unit_test_state *uts) {0x00, 0x00, "\0"} }; - state_set_skip_delays(true); ut_assertok(usb_init()); diff --git a/test/overlay/Makefile b/test/overlay/Makefile index 2deec929abf..47937e3c108 100644 --- a/test/overlay/Makefile +++ b/test/overlay/Makefile @@ -10,5 +10,5 @@ DTC_FLAGS += -@ # DT overlays obj-y += test-fdt-base.dtb.o -obj-y += test-fdt-overlay.dtb.o -obj-y += test-fdt-overlay-stacked.dtb.o +obj-y += test-fdt-overlay.dtbo.o +obj-y += test-fdt-overlay-stacked.dtbo.o diff --git a/test/overlay/cmd_ut_overlay.c b/test/overlay/cmd_ut_overlay.c index bcb29a26e21..256afd115d2 100644 --- a/test/overlay/cmd_ut_overlay.c +++ b/test/overlay/cmd_ut_overlay.c @@ -21,8 +21,8 @@ #define FDT_COPY_SIZE (4 * SZ_1K) extern u32 __dtb_test_fdt_base_begin; -extern u32 __dtb_test_fdt_overlay_begin; -extern u32 __dtb_test_fdt_overlay_stacked_begin; +extern u32 __dtbo_test_fdt_overlay_begin; +extern u32 __dtbo_test_fdt_overlay_stacked_begin; static void *fdt; @@ -216,8 +216,8 @@ int do_ut_overlay(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]) const int n_ents = UNIT_TEST_SUITE_COUNT(overlay_test); struct unit_test_state *uts; void *fdt_base = &__dtb_test_fdt_base_begin; - void *fdt_overlay = &__dtb_test_fdt_overlay_begin; - void *fdt_overlay_stacked = &__dtb_test_fdt_overlay_stacked_begin; + void *fdt_overlay = &__dtbo_test_fdt_overlay_begin; + void *fdt_overlay_stacked = &__dtbo_test_fdt_overlay_stacked_begin; void *fdt_overlay_copy, *fdt_overlay_stacked_copy; int ret = -ENOMEM; diff --git a/test/overlay/test-fdt-overlay-stacked.dts b/test/overlay/test-fdt-overlay-stacked.dtso index 6411adec539..6411adec539 100644 --- a/test/overlay/test-fdt-overlay-stacked.dts +++ b/test/overlay/test-fdt-overlay-stacked.dtso diff --git a/test/overlay/test-fdt-overlay.dts b/test/overlay/test-fdt-overlay.dtso index 5a21b346d07..5a21b346d07 100644 --- a/test/overlay/test-fdt-overlay.dts +++ b/test/overlay/test-fdt-overlay.dtso diff --git a/test/py/requirements.txt b/test/py/requirements.txt index c1dd636931f..2b1489808c0 100644 --- a/test/py/requirements.txt +++ b/test/py/requirements.txt @@ -21,10 +21,10 @@ pytest-xdist==2.5.0 python-mimeparse==1.6.0 python-subunit==1.3.0 requests==2.32.2 -setuptools==65.5.1 +setuptools==70.3.0 six==1.16.0 testtools==2.3.0 traceback2==1.4.0 unittest2==1.1.0 wcwidth==0.1.7 -zipp==0.6.0 +zipp==3.19.2 diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py index 80b12977d6f..61eab5112a1 100644 --- a/test/py/tests/test_efi_capsule/conftest.py +++ b/test/py/tests/test_efi_capsule/conftest.py @@ -53,7 +53,7 @@ def efi_capsule_data(request, u_boot_config): # Update dtb to add the version information check_call('cd %s; ' - 'cp %s/test/py/tests/test_efi_capsule/version.dts .' + 'cp %s/test/py/tests/test_efi_capsule/version.dtso .' % (data_dir, u_boot_config.source_dir), shell=True) if capsule_auth_enabled: @@ -61,13 +61,13 @@ def efi_capsule_data(request, u_boot_config): 'cp %s/arch/sandbox/dts/test.dtb test_sig.dtb' % (data_dir, u_boot_config.build_dir), shell=True) check_call('cd %s; ' - 'dtc -@ -I dts -O dtb -o version.dtbo version.dts; ' + 'dtc -@ -I dts -O dtb -o version.dtbo version.dtso; ' 'fdtoverlay -i test_sig.dtb ' '-o test_ver.dtb version.dtbo' % (data_dir), shell=True) else: check_call('cd %s; ' - 'dtc -@ -I dts -O dtb -o version.dtbo version.dts; ' + 'dtc -@ -I dts -O dtb -o version.dtbo version.dtso; ' 'fdtoverlay -i %s/arch/sandbox/dts/test.dtb ' '-o test_ver.dtb version.dtbo' % (data_dir, u_boot_config.build_dir), shell=True) 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 a5b5c8a3853..f3a2dff5c2c 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 @@ -76,7 +76,7 @@ class TestEfiCapsuleFirmwareRaw: 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 + No update should happen unless CONFIG_EFI_IGNORE_OSINDICATIONS is set 0x100000-0x150000: U-Boot binary (but dummy) 0x150000-0x200000: U-Boot environment (but dummy) """ @@ -91,16 +91,27 @@ class TestEfiCapsuleFirmwareRaw: # reboot u_boot_console.restart_uboot() + ignore_os_indications = u_boot_config.buildconfig.get( + 'config_efi_ignore_osindications') + need_reboot = True if ignore_os_indications else False + + capsule_auth = u_boot_config.buildconfig.get( + 'config_efi_capsule_authenticate') + capsule_early = u_boot_config.buildconfig.get( 'config_efi_capsule_on_disk_early') with u_boot_console.log.section('Test Case 2-b, after reboot'): if not capsule_early: - exec_manual_update(u_boot_console, disk_img, capsule_files, False) + exec_manual_update(u_boot_console, disk_img, capsule_files, need_reboot) - check_file_exist(u_boot_console, disk_img, capsule_files) + if not ignore_os_indications: + check_file_exist(u_boot_console, disk_img, capsule_files) - verify_content(u_boot_console, '100000', 'u-boot:Old') - verify_content(u_boot_console, '150000', 'u-boot-env:Old') + expected = 'u-boot:New' if (ignore_os_indications and not capsule_auth) else 'u-boot:Old' + verify_content(u_boot_console, '100000', expected) + + expected = 'u-boot-env:New' if (ignore_os_indications and not capsule_auth) else 'u-boot-env:Old' + verify_content(u_boot_console, '150000', expected) def test_efi_capsule_fw3( self, u_boot_config, u_boot_console, efi_capsule_data): diff --git a/test/py/tests/test_efi_capsule/version.dts b/test/py/tests/test_efi_capsule/version.dtso index 07850cc6064..07850cc6064 100644 --- a/test/py/tests/test_efi_capsule/version.dts +++ b/test/py/tests/test_efi_capsule/version.dtso diff --git a/test/py/tests/test_ut.py b/test/py/tests/test_ut.py index 58205066ec8..05e15830590 100644 --- a/test/py/tests/test_ut.py +++ b/test/py/tests/test_ut.py @@ -11,6 +11,7 @@ import pytest import u_boot_utils # pylint: disable=E0611 from tests import fs_helper +from test_android import test_abootimg def mkdir_cond(dirname): """Create a directory if it doesn't already exist @@ -423,6 +424,83 @@ def setup_cros_image(cons): return fname +def setup_android_image(cons): + """Create a 20MB disk image with Android partitions""" + Partition = collections.namedtuple('part', 'start,size,name') + parts = {} + disk_data = None + + def set_part_data(partnum, data): + """Set the contents of a disk partition + + This updates disk_data by putting data in the right place + + Args: + partnum (int): Partition number to set + data (bytes): Data for that partition + """ + nonlocal disk_data + + start = parts[partnum].start * sect_size + disk_data = disk_data[:start] + data + disk_data[start + len(data):] + + mmc_dev = 7 + fname = os.path.join(cons.config.source_dir, f'mmc{mmc_dev}.img') + u_boot_utils.run_and_log(cons, 'qemu-img create %s 20M' % fname) + u_boot_utils.run_and_log(cons, f'cgpt create {fname}') + + ptr = 40 + + # Number of sectors in 1MB + sect_size = 512 + sect_1mb = (1 << 20) // sect_size + + required_parts = [ + {'num': 1, 'label':'misc', 'size': '1M'}, + {'num': 2, 'label':'boot_a', 'size': '4M'}, + {'num': 3, 'label':'boot_b', 'size': '4M'}, + {'num': 4, 'label':'vendor_boot_a', 'size': '4M'}, + {'num': 5, 'label':'vendor_boot_b', 'size': '4M'}, + ] + + for part in required_parts: + size_str = part['size'] + if 'M' in size_str: + size = int(size_str[:-1]) * sect_1mb + else: + size = int(size_str) + u_boot_utils.run_and_log( + cons, + f"cgpt add -i {part['num']} -b {ptr} -s {size} -l {part['label']} -t basicdata {fname}") + ptr += size + + u_boot_utils.run_and_log(cons, f'cgpt boot -p {fname}') + out = u_boot_utils.run_and_log(cons, f'cgpt show -q {fname}') + + # Create a dict (indexed by partition number) containing the above info + for line in out.splitlines(): + start, size, num, name = line.split(maxsplit=3) + parts[int(num)] = Partition(int(start), int(size), name) + + with open(fname, 'rb') as inf: + disk_data = inf.read() + + test_abootimg.AbootimgTestDiskImage(cons, 'bootv4.img', test_abootimg.boot_img_hex) + boot_img = os.path.join(cons.config.result_dir, 'bootv4.img') + with open(boot_img, 'rb') as inf: + set_part_data(2, inf.read()) + + test_abootimg.AbootimgTestDiskImage(cons, 'vendor_boot.img', test_abootimg.vboot_img_hex) + vendor_boot_img = os.path.join(cons.config.result_dir, 'vendor_boot.img') + with open(vendor_boot_img, 'rb') as inf: + set_part_data(4, inf.read()) + + with open(fname, 'wb') as outf: + outf.write(disk_data) + + print('wrote to {}'.format(fname)) + + return fname def setup_cedit_file(cons): infname = os.path.join(cons.config.source_dir, @@ -478,6 +556,7 @@ def test_ut_dm_init_bootstd(u_boot_console): setup_bootmenu_image(u_boot_console) setup_cedit_file(u_boot_console) setup_cros_image(u_boot_console) + setup_android_image(u_boot_console) # Restart so that the new mmc1.img is picked up u_boot_console.restart_uboot() |