aboutsummaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2020-10-26 17:40:14 -0600
committerSimon Glass <sjg@chromium.org>2020-10-29 14:42:59 -0600
commit7d398bb1c71580da2182f0b820d91950bf4b3d24 (patch)
tree7313888ca95174059048b4dd9c76865c33a7f70d /tools/binman/ftest.py
parentd1d3ad7d1fea137a6fe0709458947ca84ffb124c (diff)
downloadu-boot-7d398bb1c71580da2182f0b820d91950bf4b3d24.zip
u-boot-7d398bb1c71580da2182f0b820d91950bf4b3d24.tar.gz
u-boot-7d398bb1c71580da2182f0b820d91950bf4b3d24.tar.bz2
binman: Make section padding consistent with other entries
At present padding of sections is inconsistent with other entry types, in that different pad bytes are used. When a normal entry is padded by its parent, the parent's pad byte is used. But for sections, the section's pad byte is used. Adjust logic to always do this the same way. Note there is still a special case in entry_Section.GetPaddedData() where an image is padded with the pad byte of the top-level section. This is necessary since otherwise there would be no way to set the pad byte of the image, without adding a top-level section to every image. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 31e93c6..830b610 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -3886,5 +3886,28 @@ class TestFunctional(unittest.TestCase):
self.assertEqual(len(U_BOOT_DATA), entry.size)
self.assertEqual(U_BOOT_DATA, entry.data)
+ def testSectionPad(self):
+ """Testing padding with sections"""
+ data = self._DoReadFile('180_section_pad.dts')
+ expected = (tools.GetBytes(ord('&'), 3) +
+ tools.GetBytes(ord('!'), 5) +
+ U_BOOT_DATA +
+ tools.GetBytes(ord('!'), 1) +
+ tools.GetBytes(ord('&'), 2))
+ self.assertEqual(expected, data)
+
+ def testSectionAlign(self):
+ """Testing alignment with sections"""
+ data = self._DoReadFileDtb('181_section_align.dts', map=True)[0]
+ expected = (b'\0' + # fill section
+ tools.GetBytes(ord('&'), 1) + # padding to section align
+ b'\0' + # fill section
+ tools.GetBytes(ord('!'), 3) + # padding to u-boot align
+ U_BOOT_DATA +
+ tools.GetBytes(ord('!'), 4) + # padding to u-boot size
+ tools.GetBytes(ord('!'), 4)) # padding to section size
+ self.assertEqual(expected, data)
+
+
if __name__ == "__main__":
unittest.main()