Browse Source

binman: Show an error when a file is missing

The recent support for missing external binaries does not show an error
message when a file is genuinely missing (i.e. it is missing but not
marked as 'external'). This means that when -m is passed to binman, it
will never report a missing file.

Fix this and add a test.

Signed-off-by: Simon Glass <sjg@chromium.org>
Acked-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Simon Glass 3 years ago
parent
commit
204aa78e04
3 changed files with 24 additions and 2 deletions
  1. 3 2
      tools/binman/etype/blob.py
  2. 7 0
      tools/binman/ftest.py
  3. 14 0
      tools/binman/test/173_missing_blob.dts

+ 3 - 2
tools/binman/etype/blob.py

@@ -38,12 +38,13 @@ class Entry_blob(Entry):
     def ObtainContents(self):
         self._filename = self.GetDefaultFilename()
         self._pathname = tools.GetInputFilename(self._filename,
-                                                self.section.GetAllowMissing())
+            self.external and self.section.GetAllowMissing())
         # Allow the file to be missing
-        if self.external and not self._pathname:
+        if not self._pathname:
             self.SetContents(b'')
             self.missing = True
             return True
+
         self.ReadBlobContents()
         return True
 

+ 7 - 0
tools/binman/ftest.py

@@ -3708,5 +3708,12 @@ class TestFunctional(unittest.TestCase):
         self.assertIn('Wibble test', err)
         self.assertIn('Another test', err)
 
+    def testMissingBlob(self):
+        """Test handling of a blob containing a missing file"""
+        with self.assertRaises(ValueError) as e:
+            self._DoTestFile('173_missing_blob.dts', allow_missing=True)
+        self.assertIn("Filename 'missing' not found in input path",
+                      str(e.exception))
+
 if __name__ == "__main__":
     unittest.main()

+ 14 - 0
tools/binman/test/173_missing_blob.dts

@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		blob {
+			filename = "missing";
+		};
+	};
+};