[PATCH 3/5] test: efi_capsule: test a capsule update containing multiple images

Stefan Herbrechtsmeier stefan.herbrechtsmeier-oss at weidmueller.com
Fri Jun 16 13:34:24 CEST 2023


From: Malte Schmidt <malte.schmidt at weidmueller.com>

Test updating U-Boot and the U-Boot environment with a single capsule.
This test also checks that the mkeficapsule tool builds a capsule
containing both images to update correctly. Testing of a signed and
an unsigned image is implemented.

Signed-off-by: Malte Schmidt <malte.schmidt at weidmueller.com>
Signed-off-by: Stefan Herbrechtsmeier <stefan.herbrechtsmeier at weidmueller.com>
---

 test/py/tests/test_efi_capsule/conftest.py    | 18 +++++++-
 .../test_capsule_firmware_raw.py              | 46 ++++++++++++++++---
 .../test_capsule_firmware_signed_raw.py       | 24 ++++++++--
 3 files changed, 77 insertions(+), 11 deletions(-)

diff --git a/test/py/tests/test_efi_capsule/conftest.py b/test/py/tests/test_efi_capsule/conftest.py
index 054be1ee97..7acafb8599 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -124,6 +124,12 @@ def efi_capsule_data(request, u_boot_config):
                         '--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 uboot_bin_env.itb Test105' %
                    (data_dir, u_boot_config.build_dir),
                    shell=True)
+        check_call('cd %s; %s/tools/mkeficapsule --index 1,2 '
+                         '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8,5A7021F5-FEF2-48B4-AABA-832E777418C0 '
+                         '-b u-boot.bin.new,u-boot.env.new '
+                         'Test106' %
+                   (data_dir, u_boot_config.build_dir),
+                   shell=True)
 
         if capsule_auth_enabled:
             # raw firmware signed with proper key
@@ -205,7 +211,17 @@ def efi_capsule_data(request, u_boot_config):
                             'uboot_bin_env.itb Test115'
                        % (data_dir, u_boot_config.build_dir),
                        shell=True)
