summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2024-08-26 13:11:39 -0600
committerSimon Glass <sjg@chromium.org>2024-09-26 12:40:30 +0200
commit01a609930b996499b36418108125ee53ab7094b5 (patch)
tree748967827daf391f922da36539595a4767c64565 /tools/binman/ftest.py
parentf2154c30f6174eb27dfe92c91950f6436f802f1b (diff)
binman: Add minor improvements to symbol-writing
Add a clarification to the documentation and add a missing comment. Also update the test so that when it fails it is easier to see what is going on, rather than having to decode hex strings. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py36
1 files changed, 29 insertions, 7 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index b133c76188c..7b4454bd342 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -1526,18 +1526,40 @@ class TestFunctional(unittest.TestCase):
# The image should contain the symbols from u_boot_binman_syms.c
# Note that image_pos is adjusted by the base address of the image,
# which is 0x10 in our test image
- sym_values = struct.pack('<LLQLL', elf.BINMAN_SYM_MAGIC_VALUE,
- 0x00, u_boot_offset + len(U_BOOT_DATA),
- 0x10 + u_boot_offset, 0x04)
+ vals = (elf.BINMAN_SYM_MAGIC_VALUE, 0x00,
+ u_boot_offset + len(U_BOOT_DATA),
+ 0x10 + u_boot_offset, 0x04)
+ sym_values = struct.pack('<LLQLL', *vals)
if no_write_symbols:
- expected = (base_data +
- tools.get_bytes(0xff, 0x38 - len(base_data)) +
- U_BOOT_DATA + base_data)
+ self.assertEqual(
+ base_data +
+ tools.get_bytes(0xff, 0x38 - len(base_data)) +
+ U_BOOT_DATA + base_data, data)
else:
+ got_vals = struct.unpack('<LLQLL', data[:24])
+
+ # For debugging:
+ #print('expect:', list(f'{v:x}' for v in vals))
+ #print(' got:', list(f'{v:x}' for v in got_vals))
+
+ self.assertEqual(vals, got_vals)
+ self.assertEqual(sym_values, data[:24])
+
+ blen = len(base_data)
+ self.assertEqual(base_data[24:], data[24:blen])
+ self.assertEqual(0xff, data[blen])
+
+ ofs = blen + 1 + len(U_BOOT_DATA)
+ self.assertEqual(U_BOOT_DATA, data[blen + 1:ofs])
+
+ self.assertEqual(sym_values, data[ofs:ofs + 24])
+ self.assertEqual(base_data[24:], data[ofs + 24:])
+
+ # Just repeating the above asserts all at once, for clarity
expected = (sym_values + base_data[24:] +
tools.get_bytes(0xff, 1) + U_BOOT_DATA + sym_values +
base_data[24:])
- self.assertEqual(expected, data)
+ self.assertEqual(expected, data)
def testSymbols(self):
"""Test binman can assign symbols embedded in U-Boot"""