[PATCH 6/8] test: capsule: Generate capsules through config file

Sughosh Ganu sughosh.ganu at linaro.org
Fri Sep 8 14:00:00 CEST 2023


Add logic to generate capsules through a config file while testing the
EFI capsule update functionality. Capsule generation through config
file is enabled on the sandbox variant.

Signed-off-by: Sughosh Ganu <sughosh.ganu at linaro.org>
---
 .../test_efi_capsule/capsule_gen_binman.dts    |  8 ++++++++
 test/py/tests/test_efi_capsule/conftest.py     | 18 ++++++++++++++----
 2 files changed, 22 insertions(+), 4 deletions(-)

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 e8a1858509..9bde81cbad 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,13 @@
 		};
 	};
 
+#ifdef CONFIG_EFI_USE_CAPSULE_CFG_FILE
+	capsule {
+		efi-capsule-cfg-file {
+			cfg-file = "sandbox_capsule_cfg.txt";
+		};
+	};
+#else
 	capsule1 {
 		filename = "Test01";
 		efi-capsule {
@@ -318,4 +325,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 dd41da9284..dba3114e58 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -76,15 +76,25 @@ def efi_capsule_data(request, u_boot_config):
         check_call('cd %s; echo -n u-boot:Old > u-boot.bin.old; echo -n u-boot:New > u-boot.bin.new; echo -n u-boot-env:Old > u-boot.env.old; echo -n u-boot-env:New > u-boot.env.new' % data_dir,
                    shell=True)
 
+        capsule_cfg_file_gen = u_boot_config.buildconfig.get('config_efi_use_capsule_cfg_file')
+        capsule_cfg_file_flag=""
+        if capsule_cfg_file_gen:
+            capsule_cfg_flag="-DCONFIG_EFI_USE_CAPSULE_CFG_FILE"
+            check_call('cd %s; '
+                       'cp u-boot.bin.* %s; cp u-boot.env.* %s'
+                       % (data_dir, u_boot_config.build_dir, u_boot_config.build_dir), shell=True)
+            check_call('cp %s/test/py/tests/test_efi_capsule/sandbox_capsule_cfg.txt %s'
+                       % (u_boot_config.source_dir, data_dir), shell=True)
+
         pythonpath = os.environ.get('PYTHONPATH', '')
         os.environ['PYTHONPATH'] = pythonpath + ':' + '%s/scripts/dtc/pylibfdt' % u_boot_config.build_dir
         check_call('cd %s; '
-                   'cc -E -I %s/include -x assembler-with-cpp -o capsule_gen_tmp.dts %s/test/py/tests/test_efi_capsule/capsule_gen_binman.dts; '
+                   'cc -E -I %s/include -x assembler-with-cpp %s -o capsule_gen_tmp.dts %s/test/py/tests/test_efi_capsule/capsule_gen_binman.dts; '
                    'dtc -I dts -O dtb capsule_gen_tmp.dts -o capsule_binman.dtb;'
-                   % (data_dir, u_boot_config.source_dir, u_boot_config.source_dir), shell=True)
+                   % (data_dir, u_boot_config.source_dir, capsule_cfg_file_flag, u_boot_config.source_dir), shell=True)
         check_call('cd %s; '
-                   './tools/binman/binman --toolpath %s/tools build -u -d %s/capsule_binman.dtb -O %s -m --allow-missing -I %s -I ./board/sandbox -I ./arch/sandbox/dts'
-                   % (u_boot_config.source_dir, u_boot_config.build_dir, data_dir, data_dir, data_dir), shell=True)
+                   '%s/tools/binman/binman --toolpath %s/tools build -u -d capsule_binman.dtb -O . -m --allow-missing -I . -I %s/board/sandbox -I %s/arch/sandbox/dts'
+                   % (data_dir, u_boot_config.source_dir, u_boot_config.build_dir, u_boot_config.source_dir, u_boot_config.source_dir), shell=True)
         os.environ['PYTHONPATH'] = pythonpath
 
         # Create a disk image with EFI system partition
-- 
2.34.1



More information about the U-Boot mailing list