
From: Stefan Herbrechtsmeier stefan.herbrechtsmeier@weidmueller.com
Use the low level compression commands in the tests to detect failures in the utilities to compress and decompress data.
The decompression in U-Boot expects plain compression data without any header.
Signed-off-by: Stefan Herbrechtsmeier stefan.herbrechtsmeier@weidmueller.com
--- This commit breaks the binman tests because the tests wrongly expects a header in front of the data.
tools/binman/ftest.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index fa1f421c05..b1f564ed7d 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -107,6 +107,8 @@ BASE_DTB_PROPS = ['offset', 'size', 'image-pos'] # Extra properties expected to be in the device tree when allow-repack is used REPACK_DTB_PROPS = ['orig-offset', 'orig-size']
+# Tools +LZ4 = bintool.Bintool.create('lz4')
class TestFunctional(unittest.TestCase): """Functional tests for binman @@ -1967,7 +1969,7 @@ class TestFunctional(unittest.TestCase): self._ResetDtbs()
def _decompress(self, data): - return comp_util.decompress(data, 'lz4') + return LZ4.decompress(data)
def testCompress(self): """Test compression of blobs""" @@ -2856,7 +2858,8 @@ class TestFunctional(unittest.TestCase): def testExtractCbfsRaw(self): """Test extracting CBFS compressed data without decompressing it""" data = self._RunExtractCmd('section/cbfs/u-boot-dtb', decomp=False) - dtb = comp_util.decompress(data, 'lzma', with_header=False) + lzma_alone = bintool.Bintool.create('lzma_alone') + dtb = lzma_alone.decompress(data) self.assertEqual(EXTRACT_DTB_SIZE, len(dtb))
def testExtractBadEntry(self): @@ -4412,6 +4415,9 @@ class TestFunctional(unittest.TestCase): } self.assertEqual(expected, props)
+ def _compress(self, data): + return LZ4.compress(data) + def testCompressExtra(self): """Test compression of a section with no fixed size""" self._CheckLz4() @@ -4427,15 +4433,17 @@ class TestFunctional(unittest.TestCase): rest = base[len(U_BOOT_DATA):]
# Check compressed data - section1 = self._decompress(rest) - expect1 = comp_util.compress(COMPRESS_DATA + U_BOOT_DATA, 'lz4') - self.assertEquals(expect1, rest[:len(expect1)]) + expect1 = self._compress(COMPRESS_DATA + U_BOOT_DATA) + data1 = rest[:len(expect1)] + self.assertEquals(expect1, data1) + section1 = self._decompress(data1) self.assertEquals(COMPRESS_DATA + U_BOOT_DATA, section1) rest1 = rest[len(expect1):]
- section2 = self._decompress(rest1) - expect2 = comp_util.compress(COMPRESS_DATA + COMPRESS_DATA, 'lz4') - self.assertEquals(expect2, rest1[:len(expect2)]) + expect2 = self._compress(COMPRESS_DATA + COMPRESS_DATA) + data2 = rest1[:len(expect2)] + self.assertEquals(expect2, data2) + section2 = self._decompress(data2) self.assertEquals(COMPRESS_DATA + COMPRESS_DATA, section2) rest2 = rest1[len(expect2):]