Add pytest coverage that exercises a real multi-payload capsule update end-to-end: a single capsule file containing two raw-image payloads is applied and both target regions (U-Boot binary and U-Boot environment) are verified to have been updated from one capsule apply. test_efi_capsule_fw6 covers the unsigned case and test_efi_capsule_auth6 covers the signed case, where each payload in the capsule is signed independently.
Signed-off-by: Balaji Selvanathan <[email protected]> --- .../test_efi_capsule/test_capsule_firmware_raw.py | 36 ++++++++++++++++++++++ .../test_capsule_firmware_signed_raw.py | 33 ++++++++++++++++++++ 2 files changed, 69 insertions(+) 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 b8cb483b380..a7c2ceb421f 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 @@ -238,3 +238,39 @@ class TestEfiCapsuleFirmwareRaw: check_file_removed(ubman, disk_img, capsule_files) verify_content(ubman, '100000', 'u-boot:Old') + + def test_efi_capsule_fw6( + self, u_boot_config, ubman, efi_capsule_data): + """ Test Case 6 + Update U-Boot and U-Boot environment on SPI Flash using a single + multi-payload capsule, raw image format + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) + """ + disk_img = efi_capsule_data + capsule_files = ['Test06'] + with ubman.log.section('Test Case 6-a, before reboot'): + capsule_setup(ubman, disk_img, '0x0000000000000004') + init_content(ubman, '100000', 'u-boot.bin.old', 'Old') + init_content(ubman, '150000', 'u-boot.env.old', 'Old') + place_capsule_file(ubman, capsule_files) + + capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') + capsule_auth = u_boot_config.buildconfig.get( + 'config_efi_capsule_authenticate') + + # reboot + ubman.restart_uboot(expect_reset = capsule_early) + + with ubman.log.section('Test Case 6-b, after reboot'): + if not capsule_early: + exec_manual_update(ubman, disk_img, capsule_files) + + check_file_removed(ubman, disk_img, capsule_files) + + expected = 'u-boot:Old' if capsule_auth else 'u-boot:New' + verify_content(ubman, '100000', expected) + + expected = 'u-boot-env:Old' if capsule_auth else 'u-boot-env:New' + verify_content(ubman, '150000', expected) diff --git a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py index a500c499bb9..284fbf68cbe 100644 --- a/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py +++ b/test/py/tests/test_efi_capsule/test_capsule_firmware_signed_raw.py @@ -190,3 +190,36 @@ class TestEfiCapsuleFirmwareSignedRaw(): check_file_removed(ubman, disk_img, capsule_files) verify_content(ubman, '100000', 'u-boot:Old') + + def test_efi_capsule_auth6( + self, u_boot_config, ubman, efi_capsule_data): + """Test Case 6 - Update U-Boot and U-Boot environment on SPI + Flash using a single signed multi-payload capsule, raw image + format + 0x100000-0x150000: U-Boot binary (but dummy) + 0x150000-0x200000: U-Boot environment (but dummy) + + Each payload in the multi-payload capsule is signed + independently. If both signatures are valid, the authentication + should pass and both firmware images should be updated. + """ + disk_img = efi_capsule_data + capsule_files = ['Test15'] + with ubman.log.section('Test Case 6-a, before reboot'): + capsule_setup(ubman, disk_img, '0x0000000000000004') + init_content(ubman, '100000', 'u-boot.bin.old', 'Old') + init_content(ubman, '150000', 'u-boot.env.old', 'Old') + place_capsule_file(ubman, capsule_files) + + do_reboot_dtb_specified(u_boot_config, ubman, 'test_sig.dtb') + + capsule_early = u_boot_config.buildconfig.get( + 'config_efi_capsule_on_disk_early') + with ubman.log.section('Test Case 6-b, after reboot'): + if not capsule_early: + exec_manual_update(ubman, disk_img, capsule_files) + + check_file_removed(ubman, disk_img, capsule_files) + + verify_content(ubman, '100000', 'u-boot:New') + verify_content(ubman, '150000', 'u-boot-env:New') -- 2.34.1
