self.uncomp_data = indata
if self.compress != 'none':
self.uncomp_size = len(indata)
- data = self.comp_bintool.compress(indata)
+ if self.comp_bintool.is_present():
+ data = self.comp_bintool.compress(indata)
+ else:
+ self.record_missing_bintool(self.comp_bintool)
+ data = tools.get_bytes(0, 1024)
else:
data = indata
return data
Decompressed data
"""
if self.compress != 'none':
- data = self.comp_bintool.decompress(indata)
- self.uncomp_size = len(data)
+ if self.comp_bintool.is_present():
+ data = self.comp_bintool.decompress(indata)
+ self.uncomp_size = len(data)
+ else:
+ self.record_missing_bintool(self.comp_bintool)
+ data = tools.get_bytes(0, 1024)
else:
data = indata
self.uncomp_data = data
self.assertTrue(isinstance(ent, Entry_blob))
self.assertEquals('missing', ent.etype)
+ def testDecompressData(self):
+ """Test the DecompressData() method of the base class"""
+ base = entry.Entry.Create(None, self.GetNode(), 'blob-dtb')
+ base.compress = 'lz4'
+ bintools = {}
+ base.comp_bintool = base.AddBintool(bintools, '_testing')
+ self.assertEquals(tools.get_bytes(0, 1024), base.CompressData(b'abc'))
+ self.assertEquals(tools.get_bytes(0, 1024), base.DecompressData(b'abc'))
+
if __name__ == "__main__":
unittest.main()
}
self.assertEqual(expected, props)
+ def testLz4Missing(self):
+ """Test that binman still produces an image if lz4 is missing"""
+ with test_util.capture_sys_output() as (_, stderr):
+ self._DoTestFile('185_compress_section.dts',
+ force_missing_bintools='lz4')
+ err = stderr.getvalue()
+ self.assertRegex(err,
+ "Image 'main-section'.*missing bintools.*: lz4")
+
def testCompressExtra(self):
"""Test compression of a section with no fixed size"""
self._CheckLz4()