binman: Plumb in support for missing bintools
Bintools can be missing, in which case binman continues operation but
reports an invalid image. Plumb in support for this and add tests for
entry types which use bintools.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 19461c9..6e1c498 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -310,7 +310,8 @@
entry_args=None, images=None, use_real_dtb=False,
use_expanded=False, verbosity=None, allow_missing=False,
allow_fake_blobs=False, extra_indirs=None, threads=None,
- test_section_timeout=False, update_fdt_in_elf=None):
+ test_section_timeout=False, update_fdt_in_elf=None,
+ force_missing_bintools=''):
"""Run binman with a given test file
Args:
@@ -339,6 +340,8 @@
test_section_timeout: True to force the first time to timeout, as
used in testThreadTimeout()
update_fdt_in_elf: Value to pass with --update-fdt-in-elf=xxx
+ force_missing_tools (str): comma-separated list of bintools to
+ regard as missing
Returns:
int return code, 0 on success
@@ -373,6 +376,8 @@
args.append('-M')
if allow_fake_blobs:
args.append('--fake-ext-blobs')
+ if force_missing_bintools:
+ args += ['--force-missing-bintools', force_missing_bintools]
if update_fdt_in_elf:
args += ['--update-fdt-in-elf', update_fdt_in_elf]
if images:
@@ -1713,6 +1718,18 @@
self.assertIn("Node '/binman/gbb': GBB must have a fixed size",
str(e.exception))
+ def testGbbMissing(self):
+ """Test that binman still produces an image if futility is missing"""
+ entry_args = {
+ 'keydir': 'devkeys',
+ }
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('071_gbb.dts', force_missing_bintools='futility',
+ entry_args=entry_args)
+ err = stderr.getvalue()
+ self.assertRegex(err,
+ "Image 'main-section'.*missing bintools.*: futility")
+
def _HandleVblockCommand(self, pipe_list):
"""Fake calls to the futility utility
@@ -1798,6 +1815,19 @@
expected_hashval = m.digest()
self.assertEqual(expected_hashval, hashval)
+ def testVblockMissing(self):
+ """Test that binman still produces an image if futility is missing"""
+ entry_args = {
+ 'keydir': 'devkeys',
+ }
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('074_vblock.dts',
+ force_missing_bintools='futility',
+ entry_args=entry_args)
+ err = stderr.getvalue()
+ self.assertRegex(err,
+ "Image 'main-section'.*missing bintools.*: futility")
+
def testTpl(self):
"""Test that an image with TPL and its device tree can be created"""
# ELF file with a '__bss_size' symbol
@@ -2335,6 +2365,16 @@
self.assertIn('Could not complete processing of contents',
str(e.exception))
+ def testIfwiMissing(self):
+ """Test that binman still produces an image if ifwitool is missing"""
+ self._SetupIfwi('fitimage.bin')
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('111_x86_rom_ifwi.dts',
+ force_missing_bintools='ifwitool')
+ err = stderr.getvalue()
+ self.assertRegex(err,
+ "Image 'main-section'.*missing bintools.*: ifwitool")
+
def testCbfsOffset(self):
"""Test a CBFS with files at particular offsets
@@ -3614,6 +3654,15 @@
# Just check that the data appears in the file somewhere
self.assertIn(U_BOOT_SPL_DATA, data)
+ def testMkimageMissing(self):
+ """Test that binman still produces an image if mkimage is missing"""
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('156_mkimage.dts',
+ force_missing_bintools='mkimage')
+ err = stderr.getvalue()
+ self.assertRegex(err,
+ "Image 'main-section'.*missing bintools.*: mkimage")
+
def testExtblob(self):
"""Test an image with an external blob"""
data = self._DoReadFile('157_blob_ext.dts')
@@ -3734,6 +3783,15 @@
self.assertEqual(U_BOOT_DATA + b'aa',
data[actual_pos:actual_pos + external_data_size])
+ def testFitMissing(self):
+ """Test that binman still produces a FIT image if mkimage is missing"""
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('162_fit_external.dts',
+ force_missing_bintools='mkimage')
+ err = stderr.getvalue()
+ self.assertRegex(err,
+ "Image 'main-section'.*missing bintools.*: mkimage")
+
def testSectionIgnoreHashSignature(self):
"""Test that sections ignore hash, signature nodes for its data"""
data = self._DoReadFile('165_section_ignore_hash_signature.dts')