diff options
| author | Alper Nebi Yasak <[email protected]> | 2022-03-27 18:31:49 +0300 |
|---|---|---|
| committer | Tom Rini <[email protected]> | 2022-04-25 10:11:05 -0400 |
| commit | 99283e5389cd5b8b7bb191913fa1d3d18e4bfbec (patch) | |
| tree | f39400aad48278bb8768a6fd11f6f96ad31e2a47 | |
| parent | 74d3b2311deeefe0da8df75d16b8d839ba5ff2a4 (diff) | |
binman: Test replacing non-section entries in FIT subsections
A previous patch fixes binman to correctly extract FIT subentries. This
makes it easier to test replacing these entries as we can write tests
using an existing helper function that relies on extracting the replaced
entry.
Add tests that replace leaf entries in FIT subsections with data of
various sizes. Replacing the subsections or the whole FIT section does
not work yet due to the section contents being re-built from unreplaced
subentries' data.
Signed-off-by: Alper Nebi Yasak <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
| -rw-r--r-- | tools/binman/ftest.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index 3fe57532d2b..421754b1d0a 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -5655,6 +5655,44 @@ fdt fdtmap Extract the devicetree blob from the fdtmap data = control.ReadEntry(image_fname, entry_path) self.assertEqual(expected, data) + def testReplaceFitSubentryLeafSameSize(self): + """Test replacing a FIT leaf subentry with same-size data""" + new_data = b'x' * len(U_BOOT_DATA) + data, expected_fdtmap, _ = self._RunReplaceCmd( + 'fit/kernel/u-boot', new_data, + dts='233_fit_extract_replace.dts') + self.assertEqual(new_data, data) + + path, fdtmap = state.GetFdtContents('fdtmap') + self.assertIsNotNone(path) + self.assertEqual(expected_fdtmap, fdtmap) + + def testReplaceFitSubentryLeafBiggerSize(self): + """Test replacing a FIT leaf subentry with bigger-size data""" + new_data = b'ub' * len(U_BOOT_NODTB_DATA) + data, expected_fdtmap, _ = self._RunReplaceCmd( + 'fit/fdt-1/u-boot-nodtb', new_data, + dts='233_fit_extract_replace.dts') + self.assertEqual(new_data, data) + + # Will be repacked, so fdtmap must change + path, fdtmap = state.GetFdtContents('fdtmap') + self.assertIsNotNone(path) + self.assertNotEqual(expected_fdtmap, fdtmap) + + def testReplaceFitSubentryLeafSmallerSize(self): + """Test replacing a FIT leaf subentry with smaller-size data""" + new_data = b'x' + expected = new_data.ljust(len(U_BOOT_NODTB_DATA), b'\0') + data, expected_fdtmap, _ = self._RunReplaceCmd( + 'fit/fdt-1/u-boot-nodtb', new_data, + dts='233_fit_extract_replace.dts') + self.assertEqual(expected, data) + + path, fdtmap = state.GetFdtContents('fdtmap') + self.assertIsNotNone(path) + self.assertEqual(expected_fdtmap, fdtmap) + if __name__ == "__main__": unittest.main() |
