Message ID | 20180914105736.162666-5-sjg@chromium.org |
---|---|
State | Accepted |
Commit | 0b489364f90d5cd70b594268442b14e0143c89b5 |
Delegated to: | Simon Glass |
Headers | show |
Series | binman: Expand support for SPL and TPL | expand |
On 14 September 2018 at 03:57, Simon Glass <sjg@chromium.org> wrote: > 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 | 3 +++ > tools/binman/ftest.py | 7 +++++++ > 2 files changed, 10 insertions(+) Applied to u-boot-dm, and now in mainline.
diff --git a/tools/binman/etype/text.py b/tools/binman/etype/text.py index 7a1cddf4af8..6e99819487f 100644 --- a/tools/binman/etype/text.py +++ b/tools/binman/etype/text.py @@ -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) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 7f82264f8ad..d956bd42e1b 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -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()
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 | 3 +++ tools/binman/ftest.py | 7 +++++++ 2 files changed, 10 insertions(+)