]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
binman: Show an error when a file is missing
authorSimon Glass <sjg@chromium.org>
Sun, 6 Sep 2020 16:35:32 +0000 (10:35 -0600)
committerBin Meng <bmeng.cn@gmail.com>
Fri, 25 Sep 2020 03:27:28 +0000 (11:27 +0800)
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>
tools/binman/etype/blob.py
tools/binman/ftest.py
tools/binman/test/173_missing_blob.dts [new file with mode: 0644]

index c5f97c85a38c3847f4f0ad0b62663c908a20804e..ecfb1e476e899c1b9dd68b855fde580d984cd9af 100644 (file)
@@ -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
 
index 95b17d0b74915d185fd5236f1c71caaf4b21482f..91225459162aa19a645dc8a7a609782b7e132782 100644 (file)
@@ -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()
diff --git a/tools/binman/test/173_missing_blob.dts b/tools/binman/test/173_missing_blob.dts
new file mode 100644 (file)
index 0000000..ffb655a
--- /dev/null
@@ -0,0 +1,14 @@
+// SPDX-License-Identifier: GPL-2.0+
+
+/dts-v1/;
+
+/ {
+       #address-cells = <1>;
+       #size-cells = <1>;
+
+       binman {
+               blob {
+                       filename = "missing";
+               };
+       };
+};