summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-08 14:25:45 -0600
committerSimon Glass <sjg@chromium.org>2019-07-24 12:54:08 -0700
commit2d26003df79839d7f6b5e30eaa49e191dc9e6c87 (patch)
treea25e9d32a35308c9fead99df9adebbac5f7f1d17 /tools/binman/ftest.py
parente1925fa520187b1f34c0ecabc47a147754594ecd (diff)
binman: Support locating an image header
Add support for locating an image header in an image. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index d800ba1e9d8..ce66e3a2f20 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -25,6 +25,7 @@ import control
import elf
import fdt
from etype import fdtmap
+from etype import image_header
import fdt_util
import fmap_util
import test_util
@@ -2282,6 +2283,32 @@ class TestFunctional(unittest.TestCase):
data = self._DoReadFile('005_simple.dts')
self.assertEqual(None, fdtmap.LocateFdtmap(data))
+ def testFindImageHeader(self):
+ """Test locating a image header"""
+ self._CheckLz4()
+ data = self._DoReadFileDtb('128_decode_image.dts', use_real_dtb=True,
+ update_dtb=True)[0]
+ image = control.images['image']
+ entries = image.GetEntries()
+ entry = entries['fdtmap']
+ # The header should point to the FDT map
+ self.assertEqual(entry.image_pos, image_header.LocateHeaderOffset(data))
+
+ def testFindImageHeaderStart(self):
+ """Test locating a image header located at the start of an image"""
+ data = self._DoReadFileDtb('117_fdtmap_hdr_start.dts',
+ use_real_dtb=True, update_dtb=True)[0]
+ image = control.images['image']
+ entries = image.GetEntries()
+ entry = entries['fdtmap']
+ # The header should point to the FDT map
+ self.assertEqual(entry.image_pos, image_header.LocateHeaderOffset(data))
+
+ def testFindImageHeaderMissing(self):
+ """Test failing to locate an image header"""
+ data = self._DoReadFile('005_simple.dts')
+ self.assertEqual(None, image_header.LocateHeaderOffset(data))
+
if __name__ == "__main__":
unittest.main()