aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/etype/_testing.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-20 12:23:57 -0600
committerSimon Glass <sjg@chromium.org>2019-07-29 09:38:06 -0600
commit79d3c58d1268786ce40c6c0920ed2a447247fdc4 (patch)
tree309446efa8a5ccbde4024c312ac7342e7d27e3cc /tools/binman/etype/_testing.py
parent51014aabc28e497eb98e0ba9c1fa0f19e871af1b (diff)
downloadu-boot-79d3c58d1268786ce40c6c0920ed2a447247fdc4.zip
u-boot-79d3c58d1268786ce40c6c0920ed2a447247fdc4.tar.gz
u-boot-79d3c58d1268786ce40c6c0920ed2a447247fdc4.tar.bz2
binman: Update the _testing entry to support shrinkage
Sometimes entries shrink after packing. As a start towards supporting this, update the _testing entry to handle the test case. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/etype/_testing.py')
-rw-r--r--tools/binman/etype/_testing.py25
1 files changed, 19 insertions, 6 deletions
diff --git a/tools/binman/etype/_testing.py b/tools/binman/etype/_testing.py
index 4a2e4eb..25a6206 100644
--- a/tools/binman/etype/_testing.py
+++ b/tools/binman/etype/_testing.py
@@ -31,8 +31,8 @@ class Entry__testing(Entry):
return-invalid-entry: Return an invalid entry from GetOffsets()
return-unknown-contents: Refuse to provide any contents (to cause a
failure)
- bad-update-contents: Implement ProcessContents() incorrectly so as to
- cause a failure
+ bad-update-contents: Return a larger size in ProcessContents
+ bad-shrink-contents: Return a larger size in ProcessContents
never-complete-process-fdt: Refund to process the FDT (to cause a
failure)
require-args: Require that all used args are present (generating an
@@ -51,6 +51,8 @@ class Entry__testing(Entry):
'return-unknown-contents')
self.bad_update_contents = fdt_util.GetBool(self._node,
'bad-update-contents')
+ self.bad_shrink_contents = fdt_util.GetBool(self._node,
+ 'bad-shrink-contents')
self.return_contents_once = fdt_util.GetBool(self._node,
'return-contents-once')
self.bad_update_contents_twice = fdt_util.GetBool(self._node,
@@ -76,7 +78,7 @@ class Entry__testing(Entry):
if self.force_bad_datatype:
self.GetEntryArgsOrProps([EntryArg('test-bad-datatype-arg', bool)])
self.return_contents = True
- self.contents = b'a'
+ self.contents = b'aa'
def ObtainContents(self):
if self.return_unknown_contents or not self.return_contents:
@@ -93,14 +95,25 @@ class Entry__testing(Entry):
return {}
def ProcessContents(self):
+ data = self.contents
if self.bad_update_contents:
# Request to update the contents with something larger, to cause a
# failure.
if self.bad_update_contents_twice:
- self.contents += b'a'
+ data = self.data + b'a'
else:
- self.contents = b'aa'
- return self.ProcessContentsUpdate(self.contents)
+ data = b'aaa'
+ return self.ProcessContentsUpdate(data)
+ if self.bad_shrink_contents:
+ # Request to update the contents with something smaller, to cause a
+ # failure.
+ data = b'a'
+ return self.ProcessContentsUpdate(data)
+ if self.bad_shrink_contents:
+ # Request to update the contents with something smaller, to cause a
+ # failure.
+ data = b'a'
+ return self.ProcessContentsUpdate(data)
return True
def ProcessFdt(self, fdt):