]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Handle missing bintools correctly in fit
authorSimon Glass <sjg@chromium.org>
Fri, 3 Mar 2023 00:02:43 +0000 (17:02 -0700)
committerSimon Glass <sjg@chromium.org>
Wed, 8 Mar 2023 21:15:14 +0000 (13:15 -0800)
At present these are handled as if they are allowed to be missing, but
this is only true if the -M flag is provided. Fix this and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/fit.py
tools/binman/ftest.py

index 9def44336189320184eae18576b1463546e81753..39aa792b10b155ef4f7f41e4440c6d3f1a02698f 100644 (file)
@@ -453,6 +453,8 @@ class Entry_fit(Entry_section):
             args.update({'align': fdt_util.fdt32_to_cpu(align.value)})
         if self.mkimage.run(reset_timestamp=True, output_fname=output_fname,
                             **args) is None:
+            if not self.GetAllowMissing():
+                self.Raise("Missing tool: 'mkimage'")
             # Bintool is missing; just use empty data as the output
             self.record_missing_bintool(self.mkimage)
             return tools.get_bytes(0, 1024)
index 59085804c24ae7e0d433c668f5e4d193381ddc00..934c8dd26f61236ad3ce3a2f16813fe4d22935a1 100644 (file)
@@ -3999,9 +3999,17 @@ class TestFunctional(unittest.TestCase):
             self.assertEqual(expected, data[image_pos:image_pos+size])
 
     def testFitMissing(self):
+        """Test that binman complains if mkimage is missing"""
+        with self.assertRaises(ValueError) as e:
+            self._DoTestFile('162_fit_external.dts',
+                             force_missing_bintools='mkimage')
+        self.assertIn("Node '/binman/fit': Missing tool: 'mkimage'",
+                      str(e.exception))
+
+    def testFitMissingOK(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',
+            self._DoTestFile('162_fit_external.dts', allow_missing=True,
                              force_missing_bintools='mkimage')
         err = stderr.getvalue()
         self.assertRegex(err, "Image 'image'.*missing bintools.*: mkimage")