summaryrefslogtreecommitdiff
path: root/tools/binman/ftest.py
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2018-09-14 04:57:28 -0600
committerSimon Glass <sjg@chromium.org>2018-09-29 11:49:35 -0600
commit0a98b28b06800da48f006069fe14e47dd399d2ff (patch)
tree1646d2600d0b6e8ba7459695db082bc7f345d9b6 /tools/binman/ftest.py
parentb4e1a38c294f56708d1a82717c850da359401d7e (diff)
downloadu-boot-0a98b28b06800da48f006069fe14e47dd399d2ff.tar.gz
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>
Diffstat (limited to 'tools/binman/ftest.py')
-rw-r--r--tools/binman/ftest.py43
1 files changed, 43 insertions, 0 deletions
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py
index 1c3c46fc23..e919e702b5 100644
--- a/tools/binman/ftest.py
+++ b/tools/binman/ftest.py
@@ -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()