Commit c7722e84 authored by Simon Glass's avatar Simon Glass

binman: Tweak implementation of fmap

Use an interator in two of the fmap tests so it is easier to add new
items. Also check the name first since that is the first indication
that something is wrong. Use a variable for the expected size of the
fmap to avoid repeating the code.
Signed-off-by: Simon Glass's avatarSimon Glass <sjg@chromium.org>
parent ec6db6c2
......@@ -1595,26 +1595,29 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(1, fhdr.ver_major)
self.assertEqual(0, fhdr.ver_minor)
self.assertEqual(0, fhdr.base)
self.assertEqual(16 + 16 +
fmap_util.FMAP_HEADER_LEN +
fmap_util.FMAP_AREA_LEN * 3, fhdr.image_size)
expect_size = fmap_util.FMAP_HEADER_LEN + fmap_util.FMAP_AREA_LEN * 3
self.assertEqual(16 + 16 + expect_size, fhdr.image_size)
self.assertEqual(b'FMAP', fhdr.name)
self.assertEqual(3, fhdr.nareas)
for fentry in fentries:
self.assertEqual(0, fentry.flags)
self.assertEqual(0, fentries[0].offset)
self.assertEqual(4, fentries[0].size)
self.assertEqual(b'RO_U_BOOT', fentries[0].name)
self.assertEqual(16, fentries[1].offset)
self.assertEqual(4, fentries[1].size)
self.assertEqual(b'RW_U_BOOT', fentries[1].name)
self.assertEqual(32, fentries[2].offset)
self.assertEqual(fmap_util.FMAP_HEADER_LEN +
fmap_util.FMAP_AREA_LEN * 3, fentries[2].size)
self.assertEqual(b'FMAP', fentries[2].name)
fiter = iter(fentries)
fentry = next(fiter)
self.assertEqual(b'RO_U_BOOT', fentry.name)
self.assertEqual(0, fentry.offset)
self.assertEqual(4, fentry.size)
self.assertEqual(0, fentry.flags)
fentry = next(fiter)
self.assertEqual(b'RW_U_BOOT', fentry.name)
self.assertEqual(16, fentry.offset)
self.assertEqual(4, fentry.size)
self.assertEqual(0, fentry.flags)
fentry = next(fiter)
self.assertEqual(b'FMAP', fentry.name)
self.assertEqual(32, fentry.offset)
self.assertEqual(expect_size, fentry.size)
self.assertEqual(0, fentry.flags)
def testBlobNamedByArg(self):
"""Test we can add a blob with the filename coming from an entry arg"""
......@@ -2065,19 +2068,23 @@ class TestFunctional(unittest.TestCase):
fhdr, fentries = fmap_util.DecodeFmap(data[36:])
self.assertEqual(0x100, fhdr.image_size)
self.assertEqual(0, fentries[0].offset)
self.assertEqual(4, fentries[0].size)
self.assertEqual(b'U_BOOT', fentries[0].name)
self.assertEqual(4, fentries[1].offset)
self.assertEqual(3, fentries[1].size)
self.assertEqual(b'INTEL_MRC', fentries[1].name)
self.assertEqual(36, fentries[2].offset)
self.assertEqual(fmap_util.FMAP_HEADER_LEN +
fmap_util.FMAP_AREA_LEN * 3, fentries[2].size)
self.assertEqual(b'FMAP', fentries[2].name)
expect_size = fmap_util.FMAP_HEADER_LEN + fmap_util.FMAP_AREA_LEN * 3
fiter = iter(fentries)
fentry = next(fiter)
self.assertEqual(b'U_BOOT', fentry.name)
self.assertEqual(0, fentry.offset)
self.assertEqual(4, fentry.size)
fentry = next(fiter)
self.assertEqual(b'INTEL_MRC', fentry.name)
self.assertEqual(4, fentry.offset)
self.assertEqual(3, fentry.size)
fentry = next(fiter)
self.assertEqual(b'FMAP', fentry.name)
self.assertEqual(36, fentry.offset)
self.assertEqual(expect_size, fentry.size)
def testElf(self):
"""Basic test of ELF entries"""
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment