mirror of
https://xff.cz/git/u-boot/
synced 2025-09-02 01:02:19 +02:00
binman: Support adding files
In some cases it is useful to add a group of files to the image and be able to access them at run-time. Of course it is possible to generate the binman config file with a set of blobs each with a filename. But for convenience, add an entry type which can do this. Add required support (for adding nodes and string properties) into the state module. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -54,6 +54,8 @@ CROS_EC_RW_DATA = 'ecrw'
|
||||
GBB_DATA = 'gbbd'
|
||||
BMPBLK_DATA = 'bmp'
|
||||
VBLOCK_DATA = 'vblk'
|
||||
FILES_DATA = ("sorry I'm late\nOh, don't bother apologising, I'm " +
|
||||
"sorry you're alive\n")
|
||||
COMPRESS_DATA = 'data to compress'
|
||||
|
||||
|
||||
@@ -117,6 +119,9 @@ class TestFunctional(unittest.TestCase):
|
||||
with open(self.TestFile('descriptor.bin')) as fd:
|
||||
TestFunctional._MakeInputFile('descriptor.bin', fd.read())
|
||||
|
||||
shutil.copytree(self.TestFile('files'),
|
||||
os.path.join(self._indir, 'files'))
|
||||
|
||||
TestFunctional._MakeInputFile('compress', COMPRESS_DATA)
|
||||
|
||||
@classmethod
|
||||
@@ -1536,6 +1541,44 @@ class TestFunctional(unittest.TestCase):
|
||||
}
|
||||
self.assertEqual(expected, props)
|
||||
|
||||
def testFiles(self):
|
||||
"""Test bringing in multiple files"""
|
||||
data = self._DoReadFile('84_files.dts')
|
||||
self.assertEqual(FILES_DATA, data)
|
||||
|
||||
def testFilesCompress(self):
|
||||
"""Test bringing in multiple files and compressing them"""
|
||||
data = self._DoReadFile('85_files_compress.dts')
|
||||
|
||||
image = control.images['image']
|
||||
entries = image.GetEntries()
|
||||
files = entries['files']
|
||||
entries = files._section._entries
|
||||
|
||||
orig = ''
|
||||
for i in range(1, 3):
|
||||
key = '%d.dat' % i
|
||||
start = entries[key].image_pos
|
||||
len = entries[key].size
|
||||
chunk = data[start:start + len]
|
||||
orig += self._decompress(chunk)
|
||||
|
||||
self.assertEqual(FILES_DATA, orig)
|
||||
|
||||
def testFilesMissing(self):
|
||||
"""Test missing files"""
|
||||
with self.assertRaises(ValueError) as e:
|
||||
data = self._DoReadFile('86_files_none.dts')
|
||||
self.assertIn("Node '/binman/files': Pattern \'files/*.none\' matched "
|
||||
'no files', str(e.exception))
|
||||
|
||||
def testFilesNoPattern(self):
|
||||
"""Test missing files"""
|
||||
with self.assertRaises(ValueError) as e:
|
||||
data = self._DoReadFile('87_files_no_pattern.dts')
|
||||
self.assertIn("Node '/binman/files': Missing 'pattern' property",
|
||||
str(e.exception))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
Reference in New Issue
Block a user