Re: [PATCH v7 10/10] test/py: efi_capsule: test for FMP versioning

2023-06-05 Thread Schmidt, Malte

Hello Masahisa Kojima,

I noticed some excess semicolons in your Python code. See below.

Am 31.05.2023 um 05:35 schrieb Masahisa Kojima:

This test covers the FMP versioning for both raw and FIT image,
and both signed and non-signed capsule update.

Signed-off-by: Masahisa Kojima 
---
Changes in v7:
- use newly introcuded common functions of efi_capsule test

  test/py/tests/test_efi_capsule/conftest.py| 82 ++
  .../test_capsule_firmware_fit.py  | 80 -
  .../test_capsule_firmware_raw.py  | 85 ++-
  .../test_capsule_firmware_signed_fit.py   | 65 ++
  .../test_capsule_firmware_signed_raw.py   | 70 +++
  test/py/tests/test_efi_capsule/version.dts| 24 ++
  6 files changed, 404 insertions(+), 2 deletions(-)
  create mode 100644 test/py/tests/test_efi_capsule/version.dts

diff --git a/test/py/tests/test_efi_capsule/conftest.py 
b/test/py/tests/test_efi_capsule/conftest.py
index a337e62936..d0e20df01e 100644
--- a/test/py/tests/test_efi_capsule/conftest.py
+++ b/test/py/tests/test_efi_capsule/conftest.py
@@ -62,6 +62,23 @@ def efi_capsule_data(request, u_boot_config):
  '-out SIGNER2.crt -nodes -days 365'
 % data_dir, shell=True)

+# Update dtb to add the version information
+check_call('cd %s; '
+   'cp %s/test/py/tests/test_efi_capsule/version.dts .'
+   % (data_dir, u_boot_config.source_dir), shell=True)
+if capsule_auth_enabled:
+check_call('cd %s; '
+   'dtc -@ -I dts -O dtb -o version.dtbo version.dts; '
+   '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; '
+   'fdtoverlay -i %s/arch/sandbox/dts/test.dtb '
+'-o test_ver.dtb version.dtbo'
+   % (data_dir, u_boot_config.build_dir), shell=True)
+
  # Create capsule files
  # two regions: one for u-boot.bin and the other for u-boot.env
  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,
@@ -87,6 +104,26 @@ def efi_capsule_data(request, u_boot_config):
  check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid  
058B7D83-50D5-4C47-A195-60D86AD341C4 uboot_bin_env.itb Test05' %
 (data_dir, u_boot_config.build_dir),
 shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 5 '
+'--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 
u-boot.bin.new Test101' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --index 2 --fw-version 10 '
+'--guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 
u-boot.env.new Test102' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 2 '
+'--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 
u-boot.bin.new Test103' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 5 '
+'--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 
uboot_bin_env.itb Test104' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)
+check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 2 '
+'--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 
uboot_bin_env.itb Test105' %
+   (data_dir, u_boot_config.build_dir),
+   shell=True)

  if capsule_auth_enabled:
  # raw firmware signed with proper key
@@ -123,6 +160,51 @@ def efi_capsule_data(request, u_boot_config):
  'uboot_bin_env.itb Test14'
 % (data_dir, u_boot_config.build_dir),
 shell=True)
+# raw firmware signed with proper key with version information
+check_call('cd %s; '
+   '%s/tools/mkeficapsule --index 1 --monotonic-count 1 '
+'--fw-version 5 '
+'--private-key SIGNER.key --certificate SIGNER.crt 
'
+'--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 '
+'u-boot.bin.new Test111'
+   % (data_dir, u_boot_config.build_dir),
+   shell=True)
+# raw firmware signed wi

Re: [PATCH v7 10/10] test/py: efi_capsule: test for FMP versioning

2023-06-06 Thread Masahisa Kojima
On Mon, 5 Jun 2023 at 23:04, Schmidt, Malte
 wrote:
