summaryrefslogtreecommitdiff
path: root/tools/binman/cbfs_util_test.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2019-07-08 13:18:55 -0600
committerSimon Glass <sjg@chromium.org>2019-07-24 12:53:46 -0700
commit7c173ced645b9fff4d5b41849375275a8b63f04d (patch)
tree6e01c55efbb0a3bec835e420d1bfbbac85b1ef35 /tools/binman/cbfs_util_test.py
parentc5ac138828c504812f09971a7a95bd73e186782e (diff)
binman: Pad empty areas of the CBFS with files
When there is lots of open space in a CBFS it is normally padded with 'empty' files so that sequentially scanning the CBFS can skip from one to the next without a break. Add support for this. Signed-off-by: Simon Glass <sjg@chromium.org>
Diffstat (limited to 'tools/binman/cbfs_util_test.py')
-rwxr-xr-xtools/binman/cbfs_util_test.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/tools/binman/cbfs_util_test.py b/tools/binman/cbfs_util_test.py
index 19086305af1..9bb6a298222 100755
--- a/tools/binman/cbfs_util_test.py
+++ b/tools/binman/cbfs_util_test.py
@@ -290,13 +290,23 @@ class TestCbfs(unittest.TestCase):
def test_cbfs_no_space_skip(self):
"""Check handling of running out of space in CBFS with file header"""
+ size = 0x5c
+ cbw = CbfsWriter(size, arch=cbfs_util.ARCHITECTURE_PPC64)
+ cbw._add_fileheader = True
+ cbw.add_file_raw('u-boot', U_BOOT_DATA)
+ with self.assertRaises(ValueError) as e:
+ cbw.get_data()
+ self.assertIn('No space for data before offset', str(e.exception))
+
+ def test_cbfs_no_space_pad(self):
+ """Check handling of running out of space in CBFS with file header"""
size = 0x70
cbw = CbfsWriter(size)
cbw._add_fileheader = True
cbw.add_file_raw('u-boot', U_BOOT_DATA)
with self.assertRaises(ValueError) as e:
cbw.get_data()
- self.assertIn('No space for data before offset', str(e.exception))
+ self.assertIn('No space for data before pad offset', str(e.exception))
def test_cbfs_bad_header_ptr(self):
"""Check handling of a bad master-header pointer"""
@@ -535,6 +545,17 @@ class TestCbfs(unittest.TestCase):
cbfs_fname = self._get_expected_cbfs(size=size, compress=['lz4', 'lzma'])
self._compare_expected_cbfs(data, cbfs_fname)
+ def test_cbfs_raw_space(self):
+ """Test files with unused space in the CBFS"""
+ size = 0xf0
+ cbw = CbfsWriter(size)
+ cbw.add_file_raw('u-boot', U_BOOT_DATA)
+ cbw.add_file_raw('u-boot-dtb', U_BOOT_DTB_DATA)
+ data = cbw.get_data()
+ self._check_raw(data, size)
+ cbfs_fname = self._get_expected_cbfs(size=size)
+ self._compare_expected_cbfs(data, cbfs_fname)
+
if __name__ == '__main__':
unittest.main()