From: Petr Hodina <[email protected]> Add testFitFdtCompressed, which builds a FIT with lzma-compressed fdt images and checks that each embedded image.
Signed-off-by: Petr Hodina <[email protected]> --- tools/binman/ftest.py | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/tools/binman/ftest.py b/tools/binman/ftest.py index bf98b268ac1..587400ff308 100644 --- a/tools/binman/ftest.py +++ b/tools/binman/ftest.py @@ -4349,6 +4349,35 @@ class TestFunctional(unittest.TestCase): """Test an image with an FIT with multiple FDT images""" self.CheckFitFdt() + def testFitFdtCompressed(self): + """Test that fdt images are really compressed when asked""" + bintool = self.comp_bintools['lzma_alone'] + self._CheckBintool(bintool) + entry_args = {'of-list': 'test-fdt1 test-fdt2', + 'default-dt': 'test-fdt2'} + extra_indirs = [os.path.join(self._indir, TEST_FDT_SUBDIR)] + data = self._DoReadFileDtb('fit/fdt_lzma.dts', entry_args=entry_args, + extra_indirs=extra_indirs)[0] + fit_data = data[len(U_BOOT_DATA):-len(U_BOOT_NODTB_DATA)] + dtb = fdt.Fdt.FromData(fit_data) + dtb.Scan() + for seq, expected in ((1, TEST_FDT1_DATA), (2, TEST_FDT2_DATA)): + fnode = dtb.GetNode('/images/fdt-%d' % seq) + self.assertEqual('lzma', fnode.props['compression'].value) + comp = fnode.props['data'].bytes + self.assertNotEqual(expected, comp) + self.assertEqual(expected, bintool.decompress(comp)) + + def testFitFdtBadCompression(self): + """Test an unsupported fdt compression algorithm""" + entry_args = {'of-list': 'test-fdt1 test-fdt2', + 'default-dt': 'test-fdt2'} + extra_indirs = [os.path.join(self._indir, TEST_FDT_SUBDIR)] + with self.assertRaises(ValueError) as e: + self._DoReadFileDtb('fit/fdt_bad_comp.dts', entry_args=entry_args, + extra_indirs=extra_indirs) + self.assertIn("Unsupported fdt compression 'bzip2'", str(e.exception)) + def testFitFdtMissingList(self): """Test handling of a missing 'of-list' entry arg""" with self.assertRaises(ValueError) as e: -- 2.55.0
