diff options
Diffstat (limited to 'tools/binman/cbfs_util_test.py')
-rwxr-xr-x | tools/binman/cbfs_util_test.py | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py index ee951d10cf..4c415b7ce9 100755 --- a/tools/binman/cbfs_util_test.py +++ b/tools/binman/cbfs_util_test.py @@ -96,7 +96,7 @@ class TestCbfs(unittest.TestCase): self.assertEqual(arch, cbfs.arch) return cbfs - def _check_uboot(self, cbfs, ftype=cbfs_util.TYPE_RAW, offset=0x38, + def _check_uboot(self, cbfs, ftype=cbfs_util.TYPE_RAW, offset=0x20, data=U_BOOT_DATA, cbfs_offset=None): """Check that the U-Boot file is as expected @@ -122,7 +122,7 @@ class TestCbfs(unittest.TestCase): self.assertEqual(len(data), cfile.memlen) return cfile - def _check_dtb(self, cbfs, offset=0x38, data=U_BOOT_DTB_DATA, + def _check_dtb(self, cbfs, offset=0x24, data=U_BOOT_DTB_DATA, cbfs_offset=None): """Check that the U-Boot dtb file is as expected @@ -391,7 +391,7 @@ class TestCbfs(unittest.TestCase): cbfs_util.DEBUG = True with test_util.capture_sys_output() as (stdout, _stderr): cbfs_util.CbfsReader(data) - self.assertEqual('name u-boot\ndata %s\n' % U_BOOT_DATA, + self.assertEqual('name u-boot\nftype 50\ndata %s\n' % U_BOOT_DATA, stdout.getvalue()) finally: cbfs_util.DEBUG = False @@ -437,8 +437,9 @@ class TestCbfs(unittest.TestCase): pos = fd.tell() # Create a new CBFS with only the first 4 bytes of the compression tag, - # then try to read the file - tag_pos = pos + cbfs_util.FILE_HEADER_LEN + cbfs_util.FILENAME_ALIGN + # then try to read the file. Note that the tag gets pushed out 4 bytes + tag_pos = (4 + pos + cbfs_util.FILE_HEADER_LEN + + cbfs_util.ATTRIBUTE_ALIGN) newdata = data[:tag_pos + 4] with test_util.capture_sys_output() as (stdout, _stderr): with io.BytesIO(newdata) as fd: @@ -474,7 +475,7 @@ class TestCbfs(unittest.TestCase): self._compare_expected_cbfs(data, cbfs_fname) def test_cbfs_stage(self): - """Tests handling of a Coreboot Filesystem (CBFS)""" + """Tests handling of a CBFS stage""" if not elf.ELF_TOOLS: self.skipTest('Python elftools not available') elf_fname = os.path.join(self._indir, 'cbfs-stage.elf') @@ -489,7 +490,7 @@ class TestCbfs(unittest.TestCase): load = 0xfef20000 entry = load + 2 - cfile = self._check_uboot(cbfs, cbfs_util.TYPE_STAGE, offset=0x28, + cfile = self._check_uboot(cbfs, cbfs_util.TYPE_STAGE, offset=0x38, data=U_BOOT_DATA + U_BOOT_DTB_DATA) self.assertEqual(entry, cfile.entry) @@ -520,7 +521,7 @@ class TestCbfs(unittest.TestCase): self.assertIn('u-boot', cbfs.files) cfile = cbfs.files['u-boot'] self.assertEqual(cfile.name, 'u-boot') - self.assertEqual(cfile.offset, 56) + self.assertEqual(cfile.offset, 0x30) self.assertEqual(cfile.data, COMPRESS_DATA) self.assertEqual(cfile.ftype, cbfs_util.TYPE_RAW) self.assertEqual(cfile.compress, cbfs_util.COMPRESS_LZ4) @@ -529,7 +530,7 @@ class TestCbfs(unittest.TestCase): self.assertIn('u-boot-dtb', cbfs.files) cfile = cbfs.files['u-boot-dtb'] self.assertEqual(cfile.name, 'u-boot-dtb') - self.assertEqual(cfile.offset, 56) + self.assertEqual(cfile.offset, 0x34) self.assertEqual(cfile.data, COMPRESS_DATA) self.assertEqual(cfile.ftype, cbfs_util.TYPE_RAW) self.assertEqual(cfile.compress, cbfs_util.COMPRESS_LZMA) @@ -598,8 +599,8 @@ class TestCbfs(unittest.TestCase): data = cbw.get_data() cbfs = cbfs_util.CbfsReader(data) - self.assertEqual(0x38, cbfs.files['u-boot'].cbfs_offset) - self.assertEqual(0x78, cbfs.files['u-boot-dtb'].cbfs_offset) + self.assertEqual(0x20, cbfs.files['u-boot'].cbfs_offset) + self.assertEqual(0x64, cbfs.files['u-boot-dtb'].cbfs_offset) if __name__ == '__main__': |