[U-Boot] [PATCH 03/31] binman: Allow 'fill' entry to have a size of 0

Simon Glass sjg at chromium.org
Fri Sep 14 10:57:08 UTC 2018


The check for this should be for None, not 0. Fix it and add a test.

Signed-off-by: Simon Glass <sjg at chromium.org>
---

 tools/binman/etype/fill.py          |  2 +-
 tools/binman/ftest.py               |  5 +++++
 tools/binman/test/80_fill_empty.dts | 15 +++++++++++++++
 3 files changed, 21 insertions(+), 1 deletion(-)
 create mode 100644 tools/binman/test/80_fill_empty.dts

diff --git a/tools/binman/etype/fill.py b/tools/binman/etype/fill.py
index 7210a8324a0..dcfe978a5bf 100644
--- a/tools/binman/etype/fill.py
+++ b/tools/binman/etype/fill.py
@@ -23,7 +23,7 @@ class Entry_fill(Entry):
     """
     def __init__(self, section, etype, node):
         Entry.__init__(self, section, etype, node)
-        if not self.size:
+        if self.size is None:
             self.Raise("'fill' entry must have a size property")
         self.fill_value = fdt_util.GetByte(self._node, 'fill-byte', 0)
 
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index a8456c26157..7f82264f8ad 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1364,6 +1364,11 @@ class TestFunctional(unittest.TestCase):
         self.assertIn("Node '/binman/u-boot': Please use 'offset' instead of "
                       "'pos'", str(e.exception))
 
+    def testFillZero(self):
+        """Test for an fill entry type with a size of 0"""
+        data = self._DoReadFile('80_fill_empty.dts')
+        self.assertEqual(chr(0) * 16, data)
+
 
 if __name__ == "__main__":
     unittest.main()
diff --git a/tools/binman/test/80_fill_empty.dts b/tools/binman/test/80_fill_empty.dts
new file mode 100644
index 00000000000..2b78d3ae88d
--- /dev/null
+++ b/tools/binman/test/80_fill_empty.dts
@@ -0,0 +1,15 @@
+// SPDX-License-Identifier: GPL-2.0+
+/dts-v1/;
+
+/ {
+	#address-cells = <1>;
+	#size-cells = <1>;
+
+	binman {
+		size = <16>;
+		fill {
+			size = <0>;
+			fill-byte = [ff];
+		};
+	};
+};
-- 
2.19.0.397.gdd90340f6a-goog



More information about the U-Boot mailing list