binman: Make the operation of Entry__testing explicit
[oweals/u-boot.git] / tools / binman / etype / _testing.py
1 # SPDX-License-Identifier: GPL-2.0+
2 # Copyright (c) 2016 Google, Inc
3 # Written by Simon Glass <sjg@chromium.org>
4 #
5 # Entry-type module for testing purposes. Not used in real images.
6 #
7
8 from entry import Entry
9 import fdt_util
10 import tools
11
12 class Entry__testing(Entry):
13     """A fake entry used for testing
14
15     Properties:
16         return_invalid_entry: Return an invalid entry from GetPositions()
17     """
18     def __init__(self, section, etype, node):
19         Entry.__init__(self, section, etype, node)
20         self.return_invalid_entry = fdt_util.GetBool(self._node,
21                                                      'return-invalid-entry')
22
23     def ObtainContents(self):
24         self.data = 'a'
25         self.contents_size = len(self.data)
26         return True
27
28     def GetPositions(self):
29         if self.return_invalid_entry :
30             return {'invalid-entry': [1, 2]}
31         return {}