oe-selftest: fitimage refactor u-boot-tools-native

Eliminate code duplication with a new function.
Use get_bb_var instead of bitbake -e | grep.

(From OE-Core rev: 0c7b7c5c98217b5f139058533159f61d1989d46e)

Signed-off-by: Adrian Freihofer <adrian.freihofer@siemens.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
This commit is contained in:
Adrian Freihofer
2024-07-04 09:09:38 +02:00
committed by Richard Purdie
parent 22b8761c5a
commit 7889a5cd4b

View File

@@ -11,6 +11,11 @@ import re
class FitImageTests(OESelftestTestCase):
def _setup_uboot_tools_native(self):
"""build u-boot-tools-native and return RECIPE_SYSROOT_NATIVE"""
bitbake("u-boot-tools-native -c addto_recipe_sysroot")
return get_bb_var('RECIPE_SYSROOT_NATIVE', 'u-boot-tools-native')
def test_fit_image(self):
"""
Summary: Check if FIT image and Image Tree Source (its) are built
@@ -195,10 +200,8 @@ UBOOT_MKIMAGE_SIGN_ARGS = "-c 'a smart comment'"
self.assertEqual(value, reqvalue)
# Dump the image to see if it really got signed
bitbake("u-boot-tools-native -c addto_recipe_sysroot")
result = runCmd('bitbake -e u-boot-tools-native | grep ^RECIPE_SYSROOT_NATIVE=')
recipe_sysroot_native = result.output.split('=')[1].strip('"')
dumpimage_path = os.path.join(recipe_sysroot_native, 'usr', 'bin', 'dumpimage')
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))
in_signed = None
signed_sections = {}
@@ -516,10 +519,8 @@ UBOOT_FIT_HASH_ALG = "sha256"
self.assertEqual(value, reqvalue)
# Dump the image to see if it really got signed
bitbake("u-boot-tools-native -c addto_recipe_sysroot")
result = runCmd('bitbake -e u-boot-tools-native | grep ^RECIPE_SYSROOT_NATIVE=')
recipe_sysroot_native = result.output.split('=')[1].strip('"')
dumpimage_path = os.path.join(recipe_sysroot_native, 'usr', 'bin', 'dumpimage')
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))
in_signed = None
signed_sections = {}
@@ -671,10 +672,8 @@ FIT_SIGN_INDIVIDUAL = "1"
self.assertEqual(value, reqvalue)
# Dump the image to see if it really got signed
bitbake("u-boot-tools-native -c addto_recipe_sysroot")
result = runCmd('bitbake -e u-boot-tools-native | grep ^RECIPE_SYSROOT_NATIVE=')
recipe_sysroot_native = result.output.split('=')[1].strip('"')
dumpimage_path = os.path.join(recipe_sysroot_native, 'usr', 'bin', 'dumpimage')
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))
in_signed = None
signed_sections = {}