@@ -12,17 +12,22 @@ import re
class FitImageTests(OESelftestTestCase):
def _setup_uboot_tools_native(self):
- """build u-boot-tools-native and return RECIPE_SYSROOT_NATIVE"""
+ """build u-boot-tools-native and return ${RECIPE_SYSROOT_NATIVE}/${bindir}"""
bitbake("u-boot-tools-native -c addto_recipe_sysroot")
- return get_bb_var('RECIPE_SYSROOT_NATIVE', 'u-boot-tools-native')
+ vars = get_bb_vars(['RECIPE_SYSROOT_NATIVE', 'bindir'], 'u-boot-tools-native')
+ return os.path.join(vars['RECIPE_SYSROOT_NATIVE'], vars['bindir'])
- def _verify_fit_image_signature(self, uboot_tools_sysroot_native, fitimage_path, dtb_path, conf_name=None):
+ def _run_dumpimage(self, fitimage_path, uboot_tools_bindir):
+ dumpimage_path = os.path.join(uboot_tools_bindir, 'dumpimage')
+ return runCmd('%s -l %s' % (dumpimage_path, fitimage_path))
+
+ def _verify_fit_image_signature(self, uboot_tools_bindir, fitimage_path, dtb_path, conf_name=None):
"""Verify the signature of a fit contfiguration
The fit_check_sign utility from u-boot-tools-native is called.
uboot-fit_check_sign -f fitImage -k $dtb_name -c conf-$dtb_name
"""
- fit_check_sign_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'uboot-fit_check_sign')
+ fit_check_sign_path = os.path.join(uboot_tools_bindir, 'uboot-fit_check_sign')
cmd = '%s -f %s -k %s' % (fit_check_sign_path, fitimage_path, dtb_path)
if conf_name:
cmd += ' -c %s' % conf_name
@@ -238,12 +243,11 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'"
self.assertEqual(value, reqvalue)
# Dump the image to see if it really got signed
- uboot_tools_sysroot_native = self._setup_uboot_tools_native()
- dumpimage_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'dumpimage')
- result = runCmd('%s -l %s' % (dumpimage_path, fitimage_path))
+ uboot_tools_bindir = self._setup_uboot_tools_native()
+ dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir)
in_signed = None
signed_sections = {}
- for line in result.output.splitlines():
+ for line in dumpimage_result.output.splitlines():
if line.startswith((' Configuration', ' Image')):
in_signed = re.search(r'\((.*)\)', line).groups()[0]
elif re.match('^ *', line) in (' ', ''):
@@ -272,7 +276,7 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c '%s'"
# Verify the signature for all configurations = DTBs
for dtb in ['am335x-bone.dtb', 'am335x-boneblack.dtb', 'am335x-bonegreen.dtb']:
- self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path,
+ self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path,
os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], dtb), 'conf-' + dtb)
def test_uboot_fit_image(self):
@@ -548,12 +552,11 @@ UBOOT_FIT_HASH_ALG = "sha256"
self.assertEqual(value, reqvalue)
# Dump the image to see if it really got signed
- uboot_tools_sysroot_native = self._setup_uboot_tools_native()
- dumpimage_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'dumpimage')
- result = runCmd('%s -l %s' % (dumpimage_path, fitimage_path))
+ uboot_tools_bindir = self._setup_uboot_tools_native()
+ dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir)
in_signed = None
signed_sections = {}
- for line in result.output.splitlines():
+ for line in dumpimage_result.output.splitlines():
if line.startswith((' Image')):
in_signed = re.search(r'\((.*)\)', line).groups()[0]
elif re.match(' \w', line):
@@ -577,7 +580,7 @@ UBOOT_FIT_HASH_ALG = "sha256"
self.assertEqual(found_comments, 2, "Expected 2 signed and commented section in the fitImage.")
# Verify the signature
- self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path,
+ self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path,
os.path.join(deploy_dir_image, 'u-boot-spl.dtb'))
@@ -696,12 +699,11 @@ FIT_SIGN_INDIVIDUAL = "1"
self.assertEqual(value, reqvalue)
# Dump the image to see if it really got signed
- uboot_tools_sysroot_native = self._setup_uboot_tools_native()
- dumpimage_path = os.path.join(uboot_tools_sysroot_native, 'usr', 'bin', 'dumpimage')
- result = runCmd('%s -l %s' % (dumpimage_path, fitimage_path))
+ uboot_tools_bindir = self._setup_uboot_tools_native()
+ dumpimage_result = self._run_dumpimage(fitimage_path, uboot_tools_bindir)
in_signed = None
signed_sections = {}
- for line in result.output.splitlines():
+ for line in dumpimage_result.output.splitlines():
if line.startswith((' Image')):
in_signed = re.search(r'\((.*)\)', line).groups()[0]
elif re.match(' \w', line):
@@ -725,7 +727,7 @@ FIT_SIGN_INDIVIDUAL = "1"
self.assertEqual(found_comments, 2, "Expected 2 signed and commented section in the fitImage.")
# Verify the signature
- self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path,
+ self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path,
os.path.join(deploy_dir_image, 'u-boot-spl.dtb'))
@@ -850,5 +852,5 @@ FIT_HASH_ALG = "sha256"
self.assertEqual(len(list(filter(rx_sign_line.match, node))), 1, "kernel hash not signed")
# Verify the signature
- uboot_tools_sysroot_native = self._setup_uboot_tools_native()
- self._verify_fit_image_signature(uboot_tools_sysroot_native, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb'))
+ uboot_tools_bindir = self._setup_uboot_tools_native()
+ self._verify_fit_image_signature(uboot_tools_bindir, fitimage_path, os.path.join(bb_vars['DEPLOY_DIR_IMAGE'], 'am335x-bone.dtb'))
Provide a re-usable function which calls the dumpimage utiliy. This is a refactoring. Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com> --- meta/lib/oeqa/selftest/cases/fitimage.py | 44 +++++++++++++----------- 1 file changed, 23 insertions(+), 21 deletions(-)