From: Sughosh Ganu <[email protected]>

Add logic to generate capsules through a config file while testing
the EFI capsule update functionality, and enable this on the sandbox
variant.

Signed-off-by: Sughosh Ganu <[email protected]>
Signed-off-by: Balaji Selvanathan <[email protected]>
---
 test/py/tests/test_efi_capsule/capsule_gen_binman.dts |  2 ++
 test/py/tests/test_efi_capsule/conftest.py            | 11 +++++++++++
 2 files changed, 13 insertions(+)

diff --git a/test/py/tests/test_efi_capsule/capsule_gen_binman.dts 
b/test/py/tests/test_efi_capsule/capsule_gen_binman.dts
index 1a62c260474..d1c00670647 100644
--- a/test/py/tests/test_efi_capsule/capsule_gen_binman.dts
+++ b/test/py/tests/test_efi_capsule/capsule_gen_binman.dts
@@ -54,6 +54,7 @@
                };
        };
 
+#if !defined(CONFIG_EFI_USE_CAPSULE_CFG_FILE)
        capsule1 {
                filename = "Test04";
                efi-capsule {
@@ -165,4 +166,5 @@
                        };
                };
        };
+#endif /* CONFIG_EFI_USE_CAPSULE_CFG_FILE */
 };
diff --git a/test/py/tests/test_efi_capsule/conftest.py 
b/test/py/tests/test_efi_capsule/conftest.py
index ad0cda59ebf..039a3db3b70 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -93,6 +93,17 @@ def efi_capsule_data(request, ubman):
                                  'test_efi_capsule', mnt_point)
         check_call(f'dd conv=notrunc if={fsfile} of={image_path} bs=1M 
seek=1', shell=True)
         check_call('sgdisk --mbrtogpt %s' % image_path, shell=True)
+
+        capsule_cfg_file_gen = 
ubman.config.buildconfig.get('config_efi_use_capsule_cfg_file')
+        if capsule_cfg_file_gen:
+            cfg_file = ubman.config.source_dir + '/' +  
ubman.config.buildconfig.get('config_efi_capsule_cfg_file')[1:-1]
+            check_call('cd %s; '
+                       '%s/tools/mkeficapsule -f %s'
+                       % (data_dir, ubman.config.build_dir, cfg_file), 
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)
         check_call('sgdisk %s -A 1:set:0 -t 
1:C12A7328-F81F-11D2-BA4B-00A0C93EC93B' %
                    image_path, shell=True)
         call('rm -f %s' % fsfile, shell=True)

-- 
2.34.1

Reply via email to