]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
binman: Generate an error when text is not provided
authorSimon Glass <sjg@chromium.org>
Fri, 14 Sep 2018 10:57:09 +0000 (04:57 -0600)
committerSimon Glass <sjg@chromium.org>
Fri, 28 Sep 2018 17:09:01 +0000 (11:09 -0600)
When the value of a text entry is not provided an execption is generated
talking about a None type. This is confusing. Add a more explanatory error
and a test for this case.

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

index 7a1cddf4af827e6e3bacc18c6d313c9081067c9b..6e99819487faab75b2a2d7ded198f1b48987369e 100644 (file)
@@ -51,6 +51,9 @@ class Entry_text(Entry):
         self.text_label, = self.GetEntryArgsOrProps(
             [EntryArg('text-label', str)])
         self.value, = self.GetEntryArgsOrProps([EntryArg(self.text_label, str)])
+        if not self.value:
+            self.Raise("No value provided for text label '%s'" %
+                       self.text_label)
 
     def ObtainContents(self):
         self.SetContents(self.value)
index 7f82264f8ad193e6f658f75cdda14e55ded5ff93..d956bd42e1b3e8af160012a9c379b58037471087 100644 (file)
@@ -1369,6 +1369,13 @@ class TestFunctional(unittest.TestCase):
         data = self._DoReadFile('80_fill_empty.dts')
         self.assertEqual(chr(0) * 16, data)
 
+    def testTextMissing(self):
+        """Test for a text entry type where there is no text"""
+        with self.assertRaises(ValueError) as e:
+            self._DoReadFileDtb('66_text.dts',)
+        self.assertIn("Node '/binman/text': No value provided for text label "
+                      "'test-id'", str(e.exception))
+
 
 if __name__ == "__main__":
     unittest.main()