summaryrefslogtreecommitdiff
path: root/tools/binman
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-09-06 10:35:32 -0600
committerBin Meng <bmeng.cn@gmail.com>2020-09-25 11:27:28 +0800
commit204aa78e04a290c6836bdb29ba466b9cdfcec3ea (patch)
tree2bec893227d08429f383d6e984af6347a66ea072 /tools/binman
parent2463f165a32370f44186e320aced170d50676b54 (diff)
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>
Diffstat (limited to 'tools/binman')
-rw-r--r--tools/binman/etype/blob.py5
-rw-r--r--tools/binman/ftest.py7
-rw-r--r--tools/binman/test/173_missing_blob.dts14
3 files changed, 24 insertions, 2 deletions
diff --git a/tools/binman/etype/blob.py b/tools/binman/etype/blob.py
index c5f97c85a3..ecfb1e476e 100644
--- a/tools/binman/etype/blob.py
+++ b/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
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 95b17d0b74..9122545916 100644
--- a/tools/binman/ftest.py
+++ b/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()
diff --git a/tools/binman/test/173_missing_blob.dts b/tools/binman/test/173_missing_blob.dts
new file mode 100644
index 0000000000..ffb655a1cb
--- /dev/null
+++ b/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";
+ };
+ };
+};