mirror of
https://github.com/brain-hackers/u-boot-brain
synced 2024-10-01 17:10:42 +09:00
binman: Detect bad CBFS file types
Detect when an unknown or unsupported file type is specified and report an error. Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
parent
69f7cb31a0
commit
8a1ad068de
@ -190,6 +190,9 @@ class Entry_cbfs(Entry):
|
||||
elif entry._type == 'stage':
|
||||
cfile = cbfs.add_file_stage(entry._cbfs_name, data,
|
||||
entry._cbfs_offset)
|
||||
else:
|
||||
entry.Raise("Unknown cbfs-type '%s' (use 'raw', 'stage')" %
|
||||
entry._type)
|
||||
if cfile:
|
||||
entry._cbfs_file = cfile
|
||||
entry.size = cfile.data_len
|
||||
|
@ -2185,6 +2185,12 @@ class TestFunctional(unittest.TestCase):
|
||||
'cbfs/u-boot-dtb:image-pos': 0xb8,
|
||||
}, props)
|
||||
|
||||
def testCbfsBadType(self):
|
||||
"""Test an image header with a no specified location is detected"""
|
||||
with self.assertRaises(ValueError) as e:
|
||||
self._DoReadFile('126_cbfs_bad_type.dts')
|
||||
self.assertIn("Unknown cbfs-type 'badtype'", str(e.exception))
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
17
tools/binman/test/126_cbfs_bad_type.dts
Normal file
17
tools/binman/test/126_cbfs_bad_type.dts
Normal file
@ -0,0 +1,17 @@
|
||||
// SPDX-License-Identifier: GPL-2.0+
|
||||
|
||||
/dts-v1/;
|
||||
|
||||
/ {
|
||||
#address-cells = <1>;
|
||||
#size-cells = <1>;
|
||||
|
||||
binman {
|
||||
cbfs {
|
||||
size = <0x100>;
|
||||
u-boot {
|
||||
cbfs-type = "badtype";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
Loading…
Reference in New Issue
Block a user