>
> Hello Masahisa Kojima,
>
> I noticed some excess semicolons in your Python code. See below.
>
> Am 31.05.2023 um 05:35 schrieb Masahisa Kojima:
> > This test covers the FMP versioning for both raw and FIT image,
> > and both signed and non-signed capsule update.
> >
> > Signed-off-by: Masahisa Kojima 
> > ---
> > Changes in v7:
> > - use newly introcuded common functions of efi_capsule test
> >
> >   test/py/tests/test_efi_capsule/conftest.py| 82 ++
> >   .../test_capsule_firmware_fit.py  | 80 -
> >   .../test_capsule_firmware_raw.py  | 85 ++-
> >   .../test_capsule_firmware_signed_fit.py   | 65 ++
> >   .../test_capsule_firmware_signed_raw.py   | 70 +++
> >   test/py/tests/test_efi_capsule/version.dts| 24 ++
> >   6 files changed, 404 insertions(+), 2 deletions(-)
> >   create mode 100644 test/py/tests/test_efi_capsule/version.dts
> >
> > diff --git a/test/py/tests/test_efi_capsule/conftest.py 
> > b/test/py/tests/test_efi_capsule/conftest.py
> > index a337e62936..d0e20df01e 100644
> > --- a/test/py/tests/test_efi_capsule/conftest.py
> > +++ b/test/py/tests/test_efi_capsule/conftest.py
> > @@ -62,6 +62,23 @@ def efi_capsule_data(request, u_boot_config):
> >   '-out SIGNER2.crt -nodes -days 365'
> >  % data_dir, shell=True)
> >
> > +# Update dtb to add the version information
> > +check_call('cd %s; '
> > +   'cp %s/test/py/tests/test_efi_capsule/version.dts .'
> > +   % (data_dir, u_boot_config.source_dir), shell=True)
> > +if capsule_auth_enabled:
> > +check_call('cd %s; '
> > +   'dtc -@ -I dts -O dtb -o version.dtbo version.dts; '
> > +   '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; '
> > +   'fdtoverlay -i %s/arch/sandbox/dts/test.dtb '
> > +'-o test_ver.dtb version.dtbo'
> > +   % (data_dir, u_boot_config.build_dir), shell=True)
> > +
> >   # Create capsule files
> >   # two regions: one for u-boot.bin and the other for u-boot.env
> >   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,
> > @@ -87,6 +104,26 @@ def efi_capsule_data(request, u_boot_config):
> >   check_call('cd %s; %s/tools/mkeficapsule --index 1 --guid  
> > 058B7D83-50D5-4C47-A195-60D86AD341C4 uboot_bin_env.itb Test05' %
> >  (data_dir, u_boot_config.build_dir),
> >  shell=True)
> > +check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 5 '
> > +'--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 
> > u-boot.bin.new Test101' %
> > +   (data_dir, u_boot_config.build_dir),
> > +   shell=True)
> > +check_call('cd %s; %s/tools/mkeficapsule --index 2 --fw-version 10 
> > '
> > +'--guid 5A7021F5-FEF2-48B4-AABA-832E777418C0 
> > u-boot.env.new Test102' %
> > +   (data_dir, u_boot_config.build_dir),
> > +   shell=True)
> > +check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 2 '
> > +'--guid 09D7CF52-0720-4710-91D1-08469B7FE9C8 
> > u-boot.bin.new Test103' %
> > +   (data_dir, u_boot_config.build_dir),
> > +   shell=True)
> > +check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 5 '
> > +'--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 
> > uboot_bin_env.itb Test104' %
> > +   (data_dir, u_boot_config.build_dir),
> > +   shell=True)
> > +check_call('cd %s; %s/tools/mkeficapsule --index 1 --fw-version 2 '
> > +'--guid 3673B45D-6A7C-46F3-9E60-ADABB03F7937 
> > uboot_bin_env.itb Test105' %
> > +   (data_dir, u_boot_config.build_dir),
> > +   shell=True)
> >
> >   if capsule_auth_enabled:
> >   # raw firmware signed with proper key
> > @@ -123,6 +160,51 @@ def efi_capsule_data(request, u_boot_config):
> >   'uboot_bin_env.itb Test14'
> >  % (data_dir, u_boot_config.build_dir),
> >  shell=True)
> > +# raw firmware signed with proper key with version information
> > +check_call('cd %s; '
> > +   '%s/tools/mkeficapsule --index 1 --mono