aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/binman/control.py2
-rw-r--r--tools/binman/ftest.py21
2 files changed, 22 insertions, 1 deletions
diff --git a/tools/binman/control.py b/tools/binman/control.py
index e170aea..ce57dc7 100644
--- a/tools/binman/control.py
+++ b/tools/binman/control.py
@@ -303,7 +303,7 @@ def BeforeReplace(image, allow_resize):
# If repacking, drop the old offset/size values except for the original
# ones, so we are only left with the constraints.
- if allow_resize:
+ if image.allow_repack and allow_resize:
image.ResetForPack()
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 03e6d92..c9a8209 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -5592,6 +5592,27 @@ fdt fdtmap Extract the devicetree blob from the fdtmap
finally:
shutil.rmtree(tmpdir)
+ def testReplaceResizeNoRepackSameSize(self):
+ """Test replacing entries with same-size data without repacking"""
+ expected = b'x' * len(U_BOOT_DATA)
+ data, expected_fdtmap, _ = self._RunReplaceCmd('u-boot', expected)
+ self.assertEqual(expected, data)
+
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertEqual(expected_fdtmap, fdtmap)
+
+ def testReplaceResizeNoRepackSmallerSize(self):
+ """Test replacing entries with smaller-size data without repacking"""
+ new_data = b'x'
+ data, expected_fdtmap, _ = self._RunReplaceCmd('u-boot', new_data)
+ expected = new_data.ljust(len(U_BOOT_DATA), b'\0')
+ self.assertEqual(expected, data)
+
+ path, fdtmap = state.GetFdtContents('fdtmap')
+ self.assertIsNotNone(path)
+ self.assertEqual(expected_fdtmap, fdtmap)
+
if __name__ == "__main__":
unittest.main()