-
+            # multiple raw firmwares with proper key
+            check_call('cd %s; %s/tools/mkeficapsule --index 1,2 '
+                         '--monotonic-count 1,2 '
+                         '--private-key SIGNER.key '
+                         '--certificate SIGNER.crt '
+                         '--fw-version 5,10 '
+                         '--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8,5A7021F5-FEF2-48B4-AABA-832E777418C0 '
+                         '-b u-boot.bin.new,u-boot.env.new '
+                         'Test116'
+                       % (data_dir, u_boot_config.build_dir),
+                       shell=True)
         # Create a disk image with EFI system partition
         check_call('virt-make-fs --partition=gpt --size=+1M --type=vfat %s %s' %
                    (mnt_point, image_path), 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 80d791e3de..627b93b337 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
@@ -105,12 +105,27 @@ class TestEfiCapsuleFirmwareRaw:
     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
+        Update U-Boot and U-Boot environment, raw image format, two separate capsules
+        0x100000-0x150000: U-Boot binary (but dummy)
+        """
+        self.efi_capsule_fw3_common(u_boot_config, u_boot_console, efi_capsule_data, "3", ['Test01', 'Test02'])
+
+    def test_efi_capsule_fw3_multi(
+            self, u_boot_config, u_boot_console, efi_capsule_data):
+        """ Test Case 3-multi
+        Update U-Boot and U-Boot environment, raw image format, one capsule
+        0x100000-0x150000: U-Boot binary (but dummy)
+        """
+        self.efi_capsule_fw3_common(u_boot_config, u_boot_console, efi_capsule_data, "3-multi", ['TODO!'])
+
+    def efi_capsule_fw3_common(self, u_boot_config, u_boot_console, efi_capsule_data, test_case_no, capsule_files):
+        """ Test Case
+        Update U-Boot and U-Boot environment, raw image format
         0x100000-0x150000: U-Boot binary (but dummy)
         """
         disk_img = efi_capsule_data
-        capsule_files = ['Test01', 'Test02']
-        with u_boot_console.log.section('Test Case 3-a, before reboot'):
+
+        with u_boot_console.log.section('Test Case %s-a, before reboot' % test_case_no):
             setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
@@ -124,7 +139,7 @@ class TestEfiCapsuleFirmwareRaw:
         # reboot
         u_boot_console.restart_uboot(expect_reset = capsule_early)
 
-        with u_boot_console.log.section('Test Case 3-b, after reboot'):
+        with u_boot_console.log.section('Test Case %s-b, after reboot' % test_case_no):
             if not capsule_early:
                 exec_manual_update(u_boot_console, disk_img, capsule_files)
 
@@ -147,6 +162,7 @@ class TestEfiCapsuleFirmwareRaw:
             expected = 'u-boot-env:Old' if capsule_auth else 'u-boot-env:New'
             verify_content(u_boot_console, '150000', expected)
 
+
     def test_efi_capsule_fw4(
             self, u_boot_config, u_boot_console, efi_capsule_data):
         """ Test Case 4
@@ -154,9 +170,25 @@ class TestEfiCapsuleFirmwareRaw:
         0x100000-0x150000: U-Boot binary (but dummy)
         0x150000-0x200000: U-Boot environment (but dummy)
         """
+        self.efi_capsule_fw4_common(u_boot_config, u_boot_console, efi_capsule_data, '4', ['Test101', 'Test102'])
+
+    def test_efi_capsule_fw4_multi(
+            self, u_boot_config, u_boot_console, efi_capsule_data):
+        """ Test Case 4-multi
+        Update U-Boot on SPI Flash, raw image format with fw_version and lowest_supported_version, one capsule
+        0x100000-0x150000: U-Boot binary (but dummy)
+        0x150000-0x200000: U-Boot environment (but dummy)
+        """
+        self.efi_capsule_fw4_common(u_boot_config, u_boot_console, efi_capsule_data, '4-multi', ['Test106'])
+
+    def efi_capsule_fw4_common(self, u_boot_config, u_boot_console, efi_capsule_data, test_case_no, capsule_files):
+        """ Test Case
+        Update U-Boot on SPI Flash, raw image format with fw_version and lowest_supported_version
+        0x100000-0x150000: U-Boot binary (but dummy)
+        0x150000-0x200000: U-Boot environment (but dummy)
+        """
         disk_img = efi_capsule_data
-        capsule_files = ['Test101', 'Test102']
-        with u_boot_console.log.section('Test Case 4-a, before reboot'):
+        with u_boot_console.log.section('Test Case %s-a, before reboot' % test_case_no):
             setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             init_content(u_boot_console, '150000', 'u-boot.env.old', 'Old')
@@ -169,7 +201,7 @@ class TestEfiCapsuleFirmwareRaw:
             'config_efi_capsule_on_disk_early')
         capsule_auth = u_boot_config.buildconfig.get(
             'config_efi_capsule_authenticate')
-        with u_boot_console.log.section('Test Case 4-b, after reboot'):
+        with u_boot_console.log.section('Test Case %s-b, after reboot' % test_case_no):
             if not capsule_early:
                 exec_manual_update(u_boot_console, disk_img, capsule_files)
 
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 ad2b1c6324..1624311f00 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
@@ -125,12 +125,30 @@ class TestEfiCapsuleFirmwareSignedRaw():
         """Test Case 4 - Update U-Boot on SPI Flash, raw image format with version information
         0x100000-0x150000: U-Boot binary (but dummy)
 
+        If the capsule is properly signed, the authentication
+        should pass and the firmware be updated.
+        """
+        self.efi_capsule_auth4_common(u_boot_config, u_boot_console, efi_capsule_data, '4', ['Test111', 'Test112'])
+
+    def test_efi_capsule_auth4_multi(
+            self, u_boot_config, u_boot_console, efi_capsule_data):
+        """Test Case 4-multi - Update U-Boot on SPI Flash, raw image format with version information, one capsule
+        0x100000-0x150000: U-Boot binary (but dummy)
+
+        If the capsule is properly signed, the authentication
+        should pass and the firmware be updated.
+        """
+        self.efi_capsule_auth4_common(u_boot_config, u_boot_console, efi_capsule_data, '4-multi', ['Test116'])
+
+    def efi_capsule_auth4_common(self, u_boot_config, u_boot_console, efi_capsule_data, test_case_no, capsule_files):
+        """Test Case  - Update U-Boot on SPI Flash, raw image format with version information
+        0x100000-0x150000: U-Boot binary (but dummy)
+
         If the capsule is properly signed, the authentication
         should pass and the firmware be updated.
         """
         disk_img = efi_capsule_data
-        capsule_files = ['Test111', 'Test112']
-        with u_boot_console.log.section('Test Case 4-a, before reboot'):
+        with u_boot_console.log.section('Test Case %s-a, before reboot' % test_case_no):
             setup(u_boot_console, disk_img, '0x0000000000000004')
             init_content(u_boot_console, '100000', 'u-boot.bin.old', 'Old')
             place_capsule_file(u_boot_console, capsule_files)
@@ -139,7 +157,7 @@ class TestEfiCapsuleFirmwareSignedRaw():
 
         capsule_early = u_boot_config.buildconfig.get(
             'config_efi_capsule_on_disk_early')
-        with u_boot_console.log.section('Test Case 4-b, after reboot'):
+        with u_boot_console.log.section('Test Case %s-b, after reboot' % test_case_no):
             if not capsule_early:
                 exec_manual_update(u_boot_console, disk_img, capsule_files)
 
-- 
2.30.2



More information about the U-Boot mailing list