binman: Make the operation of Entry__testing explicit
authorSimon Glass <sjg@chromium.org>
Fri, 6 Jul 2018 16:27:15 +0000 (10:27 -0600)
committerSimon Glass <sjg@chromium.org>
Mon, 9 Jul 2018 15:11:00 +0000 (09:11 -0600)
This fake entry is used for testing. At present it only has one behaviour
which is to return an invalid set of entry positions, to cause an error.

The fake entry will need to be used for other things too. Allow the test
.dts file to specify the behaviour of the fake entry, so we can control
its behaviour easily.

While we are here, drop the ReadContents() method, since this only applies
to subclasses of Entry_blob, which Entry__testing is not.

Signed-off-by: Simon Glass <sjg@chromium.org>
tools/binman/etype/_testing.py
tools/binman/test/41_unknown_pos_size.dts

index c376dd5c9ca296d3b87618f36a0a4d589ddccd78..0b1eaefc3ce4aac83af884a40e956f5439f52bb9 100644 (file)
@@ -10,16 +10,22 @@ import fdt_util
 import tools
 
 class Entry__testing(Entry):
+    """A fake entry used for testing
+
+    Properties:
+        return_invalid_entry: Return an invalid entry from GetPositions()
+    """
     def __init__(self, section, etype, node):
         Entry.__init__(self, section, etype, node)
+        self.return_invalid_entry = fdt_util.GetBool(self._node,
+                                                     'return-invalid-entry')
 
     def ObtainContents(self):
         self.data = 'a'
         self.contents_size = len(self.data)
         return True
 
-    def ReadContents(self):
-        return True
-
     def GetPositions(self):
-        return {'invalid-entry': [1, 2]}
+        if self.return_invalid_entry :
+            return {'invalid-entry': [1, 2]}
+        return {}
index a8e7d8aa2276b3c1a58a5f1fc95d045dc4685b79..94fe821c470b3216c98e15c64308342474ddf8e3 100644 (file)
@@ -6,6 +6,7 @@
 
        binman {
                _testing {
+                       return-invalid-entry;
                };
         };
 };