mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 17:22:22 +02:00
binman: Generate an error when text is not provided
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>
This commit is contained in:
@@ -51,6 +51,9 @@ class Entry_text(Entry):
|
|||||||
self.text_label, = self.GetEntryArgsOrProps(
|
self.text_label, = self.GetEntryArgsOrProps(
|
||||||
[EntryArg('text-label', str)])
|
[EntryArg('text-label', str)])
|
||||||
self.value, = self.GetEntryArgsOrProps([EntryArg(self.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):
|
def ObtainContents(self):
|
||||||
self.SetContents(self.value)
|
self.SetContents(self.value)
|
||||||
|
@@ -1369,6 +1369,13 @@ class TestFunctional(unittest.TestCase):
|
|||||||
data = self._DoReadFile('80_fill_empty.dts')
|
data = self._DoReadFile('80_fill_empty.dts')
|
||||||
self.assertEqual(chr(0) * 16, data)
|
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__":
|
if __name__ == "__main__":
|
||||||
unittest.main()
|
unittest.main()
|
||||||
|
Reference in New Issue
Block a user